agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

bug(desktop): active local worker missing from expanded project sidebar despite healthy session API

Open harshitsinghbhandari opened this issue 2 months ago • 2 comments

Summary

An existing local project's active worker is absent from the desktop sidebar. Reporter Harshit Singh Bhandari (@harshitsinghbhandari) supplied two screenshots of hosted-ao, one collapsed and one expanded, with no worker row. At investigation time the bundled daemon returned hosted-ao-103 as kind=worker, harness=codex, isTerminated=false, status=working.

Source: direct report in an AO investigation session on 2026-09-07, with the original screenshots below. No public chat permalink was supplied. Investigation only; no session changes or product implementation.

Environment and exact versions

  • macOS, darwin/arm64. Screenshot times: 2026-09-07 13:00:38 and 13:00:47 IST (07:30:38 and 07:30:47 UTC).
  • Installed app: /Applications/Agent Orchestrator.app, version 0.12.13-nightly.202609061848 from Info.plist and packaged package.json.
  • Explicit bundled binary: /Applications/Agent Orchestrator.app/Contents/Resources/daemon/ao. Its version command prints dev; go version -m identifies Go 1.26.5, revision 84fb37ce5aa947ceb9b19b0c2435b242ac92ce26, VCS time 2026-09-06T18:18:08Z, vcs.modified=true. That SHA alone is therefore not an exact clean-source reproduction of the installed artifact.
  • Bundled daemon SHA256: ab091be59dbec5d57ef4f30c22ccd2bc7355f0ce72ad295329e02baab1936e6b.
  • app.asar SHA256: 55a33450336ab27f4279c51c22f23f8d21688a6b78f3570ae8680892b158d891.
  • Bundled CLI status confirmed daemon PID 48442, port 3001, healthz OK, readyz ready, started 2026-09-06T20:16:26Z.
  • Freshly fetched upstream/main inspected at 4ffcd10462839233c8761b6528e78cc5818d4c58. Investigating worktree HEAD was d820a03c6aa6da192f6758096bc396c3640201e6; source trace below uses the fetched upstream SHA, not that older worktree.
  • Installed renderer inspected directly from app.asar, including index-Bj167_BN.js and _shell-DoSIT5R8.js. Its workspace query, project join, worker termination filtering, and disclosure animation match the relevant upstream behavior.
  • Verification boundary: live HTTP evidence is from the current installed bundle. Upstream/main was source-inspected, not launched against the reporter's data. No reload/restart or mutation was used to manufacture a reproduction.

Reproduction and observed behavior

Observed sequence, not a claim of a deterministic fresh-install repro:

  1. Use the existing local hosted-ao project in the installed desktop app.
  2. Have a worker such as hosted-ao-103 created while the app is running. This worker was created at 2026-09-07T07:28:48.668039Z, about two minutes before the screenshots.
  3. Expand the hosted-ao folder in the sidebar. The supplied expanded screenshot shows no child worker row.
  4. Independently read the same daemon:
curl -sS http://127.0.0.1:3001/api/v1/projects
curl -sS http://127.0.0.1:3001/api/v1/sessions
curl -sS 'http://127.0.0.1:3001/api/v1/sessions?project=hosted-ao&active=true'
curl -sS http://127.0.0.1:3001/api/v1/sessions/hosted-ao-103

No project or worker needs to be recreated to diagnose the reported instance.

Read-only evidence

  • /api/v1/projects contains exactly matching id=hosted-ao, name=hosted-ao, kind=single_repo, folderMissing=false. Despite its name, this is a local project, not a cloud control-plane session list.
  • Initial unfiltered /api/v1/sessions returned 492 sessions, with hosted-ao-103 at zero-based index 443. The response has a sessions array and no pagination cursor.
  • Initial target projection:
{"id":"hosted-ao-103","projectId":"hosted-ao","kind":"worker","harness":"codex","isTerminated":false,"status":"working","createdAt":"2026-09-07T07:28:48.668039Z"}
  • Later active-project and detail reads still contain the worker, now status=idle, isTerminated=false, display name merge-prs. Activity changed during the investigation; the session remained eligible for the sidebar. The active-project response also contains orchestrator hosted-ao-44.
  • Spot timing: projects HTTP 200 in 0.000676 s; sessions HTTP 200 in 0.094757 s. No current hanging list request reproduced.
  • Read-only assertions over captured responses passed: matching project join, worker classification, no legacy -orchestrator suffix, and false termination flag.

Screenshots

Original 13:00:38 IST, collapsed folder:

hosted-ao collapsed with no child rows

Original 13:00:47 IST, expanded folder:

hosted-ao expanded with no child worker rows

These are reporter-supplied crops. They establish visible absence but do not reveal the renderer's query cache, DOM, connection state, or full selected route.

Trace and root cause confidence

High confidence: the reported worker exists, is active, is returned by the exact local API the sidebar queries, and should pass the shipped/upstream inclusion predicates.

Root cause confidence: Low (unconfirmed). The failure boundary is after the live daemon snapshot, potentially renderer cache freshness or disclosure/row rendering. There is insufficient evidence to choose one or claim a specific React/animation defect. The affected Electron window's cache and DOM were not captured; the worker's creation event delivery to that window was not observed.

  1. Daemon/storage/list: backend/internal/httpd/controllers/sessions.go calls Service.List, then emits ListSessionsResponse. backend/internal/service/session/service.go reads all or project-scoped records, filters durable facts, batches PR/review facts, and derives sessions. The local list path has no page limit/offset truncation. Live row 444 is present.
  2. Frontend query/grouping: frontend/src/renderer/hooks/useWorkspaceQuery.ts fetches projects and sessions in parallel, maps each project, and joins on exact session.projectId === project.id. Both requests must succeed; on error the query can retain a prior successful snapshot. Query key is ["workspaces"], stale time 10 seconds, poll interval 15 seconds, retry 1. The observed local IDs match. Cloud first-page limits of 100 exist in separate queries and do not explain this local worker.
  3. SSE/cache: frontend/src/renderer/lib/event-transport.ts explicitly subscribes to named session_created/session_updated events, batches invalidations at 150 ms, and refetches ["workspaces"] with non-cancelling refresh/catch-up logic. Reconnection also refreshes snapshots; polling should eventually repair a missed event. No absent named-event handler was found.
  4. Shell/project selection: frontend/src/renderer/routes/_shell.tsx passes useWorkspaceQuery().data into sidebar workspaces. Sidebar renders the workspace collection; route selection controls active styling and initial disclosure, not a project-scoped session API request. Project disclosure is persisted independently in localStorage. The expanded screenshot makes a simply collapsed folder insufficient as the explanation.
  5. Worker filtering/order: frontend/src/renderer/types/workspace.ts identifies orchestrators by explicit kind or legacy suffix; frontend/src/renderer/types/workspace.ts sorts workers. frontend/src/renderer/components/Sidebar.tsx removes only workers with isTerminated === true. No harness or working/idle exclusion applies. applyOrder retains newly unplaced IDs, so an old drag order should not discard this worker.
  6. Rendering: frontend/src/renderer/components/Sidebar.tsx mounts child rows only when expanded && sessions.length > 0, with AnimatePresence and height/opacity animation inside an overflow-hidden container. A cache snapshot lacking the worker or a DOM/animation problem can each produce an empty-looking expanded project; screenshots alone do not distinguish them.

Additional stale-state boundary worth testing

A single bounded 3-second GET of /api/v1/events with no cursor received 92,636,407 bytes, including approximately 378,117 named events, starting at sequence 1. The sample ended before any event mentioning hosted-ao-103. It was intentionally stopped after three seconds, not a server timeout failure.

backend/internal/httpd/events.go replays in 512-event batches; an absent cursor resolves to zero. The renderer constructs a new EventSource without an initial cursor. This confirms substantial replay load on this installation and is a plausible contributor to delayed UI work, but does not establish causality for this disappearance. A current full snapshot should still include the worker, and the renderer has polling/catch-up logic. Do not label replay as the proven root cause without a browser timeline/cache capture.

Expected behavior and impact

An expanded existing local project must show each active worker returned by the daemon, including a newly created Codex worker, without requiring app restart, project recreation, or spawning a replacement. Working-to-idle transitions must preserve the row.

The sidebar is a primary entry point for inspecting and controlling workers. A missing active row prevents normal discovery and can prompt duplicate work or leave a running agent unattended. Observed scope: one worker/project on one macOS installation. The same renderer logic is cross-platform, but broader impact is unverified. Priority proposed: P2, bounded degradation; the daemon still exposes the worker. No UI workaround was verified.

Acceptance criteria and regression tests

  • [ ] Capture the failing window's ["workspaces"] data, fetch/error timestamps, active daemon base URL, project disclosure state, child-row DOM, and computed height/opacity to identify the precise boundary.
  • [ ] An active worker created in an already expanded project becomes visible after event-driven refresh and, if the event is missed, after the next successful polling refresh.
  • [ ] Test more than 100, 200, and 400 total sessions, with this project's worker near the end of the global response. Assert no local truncation.
  • [ ] Cover cached-empty project data followed by a new worker, simultaneous creation/refetch, continuous CDC traffic, slow fetch completion, and SSE disconnect/reconnect with a large replay backlog.
  • [ ] Cover project navigation, persisted expanded state, collapse/expand, drag ordering with a previously unknown ID, and both normal/reduced motion. Assert the actual worker row is visible, not merely present in mapped data.
  • [ ] Cover working-to-idle updates; retain active completed-PR workers; continue excluding terminated workers and displaying orchestrators through the intended separate affordance.
  • [ ] Ensure successful refresh repairs stale data; surface refresh failures without presenting an unexplained empty project.

Verification performed: live read-only REST/health/SSE probes, captured-response predicate assertions, shipped JS inspection, current upstream source trace, and duplicate searches. No product code changes or product test suite run. The listed regression tests are proposed, not claimed passing.

Duplicate search and related work

Searched both open and closed issues/PRs with sidebar, missing sessions, disappearing sessions, cache, pagination, and SSE replay terms, including older sidebar title results. No exact current Go/Electron duplicate was identified.

  • Issue 1883, closed: same visible symptom in the old Next.js/TypeScript stack, with hanging API/process-local cache. Current port-3001 list responds quickly and includes the worker, so that old mechanism is not established here.
  • Issue 2834, closed: merged-PR disappearance/runtime cleanup. This worker is explicitly non-terminated and returned working/idle; not the reported merge flow.
  • PR 4329, merged: persisted expanded projects, relevant disclosure boundary.
  • PR 4719, merged: renderer interaction overhead, relevant surrounding work, not asserted as the regression origin.
  • PR 3831, open: CDC/refetch fan-out performance, related cache boundary, not assumed to fix this report.

harshitsinghbhandari avatar Sep 07 '26 07:09 harshitsinghbhandari

Reporter follow-up

After capturing the failure, Harshit fully closed and reopened the desktop app. hosted-ao-103 then appeared in the sidebar without any change to the session.

This rules out durable daemon state, project association, and the worker eligibility filters for the observed incident. Recreating the Electron renderer repaired the view, so stale renderer query/cache state or a missed refresh is now the leading boundary. It still does not distinguish a TanStack Query refresh failure from a downstream React/disclosure rendering failure because the affected window was gone before its cache and DOM could be inspected.

The confirmed restart workaround supports the existing P2 classification.

harshitsinghbhandari avatar Sep 07 '26 07:09 harshitsinghbhandari

@diyaavirmani — could you take this Mac-reproduced issue? GitHub currently won’t let me formally assign your account on this repo. I’m removing my assignment to flag this handoff request, but the issue will not list you as assignee unless repo access changes.

codebanditssss avatar Sep 24 '26 06:09 codebanditssss