Repository navigation
Remove finished and killed claude subagents from the sidebar roster - #8522
Conversation
Finished one-shot subagents stayed in the pane roster as permanent idle rows (dozens per ultracode/workflow session), and a subagent killed without its SubagentStop hook stayed 'working' forever, pinning the pane working. SubagentStop now removes one-shot entries (teammates only idle: they are alive and resumable), and a lead Stop's present background_tasks list is treated as authoritative for non-teammates - unlisted entries are removed. Teammates are identified by their name-embedding agent ids (a<name>-<hex>, verified against live hook captures).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughClaude subagent roster handling now distinguishes teammates from one-shot subagents. Finished one-shots are removed, while teammates transition to idle and can persist through background-task omissions. Snapshot hydration re-derives teammate status, truncated inventories preserve live children, and lifecycle handling uses the new finalization helper. Tests cover roster reconciliation, teammate identity mapping, killed or interrupted subagents, and resulting sidebar payloads. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) 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 |
Workflow/named one-shot agents report name-embedding lifecycle ids (afinder-C-<hex>, agent_type = the label), indistinguishable by shape from resumable teammates - so the roster retained them as idle rows (observed live: a 32-row 12h-old pile). Unlike teammates they ARE listed id-exact as subagent-typed background tasks, including inside their own SubagentStop payload. Use that corroboration to remove them on stop, reclassify task-listed teammate-shaped entries as one-shots, and reap teammate-shaped leftovers when a complete inventory lists no teammate-typed task at all (a teams session always lists its teammates, even idle ones).
Addendum: named workflow lanes (second commit)A second real-world variant surfaced after the initial fix: a 12h-old pile of 32 idle rows ( That's the same id shape as resumable teams teammates ( Live hook captures show the reliable discriminator: one-shots (named or not) are listed id-exact as
Regression tests encode the exact observed shape. Existing stale piles clear at the first turn-end Stop after updating. Remaining edge: a killed named lane inside a session that also runs live teammates is retained until the teammates go away — acceptable and rare. |
…he sidebar roster (#8825) * fix(agent-status): reap finished Claude named agents/teammates from the sidebar roster #8522 stopped one-shot subagents from squatting as idle rows, but named background agents (Workflow/orchestration/ultracode lanes and agent-teams teammates) still piled up permanent "Idle - <type>" child rows for the rest of the session — the reported regression (11 idle rows under an "Orchestration Messages" pane, all idle 3-6h after finishing). Root cause, confirmed against live hook captures (claude 2.1.210): named agents get teammate-shaped ids (a<name>-<hex>) AND now appear in Stop's `background_tasks` as `type: "teammate"` entries whose status stays "running" forever — even after the agent finished. The old code read that shape as a "resumable teammate", so SubagentStop only marked it idle and the fold never reaped it (a present teammate task kept hasTeammateTypedTask true). The rows never left. Fix: the roster now tracks only WORKING children. - SubagentStop removes the child outright (teammate-shaped or not) — it is the reliable finish signal; the teammate task's "running" status is not. - TeammateIdle removes by name as the fallback when a SubagentStop is lost. - A lead Stop's background_tasks still reaps unlisted children: hyphen-free one-shots always, and teammate-shaped rows once a complete inventory shows no teammate-typed task at all. A live named agent whose id never appears is kept only while a teammate-typed task is still present (the done-gate). - Hydration drops persisted idle snapshots so a restart can't re-pile them. Verified live in a dev Electron instance driving a real Claude TUI that spawns four named background agents: pre-fix the pane resolves to done with four persistent "Idle - <probe>" rows; post-fix each row disappears the instant its agent finishes and the roster drains to empty (done, zero child rows). Tests: roster + row-lifecycle + hook-listener suites rewritten to the working-only semantics, grounded in the captured 2.1.210 hook stream (126 passing). Typecheck + oxlint clean. * fix(agent-status): prune persisted idle Claude children * fix(agent-status): persist Claude idle-row hydration cleanup * fix(agent-status): avoid ambiguous teammate idle cleanup * fix(agent-status): reconcile replacement children at roster cap
…tablyai#8522) * Remove finished and killed claude subagents from the sidebar roster Finished one-shot subagents stayed in the pane roster as permanent idle rows (dozens per ultracode/workflow session), and a subagent killed without its SubagentStop hook stayed 'working' forever, pinning the pane working. SubagentStop now removes one-shot entries (teammates only idle: they are alive and resumable), and a lead Stop's present background_tasks list is treated as authoritative for non-teammates - unlisted entries are removed. Teammates are identified by their name-embedding agent ids (a<name>-<hex>, verified against live hook captures). * Fix Claude subagent roster reconciliation * Drop named workflow lanes that share the teammate id shape Workflow/named one-shot agents report name-embedding lifecycle ids (afinder-C-<hex>, agent_type = the label), indistinguishable by shape from resumable teammates - so the roster retained them as idle rows (observed live: a 32-row 12h-old pile). Unlike teammates they ARE listed id-exact as subagent-typed background tasks, including inside their own SubagentStop payload. Use that corroboration to remove them on stop, reclassify task-listed teammate-shaped entries as one-shots, and reap teammate-shaped leftovers when a complete inventory lists no teammate-typed task at all (a teams session always lists its teammates, even idle ones).
…he sidebar roster (stablyai#8825) * fix(agent-status): reap finished Claude named agents/teammates from the sidebar roster stablyai#8522 stopped one-shot subagents from squatting as idle rows, but named background agents (Workflow/orchestration/ultracode lanes and agent-teams teammates) still piled up permanent "Idle - <type>" child rows for the rest of the session — the reported regression (11 idle rows under an "Orchestration Messages" pane, all idle 3-6h after finishing). Root cause, confirmed against live hook captures (claude 2.1.210): named agents get teammate-shaped ids (a<name>-<hex>) AND now appear in Stop's `background_tasks` as `type: "teammate"` entries whose status stays "running" forever — even after the agent finished. The old code read that shape as a "resumable teammate", so SubagentStop only marked it idle and the fold never reaped it (a present teammate task kept hasTeammateTypedTask true). The rows never left. Fix: the roster now tracks only WORKING children. - SubagentStop removes the child outright (teammate-shaped or not) — it is the reliable finish signal; the teammate task's "running" status is not. - TeammateIdle removes by name as the fallback when a SubagentStop is lost. - A lead Stop's background_tasks still reaps unlisted children: hyphen-free one-shots always, and teammate-shaped rows once a complete inventory shows no teammate-typed task at all. A live named agent whose id never appears is kept only while a teammate-typed task is still present (the done-gate). - Hydration drops persisted idle snapshots so a restart can't re-pile them. Verified live in a dev Electron instance driving a real Claude TUI that spawns four named background agents: pre-fix the pane resolves to done with four persistent "Idle - <probe>" rows; post-fix each row disappears the instant its agent finishes and the roster drains to empty (done, zero child rows). Tests: roster + row-lifecycle + hook-listener suites rewritten to the working-only semantics, grounded in the captured 2.1.210 hook stream (126 passing). Typecheck + oxlint clean. * fix(agent-status): prune persisted idle Claude children * fix(agent-status): persist Claude idle-row hydration cleanup * fix(agent-status): avoid ambiguous teammate idle cleanup * fix(agent-status): reconcile replacement children at roster cap


Fixes the two reported Claude subagent sidebar symptoms: finished workflow/ultracode subagents piling up as permanent
Idle - general-purposechild rows, and killed subagents that never disappear (and pin the paneworkingforever).Root cause
Roster entries had no exit path while a session stayed busy.
SubagentStoponly marked an entry idle, and the only cleanup was a leadStopwith a fully emptybackground_tasks— exactly what ultracode (live workflow tasks) and teams sessions (teammates always listed) never send. A child killed without itsSubagentStop(interrupt race, lost hook, SIGKILL'd tree) additionally stayedworkingforever, which both pinned the paneworkingvia the done-gate and blocked the server's interrupt inference.Fix (grounded in live hook captures from claude CLI)
Empirical ground truth captured with logging hooks: one-shot Task agent ids are
a+16-hex (no hyphen) while teammate ids embed their name (a<name>-<hex>withagent_type= name);SubagentStopalso fires for interrupt-aborted children; a leadStop'sbackground_taskslists running subagents id-exact and drops finished tasks entirely.SubagentStopnow removes one-shot entries. Teammates (identified by the name-embedding id) only go idle — they're alive and resumable, andSubagentStopfires per finished task for them.background_taskslist as authoritative for non-teammates: id-matched not-running entries and unlisted entries are removed (this reaps killed children whoseSubagentStopwas lost). Teammates are exempt (their task ids never match lifecycle ids); snapshot-seeded teammate phantoms still demote to idle so they can't gate the pane.Verification
Reproduced live in a dev instance (real claude session in an Orca terminal + a deterministic replay of the exact ultracode/teams hook traffic against the dev hook server), then re-ran the identical traffic on the fixed build.
Working, no SubagentStop) + 6 squatters + teammateworkingAn organic re-run (real claude spawning 6 subagents in batches) showed idle-row count staying 0 for the whole session (pre-fix it climbed with every finished batch), resolving to
donecleanly.Tests: roster + listener suites updated to the new semantics plus a regression spec (
claude-subagent-row-lifecycle.test.ts);src/shared(2363),src/main/agent-hooks+src/relay(1131) all green; typecheck + oxlint clean. The 10 sidebar/dashboard renderer test failures are pre-existing on main (fail with this diff stashed; Linear-toast/board-hint files, unrelated).Known residual gaps (follow-ups, out of scope)
clearPaneState(stillOwnsPaneKey === false— remount/SSH-reattach races) or a dead pane rehydrated with its tab restored can still render frozen child rows until eviction (src/main/ipc/pty.ts:1168,server.ts:1603).pty-connection.ts:2981); with this fix its last snapshot at least no longer contains finished-agent squatters.background_taskskeep the previous conservative behavior (no reaping by omission).