Repository navigation
fix(agent-status): leftover Claude shells must not hold a finished lead at working (STA-4119) - #15189
brennanb2025 wants to merge 8 commits into
Conversation
…d lead at working A lead Stop with a still-running background shell published working, and a later start-less SubagentStop re-emitted that latch forever because an idle parent never sends another inventory. Leftover non-agent inventory no longer participates in pane state; live child agents and session crons still gate working. STA-4119
STA-4119 reproduction evidenceMoved out of the repo root so the root-directory guard passes — evidence belongs on the PR, not in the tree. Content is unchanged. STA-4119-REPRO.md — full reproduction record (macOS + Windows, with control arm)STA-4119 reproductionVerdict: reproduced on both macOS and Windows. The reported mechanism is real and is not a Windows-only artifact. It is also not the phantom-working bug fixed by #14375 / #15082. The pane stays Builds
This lane did not cherry-pick anything. The macOS run is the "still broken after the two merged status PRs" result. The Windows run is the original-platform result on the shipped 1.4.184 the reporter's era used. Exact steps (what I actually ran)Throwaway fixture, not the orca repo (no setup hooks, no sibling-worktree discovery):
Control (same macOS adhoc build, no background work): worktree What I observedBoth platforms (the reported bug)After the lead printed
Re-check at 16:37:44 local, ~5 minutes after the macOS Windows extra: Claude printed macOS 1.4.185-adhoc (has #14375 / #15082 / #14580)
{
"hookEventName": "SubagentStop",
"toolAgentId": "ac4a0c329a0e18cd9",
"payload": {
"state": "working",
"lastAssistantMessage": "STA-4119-TURN-DONE",
"toolName": "Bash",
"turnCompletedAt": 1787009576866
},
"receivedAt": 1787009578408,
"stateStartedAt": 1787009567895
}
Windows 1.4.184 (original platform, pre-#14580)
This is the reporter's evidence, reproduced on the reported OS, on 1.4.184. Control (macOS adhoc, no background shell){
"hookEventName": "Stop",
"payload": {
"state": "done",
"lastAssistantMessage": "STA-4119-CONTROL-DONE"
}
}Card Did the completion notification fire?
#14580 ( Mechanism (checked against this tree, not the handoff line numbers)
A later start-less This is not the #14375 phantom: the gate has positive evidence (Claude's own "1 shell still running", a STA-4612 subsumption verdict: does not subsume this caseSTA-4612 proposes a hooks-independent backstop that is either:
so a dead pane cannot stay Here the pane is alive. Claude is at an idle prompt. STA-4612's write-up also lists "background-task gate never refreshed" for the other failure: a background task ends while the parent stays idle, so the inventory is stale and nothing clears the gate. That is a sibling, not this ticket. This ticket's reporter case is "the shell is still running, the turn is over, stop looking like foreground work / fire the finish notification." PTY liveness does not distinguish those. A TUI-idle → Post-fix (this worktree)Plan: The reporter sequence is now a unit test ( 147 related tests pass ( Live UI re-run against this commit is not possible in the currently running desktop ( What is left
Evidence files
sta-4119-macos-last-status-entry.json — captured macOS last-status entry{
"capturedAtLocal": "2026-08-17T16:37:44-07:00",
"localAppVersion": "1.4.185-adhoc.20260817215434",
"sourceWorktreeHead": "8cd338357ee35e7348cb08d3a0522fee161b2e28",
"reproPane": {
"paneKey": "b1a746f4-93d0-483a-9b56-841d3d38b3c5:45175c2f-d16d-4ff4-bc95-809fed804872",
"source": "claude",
"tabId": "b1a746f4-93d0-483a-9b56-841d3d38b3c5",
"worktreeId": "a2200db1-ead2-44b2-98ef-305f17644241::/Users/brennanbenson/orca/workspaces/sta-4119-bg-fixture/sta-4119-repro-macos",
"connectionId": null,
"hasExplicitPrompt": false,
"hookEventName": "SubagentStop",
"providerPromptId": "cd77def5-25b9-40b3-a721-b4a66b6c8004",
"toolAgentId": "ac4a0c329a0e18cd9",
"providerSession": {
"key": "session_id",
"id": "4598b6d9-e09d-4a1c-896a-df301d180f44",
"transcriptPath": "/Users/brennanbenson/.claude/projects/-Users-brennanbenson-orca-workspaces-sta-4119-bg-fixture-sta-4119-repro-macos/4598b6d9-e09d-4a1c-896a-df301d180f44.jsonl"
},
"payload": {
"state": "working",
"prompt": "Do exactly these steps, then end your turn. Do not start a subagent. Do not ask questions. 1. Start this long-lived process as a background/async Bash shell and do NOT wait for it to exit: python3 ",
"agentType": "claude",
"toolName": "Bash",
"toolInput": "cat /private/tmp/claude-501/-Users-brennanbenson-orca-workspaces-sta-4119-bg-fixture-sta-4119-repro-macos/4598b6d9-e09d-4a1c-896a-df301d180f44/tasks/b0icpu59e.o",
"lastAssistantMessage": "STA-4119-TURN-DONE",
"turnCompletedAt": 1787009576866
},
"receivedAt": 1787009578408,
"stateStartedAt": 1787009567895,
"launchTokenHash": "dee6f186298eb5a60bb0a854ae0a6ced88cebfa4dc3988bd5dc48d84cce6896c"
},
"controlPane": {
"paneKey": "032f97d0-4e98-4833-a2c9-b360e1ecd162:92bc0766-7177-4cd6-89dd-a45130e36e70",
"source": "claude",
"tabId": "032f97d0-4e98-4833-a2c9-b360e1ecd162",
"worktreeId": "a2200db1-ead2-44b2-98ef-305f17644241::/Users/brennanbenson/orca/workspaces/sta-4119-bg-fixture/sta-4119-control-macos",
"connectionId": null,
"hasExplicitPrompt": false,
"hookEventName": "Stop",
"providerPromptId": "982d1b47-9d7b-47d0-bfb3-ccfb217e850d",
"providerSession": {
"key": "session_id",
"id": "e8ddb7ac-d5ec-424f-bead-4b76ff64ce16",
"transcriptPath": "/Users/brennanbenson/.claude/projects/-Users-brennanbenson-orca-workspaces-sta-4119-bg-fixture-sta-4119-control-macos/e8ddb7ac-d5ec-424f-bead-4b76ff64ce16.jsonl"
},
"payload": {
"state": "done",
"prompt": "Reply with exactly STA-4119-CONTROL-DONE and end your turn. Do not run any shell command. Do not start a background process. Do not start a subagent.",
"agentType": "claude",
"lastAssistantMessage": "STA-4119-CONTROL-DONE"
},
"receivedAt": 1787009672621,
"stateStartedAt": 1787009672621,
"launchTokenHash": "e3a4bc871a4a496087b8f220b65468476673ab9a7d297e9b7da4f5c4a7d5956f"
}
}sta-4119-windows-last-status-fields.json — captured Windows last-status fields{
"capturedAtLocal": "2026-08-17T16:38:30-07:00",
"windowsEnvironment": "Windows high spec",
"windowsAppVersion": "1.4.184",
"windowsRuntimeId": "70a74ef9-bd02-4f76-b08b-846e230d2dc5",
"lastStatusPath": "C:\\Users\\neil\\AppData\\Roaming\\orca\\agent-hooks\\last-status.json",
"paneKey": "0eefb1da-3af1-40cb-ab8c-309eea05e5cb:d96df5f8-1870-42e2-b11b-a50bbc6c6985",
"hookEventName": "SubagentStop",
"state": "working",
"turnCompletedAt": null,
"lastAssistantMessage": "STA-4119-TURN-DONE",
"toolName": "Read",
"toolAgentId": "a0dc6d9fd3ea4d8be",
"receivedAt": 1787009583714,
"stateStartedAt": 1787009565488,
"payloadKeys": ["state", "prompt", "agentType", "toolName", "toolInput", "lastAssistantMessage"],
"subagents": null,
"note": "Fields extracted on the Windows host from last-status.json. Full entry also written on that host as C:/Users/neil/orca/workspaces/orca-setup-shell-repro/sta-4119-repro-win/sta-4119-win-last-status.json"
} |
The reproduction record, the plan, and the two captured last-status payloads were committed at the repo root, which the root-directory guard rejects. Evidence belongs on the PR; the content is preserved verbatim in a PR comment.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughClaude background-task parsing now separates recognized shell work from unclassified work. Listener and server lifecycle logic uses unclassified work and session crons for state gating, while recognized shell work no longer keeps completed panes working. Tri-state provider background-work evidence crosses local, remote, relay, SSH, IPC, and renderer status paths. Persisted entries omit runtime markers. Completed panes with active or unobserved provider work are excluded from hibernation. Tests cover classification, lifecycle states, interrupt inference, persistence, notifications, status propagation, and hibernation. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 3
🧹 Nitpick comments (1)
STA-4119-PLAN.md (1)
47-60: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover
StopFailurein the regression matrix.The decision applies to
StopandStopFailureon Line 5, but the listed STA-4119 sequence covers onlyStopon Lines 49-57. Add a shell-onlyStopFailurecase, or identify an existing test that verifies the samedoneand notification behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 53e41eea-843c-4dc6-909f-4ba17cffb9c2
📒 Files selected for processing (10)
STA-4119-PLAN.mdSTA-4119-REPRO.mdsrc/main/agent-hooks/server-last-status-write.test.tssrc/relay/agent-hook-server.test.tssrc/renderer/src/hooks/agent-hook-completion-background-turn-notifications.test.tssrc/shared/agent-hook-listener-claude-subagents.test.tssrc/shared/agent-hook-listener.tssrc/shared/claude-background-task-status.test.tssta-4119-macos-last-status-entry.jsonsta-4119-windows-last-status-fields.json
Included review availability: Your plan includes up to 10 reviews per rolling hour; 4 remain after this review.
… a finished lead STA-4119's first pass dropped the whole background-inventory disjunct, which also retired panes whose running entry Orca could not classify — a `type: "agent"` row, a future type, a blank or malformed entry. readClaudeBackgroundAgentTasks documents that those must fail active, and that gate was its only enforcement. Split the signal instead. A positively identified shell (`shell`, `background_shell`) stops gating pane state; everything else stays unclassified and still holds the lead at working. Live child agents and session crons are unchanged. The broad "provider still owns live background work" signal is kept and now reaches the renderer, because a pane that can finally reach done also became eligible for agent hibernation — which kills the PTY, and the user's dev server with it. Interrupt inference now keys off the unclassified signal too: the shell set survives into the next turn, so keeping it there only blocked inference on a real turn the user had just cancelled. STA-4119
Live validation evidence — STA-4119 revisionIsolated dev instance built from this branch (temp 1. Lead turn ends with a 2. Control — a live typed subagent still holds Working. 3. The fix — a running 4. The same shell reported Hibernation plumbing, observed end to endWith the shell alive, the renderer's own status entry for the pane read: Idle to the user, off-limits to the hibernation planner. After the shell reported Original STA-4119 reproduction record (pre-fix, both platforms)Preserved from the earlier evidence comment: TUI idle at the prompt showing |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/shared/claude-background-task-inventory.ts (1)
105-107: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winKeep malformed running agent rows fail-active.
A running
subagentorteammateentry withoutidis malformed. This branch only setstruncated. It does not sethasRunningUnclassifiedTask.The listener then has no roster row and no unclassified gate. A later
Stopcan publishdonewhile the provider task is still running.Set
hasRunningUnclassifiedTaskwhen the malformed typed agent row is nonterminal. Add a regression case for a runningsubagentwithoutid.Proposed fix
if (typeof obj.id !== 'string' || obj.id.trim().length === 0) { truncated = true + hasRunningUnclassifiedTask ||= !isTerminal continue }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 61dc0aa3-6d2b-4838-b9f5-f621e5ce0d7c
📒 Files selected for processing (19)
src/main/agent-hooks/server-interrupt-inference-guards.test.tssrc/main/agent-hooks/server-last-status-write.test.tssrc/main/agent-hooks/server.tssrc/main/index.tssrc/main/ssh/ssh-relay-session.tssrc/relay/agent-hook-envelope-build.tssrc/relay/agent-hook-server.test.tssrc/renderer/src/hooks/ipc-events-agent-status-store-test-fixtures.tssrc/renderer/src/hooks/useIpcEvents-agent-status-turn-completion.test.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/lib/agent-hibernation-planner.test.tssrc/renderer/src/lib/agent-hibernation-planner.tssrc/renderer/src/store/slices/agent-status.test.tssrc/renderer/src/store/slices/agent-status.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-relay.tssrc/shared/agent-status-types.tssrc/shared/claude-background-task-inventory.tssrc/shared/claude-background-task-status.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/agent-hooks/server-last-status-write.test.ts
- src/relay/agent-hook-server.test.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review.
… replay (STA-4119) The hibernation guard added here was inert on the snapshot/replay path, so a pane with a live background shell could still be torn down — no app restart required. `providerBackgroundWorkActive` was only ever assigned on the live push (main/index.ts). `agentStatus:getSnapshot` builds its rows through `toAgentStatusIpcPayload`, which never carried the field, and the renderer feeds those rows through the same accepted-write path — where the write-through does not merely fail to set the value, it overwrites a live `true` with `undefined`. The renderer pulls that snapshot after workspace hydration, so an ordinary reload was enough to disarm the guard and let the planner select the pane. Restore the invariant `agentStatus:getSnapshot` already claims in its own comment — "Match the live push enrichment in main/index.ts so parent/child rows survive replay" — by resolving the evidence once, in the hook server, and stamping it on every emitted and snapshotted row. Make the signal tri-state while doing it, because a boolean cannot distinguish "nothing is running" from "the provider has not told us". A restarted listener starts with an empty inventory, and reading that as "nothing is running" is permission to destroy the PTY. The planner now requires a positively-observed `false`; live work and never-observed both hold the pane. Providers that report no inventory at all are unaffected, so this does not disable hibernation for them. The renderer forwarder now carries `false` as well as `true`: `false` is the only value that makes a pane eligible, so dropping it would silently disable hibernation rather than kill a dev server. Both directions are pinned.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/agent-hooks/server-status-snapshot-background-work.test.ts (1)
27-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the explanatory comments.
Keep only the non-obvious rationale in one concise line.
src/main/agent-hooks/server-status-snapshot-background-work.test.ts#L27-L30: Reduce the snapshot-path rationale to one line.src/renderer/src/hooks/useIpcEvents-agent-status-turn-completion.test.ts#L164-L167: Reduce the tri-state forwarding rationale to one line.src/renderer/src/lib/agent-pane-provider-background-work.ts#L3-L15: Replace the multi-line provider and tri-state explanations with concise contract comments.src/renderer/src/lib/agent-hibernation-snapshot-replay-guard.test.ts#L63-L66: Reduce the replay rationale to one line.src/renderer/src/lib/agent-hibernation-snapshot-replay-guard.test.ts#L90-L91: Reduce the fail-safe rationale to one line.src/renderer/src/lib/agent-hibernation-coordinator.test.ts#L75-L76: Reduce the fixture rationale to one line.As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 770e21a0-caf8-4f48-98c3-1f28d2c19610
📒 Files selected for processing (13)
src/main/agent-hooks/server-status-snapshot-background-work.test.tssrc/main/agent-hooks/server.tssrc/main/index.tssrc/renderer/src/hooks/useIpcEvents-agent-status-turn-completion.test.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/lib/agent-hibernation-coordinator.test.tssrc/renderer/src/lib/agent-hibernation-planner.test.tssrc/renderer/src/lib/agent-hibernation-planner.tssrc/renderer/src/lib/agent-hibernation-snapshot-replay-guard.test.tssrc/renderer/src/lib/agent-pane-provider-background-work.tssrc/renderer/src/store/slices/agent-status.test.tssrc/renderer/src/store/slices/agent-status.tssrc/shared/agent-hook-listener.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- src/renderer/src/store/slices/agent-status.test.ts
- src/renderer/src/hooks/useIpcEvents.ts
- src/renderer/src/lib/agent-hibernation-planner.ts
- src/renderer/src/lib/agent-hibernation-planner.test.ts
- src/main/index.ts
- src/renderer/src/store/slices/agent-status.ts
- src/shared/agent-hook-listener.ts
- src/main/agent-hooks/server.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review.
…2025/sta-4119-repro # Conflicts: # src/main/agent-hooks/server.ts # src/main/index.ts # src/renderer/src/hooks/useIpcEvents.ts # src/renderer/src/store/slices/agent-status.ts # src/shared/agent-status-types.ts
… (STA-4119) Independent review of the snapshot/replay fix found four ways the tri-state could report a positive "no background work" from evidence nobody reported, or stay "never observed" forever. All four are the same failure in different places: the new per-runtime observation marker was not kept in step with the inventory sets it qualifies. - Interrupt: clearing the inventory sets means "stop gating the pane", not "the provider reported an all-clear". The marker survived, so the resolver saw "observed, nothing running" and emitted a positive false over a process that may still be live. Interrupts now drop the marker in all three paths. - Session cron: a scheduled cron is provider-owned work under the same PTY, but the resolver consulted only the background-shell set and a cron-only inventory never set the marker. Such a pane was unknown forever, or reported a false all-clear from stale state. Cron now both counts as an observation and resolves as work. - Remote/relay: a host reports the inventory as a wire boolean, but the receiving runtime never recorded that an observation happened, so every remote pane resolved to unknown and a relayed all-clear could never make one eligible. - Local-hook rollback: the save/restore dance that protects against nested or rejected payloads tracked three fields and not the marker, so a discarded payload could leave the pane marked observed with the sets rolled back. Each is pinned by a test whose corresponding production revert makes it red.
Note for reviewers: 5 unrelated files in this diff are formatter-only churnMerging current
Every change in them is line-wrapping only — no logic, no behavior. Verified two ways: the diff against the merge base contains no non-formatting lines, and So this is the repo's own formatter converging files that were committed out of format, not a revert of anyone's work — I checked specifically for the failure mode where a merge silently drops Review these files by skipping them. |
The 5 red
|
The 2 red e2e jobs are a CI relay-build problem, not this PREvery failure across both jobs is the same line, thrown at The job log says why, earlier in the same run: The relay build was skipped because a bundle was already present, but that bundle carries no Attribution: this branch changes no e2e spec, and its only Filed separately as a CI issue. Not patching it from a status-semantics branch. |
Conflicts were confined to CliSkillRuntimeSetup and its test, where this branch had only incidental oxfmt line-wrapping picked up by the pre-commit hook during an earlier merge — no logic of ours. Took main's version of both, which also drops that unrelated churn from the PR.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 424a8d42-a231-4c7c-85e8-a67df6cd6bed
📒 Files selected for processing (26)
src/main/agent-hooks/server-hook-http-ingest.test.tssrc/main/agent-hooks/server-interrupt-inference-guards.test.tssrc/main/agent-hooks/server-last-status-write.test.tssrc/main/agent-hooks/server-status-snapshot-background-work.test.tssrc/main/agent-hooks/server.tssrc/main/index.tssrc/main/ssh/ssh-relay-session.tssrc/relay/agent-hook-envelope-build.tssrc/relay/agent-hook-server.test.tssrc/renderer/src/hooks/agent-hook-completion-background-turn-notifications.test.tssrc/renderer/src/hooks/ipc-events-agent-status-store-test-fixtures.tssrc/renderer/src/hooks/useIpcEvents-agent-status-turn-completion.test.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/lib/agent-hibernation-coordinator.test.tssrc/renderer/src/lib/agent-hibernation-planner.test.tssrc/renderer/src/lib/agent-hibernation-planner.tssrc/renderer/src/lib/agent-hibernation-snapshot-replay-guard.test.tssrc/renderer/src/lib/agent-pane-provider-background-work.tssrc/renderer/src/store/slices/agent-status.test.tssrc/renderer/src/store/slices/agent-status.tssrc/shared/agent-hook-listener-claude-subagents.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-relay.tssrc/shared/agent-status-types.tssrc/shared/claude-background-task-inventory.tssrc/shared/claude-background-task-status.test.ts
🚧 Files skipped from review as they are similar to previous changes (23)
- src/renderer/src/hooks/agent-hook-completion-background-turn-notifications.test.ts
- src/renderer/src/lib/agent-hibernation-planner.ts
- src/renderer/src/hooks/ipc-events-agent-status-store-test-fixtures.ts
- src/main/agent-hooks/server-last-status-write.test.ts
- src/renderer/src/lib/agent-pane-provider-background-work.ts
- src/renderer/src/store/slices/agent-status.test.ts
- src/shared/agent-hook-listener-claude-subagents.test.ts
- src/renderer/src/lib/agent-hibernation-coordinator.test.ts
- src/relay/agent-hook-envelope-build.ts
- src/main/agent-hooks/server-interrupt-inference-guards.test.ts
- src/main/ssh/ssh-relay-session.ts
- src/shared/agent-hook-relay.ts
- src/renderer/src/store/slices/agent-status.ts
- src/renderer/src/hooks/useIpcEvents-agent-status-turn-completion.test.ts
- src/main/index.ts
- src/renderer/src/lib/agent-hibernation-snapshot-replay-guard.test.ts
- src/shared/agent-status-types.ts
- src/shared/claude-background-task-inventory.ts
- src/renderer/src/hooks/useIpcEvents.ts
- src/relay/agent-hook-server.test.ts
- src/shared/agent-hook-listener.ts
- src/shared/claude-background-task-status.test.ts
- src/main/agent-hooks/server.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| const unknown = entry() | ||
| expect( | ||
| plannedWorktrees(snapshot({ agentStatusByPaneKey: { [unknown.paneKey]: unknown } })) | ||
| ).toEqual(['wt-bg']) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Correct the unobserved-work test case.
entry() now sets providerBackgroundWorkActive to false on Line 56. unknown is therefore an explicit all-clear state. This assertion repeats the settled case. Pass undefined and expect no candidate, or remove this block because the nested tri-state test already covers it.
|
Closing. This reverts a merged fix, and that is disqualifying regardless of the rest of the work. What it got wrong. #11838 (fix(agent-status): preserve Claude background work, merged 2026-08-02) deliberately made Orca hold This PR settles that same pane to Three independent lanes read the gate as a bug and none caught this, because Why the framing was wrong, not just the direction. STA-4119 and #11838 are the same observation from opposite sides: What supersedes it: #14205 (feat(agents): distinguish Claude background monitoring), which adds an optional Not lost. Two findings from this PR's review stand on their own and are already filed:
Also recorded, for whoever revisits this area: Branch left in place. STA-4119 stays open and re-homed onto #14205. |




ELI5
When Claude finishes a turn but leaves a background shell running — a dev server, a
sleep, a monitor — Orca kept the worktree card and tab spinning as if Claude were still thinking. The TUI was already idle. This PR treats a recognised leftover shell as session inventory rather than an active lead turn, so the card goes idle when the turn ends.The word "recognised" is load-bearing. Anything Orca cannot positively identify as a plain background shell — a live child agent, a task type Orca has never seen, a malformed entry — still holds the pane at
working. Silently retiring live agent work is a worse failure than a spinner.The contract
workingsubagent/teammate)workingworkingtype: "agent", an unknown type, a blank/absent type, a malformed entryworking(fail active)shell,background_shell)done+ completion notificationdone+ completion notificationreadClaudeBackgroundAgentTasksalready documented that unclassifiable inventory must fail active.resolveClaudePaneStatewas that rule's only end-to-end enforcement, so the signal is now split rather than dropped:hasRunningNonAgentTask— unchanged meaning. Any running non-agent entry, recognised shells included. It no longer gates pane state; it is the "provider still owns live work under this PTY" signal.hasRunningUnclassifiedTask— new, narrower. Only the entries we could not prove are shells. This is what gatesdone → working.The shell whitelist is deliberately a whitelist: a future Claude type is unclassified until Orca is taught about it.
Hibernation
A pane that can finally reach
donealso became eligible for agent hibernation, and hibernation tears down the PTY — which would kill the very dev server this PR just declared "still running".doneanswers is the agent idle, not is this pane safe to tear down; this change is exactly what pulled those two questions apart, so the planner now consults live background work directly.AgentStatusEntry.providerBackgroundWorkActivecarries the broad signal to the renderer and disqualifies the pane ingetEligiblePane. It is live-only and written through on every accepted status, so a pane that goes quiet becomes eligible again. This is fixed here rather than deferred: the reachability is created by this PR, andexperimentalAgentHibernationlowers the blast radius without making a silent dev-server kill acceptable.Interrupt inference
inferInterrupt's Claude guard keyed off the broad shell set. That set survives into the next turn (it is only rewritten whenbackground_tasksis present, andUserPromptSubmitcarries none), and after this change a recognised shell can no longer hold an idle pane atworking— so the guard's only reachable effect was to block inference on a genuinely active turn the user had just cancelled. It now keys off the unclassified signal, which is the only inventory that can still hold an idle pane atworking.Notification timing (behavior change)
These turns previously announced immediately off
turnCompletedAt, because the pane stayedworkingpast the lead boundary. They now take the ordinarydonepath and announce on the standard 1.5 sHOOK_DONE_QUIET_MSquiet window, like every other completed turn. Banner count and content are unchanged; only the timing moves, and it moves onto the common path rather than off it. Called out explicitly because it is a user-facing timing change with no other signpost.Wire compatibility
Per
docs/reference/remote-wire-compatibility.md. The relay computespayload.stateon the host (RelayAgentHookServerruns the samenormalizeHookPayload) and the client forwards it verbatim throughingestRemote, so this is a Rule 3 change — what the host publishes moves, with no codec change. The cross-version harness covers the terminal stream only, not agent-session publications or the relay transport, so this is the reasoning it asks for.Rule 1 — new optional envelope field.
claudeUnclassifiedBackgroundTaskis added alongsideclaudeRunningNonAgentTask. Decoders ignore unknown keys, and no reader requires it.Rule 3 — changed published content. For a pane whose only background work is a recognised shell, a fixed host now publishes
state: "done"where it publishedworking, and stops stampingturnCompletedAtfor that turn.claudeRunningNonAgentTaskkeeps its exact previous meaning, so the field an old client already reads did not move under it.donenormally — that is the fix arriving early, and it is the intended user-visible state. The old client cannot read the new field, so its interrupt guard falls back to the broad field, i.e. today's behavior. It also has noproviderBackgroundWorkActive, so its hibernation planner would treat the pane as eligible;experimentalAgentHibernationis opt-in, and the client gains the guard as soon as it updates. Called out rather than gated because gating a status value behind a capability would leave the reported bug unfixed on every mixed pair.workingfor a leftover shell, so remote panes keep the old behavior until the relay updates — no break, just no fix yet. The old host omits the new field, andingestRemotefalls back toclaudeRunningNonAgentTask, which is precisely how that host gated pane state. Covered by a test.Remote / SSH / Windows parity. All classification lives in
src/shared, with noprocess.platform, path, orconnectionIdbranch, so local, WSL, and SSH panes run identical code — the relay just runs it on the host. STA-4119 was filed from a Windows client and reproduces on macOS; the fix is platform-independent.Why
The leftover-shell set is only refreshed from
background_taskson a lead turn boundary. An idle parent never emits another list, so the pane stayedworkingindefinitely. That is STA-4119. Reproduced on macOS 1.4.185-adhoc (contains #14375 / #15082 / #14580) and Windows 1.4.184. A control turn with no background shell already wentStop/done.A PTY-liveness join would not have fixed this: the pane is still alive. That class of recovery stays on STA-4612.
Linked Issue
Fixes STA-4119
Testing
Live validation against an isolated dev instance built from this branch (temp
ORCA_DEV_USER_DATA_PATH, throwaway single-commit git repo, Playwright CDP only, torn down after). RealPOST /hook/clauderequests in the shape~/.orca/agent-hooks/claude-hook.shsends:Stopwith a livetype: "shell"source: agent-task-complete)SubagentStart+Stopwith the child still listedStopwith a runningtype: "agent"entrystate: "done"withproviderBackgroundWorkActive: true— idle to the user, off-limits to hibernationcompletedEvery fix has a test that goes red without it, checked by reverting only the production file:
type: "agent", unknown type,monitor, blank type, absent type, malformed entry, and the recognised-shell counterpart) — 11 red at the previous head.expected [ 'wt-bg' ] to deeply equal [], i.e. the pane really was a candidate.Mutation-tested so the assertions cannot pass for the wrong reason: making unclassified work stop gating turns 7 red; whitelisting every non-agent type turns 5 red; dropping the subagent-roster gate turns 16 red.
The
finds pending monitor work after the visible child-row capcase was passing via the 25 folded child rows rather than the monitor, so it now asserts the monitor alone. The local-HTTP interrupt-guard case was short-circuiting onstate !== 'working'after this change, so it now uses unclassifiable work to keep the paneworkingand actually exercise the guard.Suites: agent-hooks / agent-hook / agent-status / claude-subagent-roster / claude — 114 files, 1171 passed, 7 skipped (baseline 1169 + 2 new). Store slice / sidebar / smart-attention / hibernation / running-agent-targets / tab activity / hook projection — 31 files, 464 passed (baseline 462 + 2 new). Both also green rebased onto current
main, which has since touchedserver.ts,agent-hook-listener.ts, andmain/index.ts.pnpm typecheckandpnpm lintclean;cross-version-terminal-wire.unit.test.tsgreen.Visual Proof
Screenshots of the four live cases are attached in a PR comment rather than committed — evidence belongs on the PR, and the repo root is guarded.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author