Repository navigation
fix(agent-status): keep Claude in-process teammates visible as idle sidebar rows - #9850
Conversation
…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.
📝 WalkthroughWalkthroughClaude subagent roster entries now track explicit 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b1e13d5c-f306-4c43-9c87-bdff2f8793cc
📒 Files selected for processing (6)
src/main/agent-hooks/server.tssrc/shared/agent-hook-listener.test.tssrc/shared/agent-hook-listener.tssrc/shared/claude-subagent-roster.test.tssrc/shared/claude-subagent-roster.tssrc/shared/claude-subagent-row-lifecycle.test.ts
Live Electron QA — real
|
…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



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 emitSubagentStop+TeammateIdleand sit alive-but-parked until messaged again. Verified live on 2.1.217 with a hook-capture probe and against Orca's ownagent-hooks/last-status.json:SubagentStart→ the child row appears with the expected teammate-shaped id (a<name>-<hex>) —SubagentStop/TeammateIdlearrive ~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:SubagentStopis a true finish and removes the row.SubagentStop/TeammateIdleand revive to working on the nextSubagentStart(same lifecycle id; first-observedstartedAtpreserved). The sidebar keeps showing them as idle child rows (renderer + wire already supportedstate: 'idle'; the dashboard already labels idle subagents "alive-but-idle").TeammateIdle. Unconfirmed idle rows are reaped at the next complete lead-Stopbackground_tasksfold (or immediately on stop once a fold tagged the idlistedAsSubagentTask), so finished lanes can't accumulate.SubagentStart.Evidence behind the semantics
SubagentStart/SubagentStop/TeammateIdleall fire for in-process teammates; teammatebackground_tasksentries still readstatus: "running"permanently (so the fold still can't trust them per-agent — unchanged rules there).last-status.jsonshowed the teammate row appear (state: "working") then get wiped byTeammateIdlemid-sleep 180— the exact reported symptom.Workflowtool lanes spawn as hyphen-free one-shot ids (agent_type: "workflow-subagent") with noTeammateIdle— they take the remove-on-stop path, so workflows cannot build an idle pile under this change. TheconfirmedTeammatefold 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,
TeammateIdlemeant "finished" and teammatebackground_tasksentries 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 vialistedAsSubagentTask, revival keepingstartedAt, 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.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 commitac909c8d83); same for the pre-existingskill-freshness-group.tsxswitch-exhaustiveness lint error.Live Electron QA: PASSED — dev app from this branch with a real
claudeCLI (2.1.217) spawning a real in-process teammate; full spawn → idle-persists → SendMessage-revival → idle-again cycle verified against the sidebar andlast-status.json. Screenshots in the PR comment below.