Skip to content

fix(agent-status): keep Claude in-process teammates visible as idle sidebar rows - #9850

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-claude-subagent-visibility
Jul 22, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-claude-subagent-visibility

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On Claude Code 2.1.21x, named Agent-tool agents run as turn-based in-process teammates (taskKind: "in_process_teammate"): they work a mailbox turn, then emit SubagentStop + TeammateIdle and sit alive-but-parked until messaged again. Verified live on 2.1.217 with a hook-capture probe and against Orca's own agent-hooks/last-status.json:

  • SubagentStart → the child row appears with the expected teammate-shaped id (a<name>-<hex>) —
  • SubagentStop/TeammateIdle arrive ~20s later at the first turn boundary while the teammate's own background work is still running, and Orca deletes the row.

Orca's roster treated both events as finish signals (per #8825, correct for the 2.1.210-era semantics they were verified against). Result: teammate rows exist only during brief working bursts, which reads as "the sidebar never shows my subagents". The delivery pipeline itself was proven healthy end-to-end.

Fix (root cause: model the new lifecycle, don't patch the symptom)

The roster now tracks a working | 'idle' state per child instead of holding working children only:

  • One-shot children (hyphen-free ids): unchanged — SubagentStop is a true finish and removes the row.
  • Teammate-shaped rows park as idle on SubagentStop/TeammateIdle and revive to working on the next SubagentStart (same lifecycle id; first-observed startedAt preserved). The sidebar keeps showing them as idle child rows (renderer + wire already supported state: 'idle'; the dashboard already labels idle subagents "alive-but-idle").
  • Done-gate preserved (fix(agent-status): reap finished Claude named agents/teammates from the sidebar roster #8825): only working children gate the pane 'working'; idle teammates never pin a finished pane's spinner.
  • Idle-pile prevention (fix(agent-status): reap finished Claude named agents/teammates from the sidebar roster #8825's original symptom): named workflow lanes reuse the teammate id shape but genuinely finish on stop. Discriminator: real teammates always get a name-keyed TeammateIdle. Unconfirmed idle rows are reaped at the next complete lead-Stop background_tasks fold (or immediately on stop once a fold tagged the id listedAsSubagentTask), so finished lanes can't accumulate.
  • Cap safety: at the 32-row wire cap the oldest idle row is evicted to admit a working spawn; working children are never displaced.
  • Restart: hydrate keeps pruning idle snapshots — idle-teammate liveness can't be proven across a restart; a live teammate re-earns its row via SubagentStart.

Evidence behind the semantics

  • Interactive 2.1.217 probe with capture hooks: SubagentStart/SubagentStop/TeammateIdle all fire for in-process teammates; teammate background_tasks entries still read status: "running" permanently (so the fold still can't trust them per-agent — unchanged rules there).
  • Live end-to-end from an Orca pane: last-status.json showed the teammate row appear (state: "working") then get wiped by TeammateIdle mid-sleep 180 — the exact reported symptom.
  • The new lifecycle test replays the captured real event sequence (ids and ordering) from the reporting session.
  • Workflow-lane probe (2.1.217): Workflow tool lanes spawn as hyphen-free one-shot ids (agent_type: "workflow-subagent") with no TeammateIdle — they take the remove-on-stop path, so workflows cannot build an idle pile under this change. The confirmedTeammate fold guard remains as defense-in-depth for the 2.1.210-era teammate-shaped lane ids.

Behavior trade-off on older Claude CLIs

On ≤2.1.210, TeammateIdle meant "finished" and teammate background_tasks entries linger; finished named agents there will now show as idle rows for the rest of the session (honestly labeled, never gating done, cap-evictable, cleared on restart/new session/complete-inventory teardown). Current CLIs get the correct persistent-teammate view; the old-CLI regression risk is bounded clutter, not stuck panes.

Tests

  • claude-subagent-roster.test.ts: idle parking, workflow-lane removal via listedAsSubagentTask, revival keeping startedAt, confirmed-idle fold survival vs unconfirmed reap, oldest-idle cap eviction, TeammateIdle name-scoping now parking instead of deleting.
  • claude-subagent-row-lifecycle.test.ts: new turn-cycle scenario (work → idle → lead Stop → SendMessage revival) with live-captured ids; updated stop/fold expectations.
  • agent-hook-listener.test.ts: teammate stop/idle now emit idle snapshots; pane still settles done under idle-only rosters.
  • Full sweep: src/shared + src/main/agent-hooks + src/main/ipc/agent-hooks = 3183 passed. Typecheck green. Renderer sidebar/dashboard suites: only pre-existing failures unrelated to this change (fail identically on base commit ac909c8d83); same for the pre-existing skill-freshness-group.tsx switch-exhaustiveness lint error.

Live Electron QA: PASSED — dev app from this branch with a real claude CLI (2.1.217) spawning a real in-process teammate; full spawn → idle-persists → SendMessage-revival → idle-again cycle verified against the sidebar and last-status.json. Screenshots in the PR comment below.

…idebar rows

Claude Code 2.1.21x runs named Agent-tool agents as turn-based in-process
teammates: SubagentStop and TeammateIdle fire at every TURN end while the
teammate stays alive awaiting mail (verified live on 2.1.217). Treating
those events as finish signals deleted the child row seconds after each
burst, so the sidebar showed no subagents for most of a teammate's life.

Root-cause fix: the roster now tracks a working/idle state per child.

- One-shot children (hyphen-free ids) keep remove-on-stop: their
  SubagentStop is a true finish.
- Teammate-shaped rows park as idle on SubagentStop/TeammateIdle and
  revive to working via the next SubagentStart (same lifecycle id,
  first-observed startedAt preserved).
- Idle rows never gate the pane 'working' (#8825's done-gate rule).
- Only TeammateIdle-confirmed idle rows survive a complete lead-Stop
  fold; a stopped workflow lane wearing a teammate-shaped id is reaped
  there (or immediately, once a fold tagged it listedAsSubagentTask), so
  the pre-#8825 idle pile cannot rebuild.
- At the wire cap, the oldest idle row is evicted to admit a working
  spawn; working children are never displaced.
- Hydrate keeps pruning idle snapshots: idle-teammate liveness cannot be
  proven across a restart, and a live teammate re-earns its row.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Claude subagent roster entries now track explicit working or idle state and teammate confirmation. Teammate-shaped rows are parked on stop, can revive on a later start, persist when confirmed, and are reaped through background-task folding when unconfirmed. Listener handling and snapshot hydration were updated for the new state model, with tests covering lifecycle transitions, capacity, serialization, pane status, and name scoping.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description omits the required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Rewrite the PR description to follow the repository template and add the missing sections, including testing checklist, screenshots, review report, and security audit.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and accurately summarizes the main change: keeping Claude in-process teammates visible as idle sidebar rows.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b1e13d5c-f306-4c43-9c87-bdff2f8793cc

📥 Commits

Reviewing files that changed from the base of the PR and between 2a32c5c and df6ebf2.

📒 Files selected for processing (6)
  • src/main/agent-hooks/server.ts
  • src/shared/agent-hook-listener.test.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/claude-subagent-roster.test.ts
  • src/shared/claude-subagent-roster.ts
  • src/shared/claude-subagent-row-lifecycle.test.ts

Comment thread src/shared/claude-subagent-roster.ts Resolved
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Live Electron QA — real claude CLI, real in-process teammate ✅

Ran the dev app from this branch (pnpm dev, Claude Code CLI 2.1.217) and drove the real product path end-to-end: orca worktree create --agent claude → the lead Claude spawned a named teammate (qa-mate) via the Agent tool → verified each lifecycle phase against both the sidebar UI and the persisted agent-hooks/last-status.json ground truth.

1. Teammate finished its turn and went idle — the child row now persists (pre-fix it vanished at exactly this moment; the transcript on screen even narrates "Teammate @qa-mate finished … now idle and standing by"). Persisted payload: state: done, subagents: [{id: "aqa-mate-a6c9b3919d81d068", state: "idle"}] — idle row visible, pane not pinned working:

teammate idle row persists

2. SendMessage wake → same lifecycle id revives to working (card, lead row, and qa-mate child row all spinning; persisted payload flipped to subagents: [... state: "working"]):

teammate revived working

3. Second turn over → parked idle again, row still there a minute later (sidebar close-up):

sidebar crop idle

Full cycle observed live: spawn → working row → idle row persists → revival → idle again — with the done-gate behaving (pane resolves done while the idle teammate stays listed).

@brennanb2025
brennanb2025 merged commit c4d903f into main Jul 22, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…idebar rows (stablyai#9850)

* fix(agent-status): keep Claude in-process teammates visible as idle sidebar rows

Claude Code 2.1.21x runs named Agent-tool agents as turn-based in-process
teammates: SubagentStop and TeammateIdle fire at every TURN end while the
teammate stays alive awaiting mail (verified live on 2.1.217). Treating
those events as finish signals deleted the child row seconds after each
burst, so the sidebar showed no subagents for most of a teammate's life.

Root-cause fix: the roster now tracks a working/idle state per child.

- One-shot children (hyphen-free ids) keep remove-on-stop: their
  SubagentStop is a true finish.
- Teammate-shaped rows park as idle on SubagentStop/TeammateIdle and
  revive to working via the next SubagentStart (same lifecycle id,
  first-observed startedAt preserved).
- Idle rows never gate the pane 'working' (stablyai#8825's done-gate rule).
- Only TeammateIdle-confirmed idle rows survive a complete lead-Stop
  fold; a stopped workflow lane wearing a teammate-shaped id is reaped
  there (or immediately, once a fold tagged it listedAsSubagentTask), so
  the pre-stablyai#8825 idle pile cannot rebuild.
- At the wire cap, the oldest idle row is evicted to admit a working
  spawn; working children are never displaced.
- Hydrate keeps pruning idle snapshots: idle-teammate liveness cannot be
  proven across a restart, and a live teammate re-earns its row.

* fix(agent-status): restore inventory-confirmed workflow lanes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant