Skip to content

fix(agent-status): leftover Claude shells must not hold a finished lead at working (STA-4119) - #15189

Closed
brennanb2025 wants to merge 8 commits into
mainfrom
brennanb2025/sta-4119-repro
Closed

brennanb2025 wants to merge 8 commits into
mainfrom
brennanb2025/sta-4119-repro

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​785 $\color{#cf222e}{\Huge{\mathbf{−}}}$​39 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​746
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​311 $\color{#cf222e}{\Huge{\mathbf{−}}}$​27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​284

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

Background inventory at the turn boundary Pane
lead turn still active working
live child agent on the roster (subagent / teammate) working
pending session cron working
running entry Orca cannot classify — type: "agent", an unknown type, a blank/absent type, a malformed entry working (fail active)
running entry positively identified as a shell (shell, background_shell) done + completion notification
nothing running done + completion notification

readClaudeBackgroundAgentTasks already documented that unclassifiable inventory must fail active. resolveClaudePaneState was 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 gates done → 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 done also became eligible for agent hibernation, and hibernation tears down the PTY — which would kill the very dev server this PR just declared "still running". done answers 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.providerBackgroundWorkActive carries the broad signal to the renderer and disqualifies the pane in getEligiblePane. 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, and experimentalAgentHibernation lowers 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 when background_tasks is present, and UserPromptSubmit carries none), and after this change a recognised shell can no longer hold an idle pane at working — 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 at working.

Notification timing (behavior change)

These turns previously announced immediately off turnCompletedAt, because the pane stayed working past the lead boundary. They now take the ordinary done path and announce on the standard 1.5 s HOOK_DONE_QUIET_MS quiet 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 computes payload.state on the host (RelayAgentHookServer runs the same normalizeHookPayload) and the client forwards it verbatim through ingestRemote, 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. claudeUnclassifiedBackgroundTask is added alongside claudeRunningNonAgentTask. 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 published working, and stops stamping turnCompletedAt for that turn. claudeRunningNonAgentTask keeps its exact previous meaning, so the field an old client already reads did not move under it.

  • Old client + new host. The client renders the host's done normally — 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 no providerBackgroundWorkActive, so its hibernation planner would treat the pane as eligible; experimentalAgentHibernation is 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.
  • New client + old host. The host still publishes working for 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, and ingestRemote falls back to claudeRunningNonAgentTask, which is precisely how that host gated pane state. Covered by a test.

Remote / SSH / Windows parity. All classification lives in src/shared, with no process.platform, path, or connectionId branch, 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_tasks on a lead turn boundary. An idle parent never emits another list, so the pane stayed working indefinitely. 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 went Stop / 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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). Real POST /hook/claude requests in the shape ~/.orca/agent-hooks/claude-hook.sh sends:

Case Result
lead turn active card Working, tab Working
Stop with a live type: "shell" card Done, tab Done, completion notification dispatched (source: agent-task-complete)
SubagentStart + Stop with the child still listed card Working + child row "general-purpose Working"
Stop with a running type: "agent" entry card Working — this read Done before the fix
renderer entry during the shell case state: "done" with providerBackgroundWorkActive: true — idle to the user, off-limits to hibernation
same shell reported completed flag clears, pane eligible again

Every fix has a test that goes red without it, checked by reverting only the production file:

  • F1 contract (type: "agent", unknown type, monitor, blank type, absent type, malformed entry, and the recognised-shell counterpart) — 11 red at the previous head.
  • Hibernation refusal — red as expected [ 'wt-bg' ] to deeply equal [], i.e. the pane really was a candidate.
  • Interrupt inference, both directions, plus the old-host fallback — 3 red.

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 cap case 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 on state !== 'working' after this change, so it now uses unclassifiable work to keep the pane working and 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 touched server.ts, agent-hook-listener.ts, and main/index.ts. pnpm typecheck and pnpm lint clean; cross-version-terminal-wire.unit.test.ts green.

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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Author

  • X / Twitter: @BrennanKB5

…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
@brennanb2025

Copy link
Copy Markdown
Contributor Author

STA-4119 reproduction evidence

Moved 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 reproduction

Verdict: 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 working after the lead turn ends because a live background shell (and a start-less SubagentStop) keeps the background-task / child gate up. The owning Claude PTY is still alive, sitting at an idle ❯ prompt. A hooks-independent PTY-liveness join (STA-4612 as specified) does not clear this case.

Builds

Surface App Contains #14375 / #15082 / #14580? Claude Code
Local macOS Orca (authoritative "has the merged status PRs" build) 1.4.185-adhoc.20260817215434 Yes. Source worktree HEAD 8cd338357ee35e7348cb08d3a0522fee161b2e28 is a descendant of d137bb93e1 (#14375), 60805f5c45 (#15082), and 5e9e38fa75 (#14580). The running adhoc binary stamps turnCompletedAt on the gated working row, which is the #14580 signal. v2.1.233
Windows high spec remote (runtimeId 70a74ef9-bd02-4f76-b08b-846e230d2dc5) 1.4.184 (runtime ready; desktop app not running) No. 1.4.184 predates those merges. Confirmed in-product: the working row has no turnCompletedAt. v2.1.234
Windows low spec Unreachable (ok: false) n/a n/a

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):

  1. Create /tmp/sta-4119-bg-fixture with package.json dev → python3 serve.py (sleeps 3600s). orca repo add --path /tmp/sta-4119-bg-fixture.

  2. macOS: orca worktree create --repo id:a2200db1-ead2-44b2-98ef-305f17644241 --name sta-4119-repro-macos --no-parent --agent claude --setup skip

    • handle term_0a08d384-10a2-49ec-a5da-a6defc516cac
    • paneKey b1a746f4-93d0-483a-9b56-841d3d38b3c5:45175c2f-d16d-4ff4-bc95-809fed804872
  3. Windows: orca worktree create --environment "Windows high spec" --repo id:be84c937-38c9-426c-aa55-300e8f658a83 --name sta-4119-repro-win --no-parent --agent claude --setup skip

    • handle term_ab5aff7b-d73e-4946-b445-dfdfc729b68f
    • paneKey 0eefb1da-3af1-40cb-ab8c-309eea05e5cb:d96df5f8-1870-42e2-b11b-a50bbc6c6985
    • path C:/Users/neil/orca/workspaces/orca-setup-shell-repro/sta-4119-repro-win
  4. Accept Claude's workspace-trust prompt (1. Yes, I trust this folder).

  5. Send the same lead prompt on both panes:

    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 -c "import time; print(\"sta-4119-bg-started\", flush=True); time.sleep(3600)" (fallback python / sleep 3600).
    2. Confirm the process is running in the background.
    3. Reply with exactly STA-4119-TURN-DONE.
  6. Wait until orca terminal wait --for tui-idle is satisfied and the TUI shows the final assistant line plus an idle ❯.

  7. Read last-status.json for that pane and orca worktree ps card/agent state. Re-check ~5 minutes later.

Control (same macOS adhoc build, no background work): worktree sta-4119-control-macos, prompt "Reply with exactly STA-4119-CONTROL-DONE and end your turn. Do not run any shell command."

What I observed

Both platforms (the reported bug)

After the lead printed STA-4119-TURN-DONE:

  • Claude TUI sat at an idle ❯. Footer: 1 shell / 1 shell still running. Status line also showed ← for agents even though the prompt forbade a subagent.
  • orca terminal wait --for tui-idle returned satisfied. The PTY was still running.
  • Worktree card / agent row stayed working. Windows tab title kept the working glyph (✳ STA-4119 background shell test).
  • Last hook Orca stored for the pane was SubagentStop with payload.state: "working". No later hook arrived while the background shell lived.
  • The SubagentStop carried a toolAgentId that never had a matching visible SubagentStart in the pane status. That matches the already-measured fact that start-less SubagentStop is native traffic.

Re-check at 16:37:44 local, ~5 minutes after the macOS SubagentStop (16:32:58) and the Windows one (receivedAt 1787009583714): same last event, still working. This is not a brief race.

Windows extra: Claude printed Background command "Start long-lived background process" failed with exit code 49 and still showed 1 shell still running. The inventory Orca consumed was still a live shell as far as Claude's own status line was concerned.

macOS 1.4.185-adhoc (has #14375 / #15082 / #14580)

~/Library/Application Support/orca/agent-hooks/last-status.json pane entry (full dump: sta-4119-macos-last-status-entry.json):

{
  "hookEventName": "SubagentStop",
  "toolAgentId": "ac4a0c329a0e18cd9",
  "payload": {
    "state": "working",
    "lastAssistantMessage": "STA-4119-TURN-DONE",
    "toolName": "Bash",
    "turnCompletedAt": 1787009576866
  },
  "receivedAt": 1787009578408,
  "stateStartedAt": 1787009567895
}

orca worktree ps: card status=working, agent state=working, last message STA-4119-TURN-DONE. Unchanged 5 minutes later.

turnCompletedAt is present. That is the #14580 stamp: lead Stop was gated back up to working by the background shell, and the listener recorded the turn-end time so the completion coordinator can announce without waiting for done.

Windows 1.4.184 (original platform, pre-#14580)

C:\Users\neil\AppData\Roaming\orca\agent-hooks\last-status.json for pane 0eefb1da-…:d96df5f8-… (fields: sta-4119-windows-last-status-fields.json; full entry on the host at sta-4119-win-last-status.json in that worktree):

  • hookEventName=SubagentStop
  • state=working
  • turnCompletedAt=None — not in payloadKeys
  • lastAssistantMessage=STA-4119-TURN-DONE
  • toolName=Read
  • toolAgentId=a0dc6d9fd3ea4d8be
  • receivedAt=1787009583714

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 status=active, agent state=done. Same build, same Claude major, no background inventory → the working→done edge happens.

Did the completion notification fire?

Build Notification
Windows 1.4.184 No path for it to fire. Last row is working with no turnCompletedAt and no later done. The old coordinator only announces on a working→done (or equivalent) edge. Matches the reporter ("no completion notification, no sound, no chip").
macOS 1.4.185-adhoc Stamp present, banner not independently observed. The gated working row carries turnCompletedAt=1787009576866, which is exactly the signal #14580 added so the coordinator can announce the finished turn while the pane stays working. I searched ~/Library/Application Support/orca/logs/main.trace.ndjson and daemon.log for agent-task-complete / this paneKey / STA-4119-TURN-DONE and found no dispatch log. I did not see an OS banner from this session. I am not claiming the live banner fired; I am claiming the data the coordinator needs is on the row.

#14580 (fix(agent-status): announce Claude turn complete while background work runs) is already on this source HEAD. #14620 (stop rendering the leftover gate as foreground work) was closed unmerged. So on current main the remaining user-visible half of STA-4119 is the spinner/card staying "Claude is working right now" while the TUI is idle.

Mechanism (checked against this tree, not the handoff line numbers)

resolveClaudePaneState (src/shared/agent-hook-listener.ts) returns working when the lead is done if a roster child is working or claudeRunningNonAgentTaskPaneKeys / session-cron gates are set.

updateClaudeRunningNonAgentTask runs on lead events that carry background_tasks. A running type: "shell" is a non-agent task (src/shared/claude-background-task-inventory.ts). Folding the inventory into the roster happens on a lead turn boundary (Stop / StopFailure). An idle parent never emits another inventory.

A later start-less SubagentStop (native traffic; we saw one on both platforms after a prompt that forbade subagents) re-emits the cached lead as working. That is why last-status.json ends on SubagentStop / working — same as the reporter — rather than on the lead Stop.

This is not the #14375 phantom: the gate has positive evidence (Claude's own "1 shell still running", a turnCompletedAt stamp on the adhoc build, a live PTY). Working is what the current state machine intends given that inventory.

STA-4612 subsumption verdict: does not subsume this case

STA-4612 proposes a hooks-independent backstop that is either:

  1. process-exit of the owning agent, keyed by pid + start time, or
  2. a read-time liveness join with "the owning session/PTY is still live"

so a dead pane cannot stay working.

Here the pane is alive. Claude is at an idle prompt. orca terminal wait --for tui-idle succeeds. The background shell is a child of that still-live PTY, not a replacement for it. Intersecting status with "PTY live" still yields live + working. Process-exit never fires because the Claude process has not exited.

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 → done fallback (the reporter's first suggestion) would also fight keep-awake / hibernation, which currently treat state !== 'done' as live work. #14620's closed approach — keep state=working for those systems, but stop drawing it as foreground activity — is the product-shaped remaining fix if notification-on-turnCompletedAt is accepted as sufficient for the banner half.

Post-fix (this worktree)

Plan: STA-4119-PLAN.md. Reviewed CLEAN by Claude Fable (task_599c4da8f712) then independently verified CLEAN by a fresh Codex worker (task_fa35d597c48c) before any production edit.

The reporter sequence is now a unit test (does not hold a finished lead at working for a leftover background shell). It was red on the pre-change listener (Stop + running shell published working) and is green after removing leftover shells from resolveClaudePaneState / the two sibling predicates.

147 related tests pass (claude-background-task-status, Claude subagent listener, background-turn notifications, last-status write/lead-boundary, hook ingest, interrupt inference, relay hook server).

Live UI re-run against this commit is not possible in the currently running desktop (1.4.185-adhoc.20260817215434): that binary does not load this worktree. The leftover sta-4119-repro-macos / sta-4119-repro-win panes will stay working until a build that contains this change processes a new hook (or the session is restarted on that build).

What is left

  • Merge the PR that implements STA-4119-PLAN.md.
  • Re-run the live macOS repro on a desktop that includes this commit: card/tab must be done while 1 shell still running.
  • Repro worktrees left running on purpose: sta-4119-repro-macos (local) and sta-4119-repro-win (Windows high spec). Kill the background sleep/python if they should not keep a core parked.

Evidence files

  • sta-4119-macos-last-status-entry.json — full local last-status rows for repro + control
  • sta-4119-windows-last-status-fields.json — extracted Windows last-status fields
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.
@coderabbitai

coderabbitai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Claude 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)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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.
Description check ✅ Passed The description clearly explains the problem, scope, rationale, compatibility, testing, visual proof, linked issue, and checklist status.
Title check ✅ Passed The title clearly identifies the primary fix: recognized leftover Claude shells no longer keep a completed lead in the working state.
✨ 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: 3

🧹 Nitpick comments (1)
STA-4119-PLAN.md (1)

47-60: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover StopFailure in the regression matrix.

The decision applies to Stop and StopFailure on Line 5, but the listed STA-4119 sequence covers only Stop on Lines 49-57. Add a shell-only StopFailure case, or identify an existing test that verifies the same done and notification behavior.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 53e41eea-843c-4dc6-909f-4ba17cffb9c2

📥 Commits

Reviewing files that changed from the base of the PR and between 24e662a and bc6c538.

📒 Files selected for processing (10)
  • STA-4119-PLAN.md
  • STA-4119-REPRO.md
  • src/main/agent-hooks/server-last-status-write.test.ts
  • src/relay/agent-hook-server.test.ts
  • src/renderer/src/hooks/agent-hook-completion-background-turn-notifications.test.ts
  • src/shared/agent-hook-listener-claude-subagents.test.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/claude-background-task-status.test.ts
  • sta-4119-macos-last-status-entry.json
  • sta-4119-windows-last-status-fields.json

Included review availability: Your plan includes up to 10 reviews per rolling hour; 4 remain after this review.

Comment thread sta-4119-macos-last-status-entry.json Resolved
Comment thread STA-4119-PLAN.md Resolved
Comment thread STA-4119-PLAN.md Resolved
… 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
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Live validation evidence — STA-4119 revision

Isolated dev instance built from this branch (temp ORCA_DEV_USER_DATA_PATH, throwaway single-commit git repo, Playwright CDP only, torn down afterwards). Hooks driven by real POST /hook/claude requests in the shape ~/.orca/agent-hooks/claude-hook.sh sends.

1. Lead turn ends with a type: "shell" background task still running → card and tab reach Done.
The completion notification fired for this pane (dispatchTerminalNotification with source: "agent-task-complete").

01-shell-alive-reaches-done.png

2. Control — a live typed subagent still holds Working.
Lead row Working plus the indented child row "general-purpose Working", with the same shell running.

02-live-subagent-holds-working.png

3. The fix — a running type: "agent" entry holds Working.
This read Done before the revision. Orca cannot classify the type, so it fails active.

03-unknown-type-holds-working.png

4. The same shell reported completed → the hibernation guard clears.

04-shell-finished-flag-clears.png

Hibernation plumbing, observed end to end

With the shell alive, the renderer's own status entry for the pane read:

{ "state": "done", "providerBackgroundWorkActive": true }

Idle to the user, off-limits to the hibernation planner. After the shell reported completed, the same probe showed state: "done" with the flag absent — the pane becomes eligible again, so failing safe does not become a second one-way latch.

Original STA-4119 reproduction record (pre-fix, both platforms)

Preserved from the earlier evidence comment: TUI idle at the prompt showing 1 shell still running, card and tab stuck at working, and last-status.json holding SubagentStop with state: working. Reproduced on macOS 1.4.185-adhoc (contains #14375 / #15082 / #14580) and Windows 1.4.184. The control turn without a background shell already went Stop / done.

@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.

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 win

Keep malformed running agent rows fail-active.

A running subagent or teammate entry without id is malformed. This branch only sets truncated. It does not set hasRunningUnclassifiedTask.

The listener then has no roster row and no unclassified gate. A later Stop can publish done while the provider task is still running.

Set hasRunningUnclassifiedTask when the malformed typed agent row is nonterminal. Add a regression case for a running subagent without id.

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

📥 Commits

Reviewing files that changed from the base of the PR and between bc6c538 and af7eefe.

📒 Files selected for processing (19)
  • src/main/agent-hooks/server-interrupt-inference-guards.test.ts
  • src/main/agent-hooks/server-last-status-write.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/index.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/agent-hook-envelope-build.ts
  • src/relay/agent-hook-server.test.ts
  • src/renderer/src/hooks/ipc-events-agent-status-store-test-fixtures.ts
  • src/renderer/src/hooks/useIpcEvents-agent-status-turn-completion.test.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/lib/agent-hibernation-planner.test.ts
  • src/renderer/src/lib/agent-hibernation-planner.ts
  • src/renderer/src/store/slices/agent-status.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-status-types.ts
  • src/shared/claude-background-task-inventory.ts
  • src/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.

@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: 2

🧹 Nitpick comments (1)
src/main/agent-hooks/server-status-snapshot-background-work.test.ts (1)

27-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten 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

📥 Commits

Reviewing files that changed from the base of the PR and between 41c1565 and 5958126.

📒 Files selected for processing (13)
  • src/main/agent-hooks/server-status-snapshot-background-work.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/index.ts
  • src/renderer/src/hooks/useIpcEvents-agent-status-turn-completion.test.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/lib/agent-hibernation-coordinator.test.ts
  • src/renderer/src/lib/agent-hibernation-planner.test.ts
  • src/renderer/src/lib/agent-hibernation-planner.ts
  • src/renderer/src/lib/agent-hibernation-snapshot-replay-guard.test.ts
  • src/renderer/src/lib/agent-pane-provider-background-work.ts
  • src/renderer/src/store/slices/agent-status.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/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.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Note for reviewers: 5 unrelated files in this diff are formatter-only churn

Merging current main in brought these along, and they are not part of this change:

  • config/scripts/wsl-git-shell-benchmark.mjs
  • src/main/codex/codex-trust-grant-host.test.ts
  • src/main/local-worktree-filesystem-wsl-banner.wsl.test.ts
  • src/main/providers/local-pty-provider-windows-shell-launch.test.ts
  • src/renderer/src/components/settings/CliSkillRuntimeSetup.tsx (+ its test)
  • src/shared/wsl-login-shell-command.test.ts, src/shared/wsl-exec-mode-separator.test.ts
  • src/main/local-worktree-filesystem.test.ts

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 oxfmt --check fails on the merge-base versions, i.e. those files are currently unformatted on main. The pre-commit hook normalized them when it ran over the merge.

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 main's changes, and that is not what happened here. Left in place deliberately: reverting would reintroduce unformatted code that the hook will fix again on the next touch.

Review these files by skipping them.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

The 5 red e2e / changed e2e specs failures are environmental, not this PR

All five fail identically:

Error invoking remote method 'ssh:connect': Orca's local relay build is missing its
version marker at out/relay/linux-x64/.version. This usually indicates a packaging
or build problem; reinstall Orca.

That is the CI relay build not producing its version marker — no SSH connection is ever attempted, so nothing about agent status is exercised.

Attribution: this branch authored no e2e specs at all (git diff --name-only <merge-base>..HEAD -- tests/e2e/ is empty). The five specs are SSH tests that arrived from main via #14844, and they run here only because merging main in makes them "changed" relative to this PR's merge base. Sibling PRs #15202 and #15212 report e2e: skipping for exactly that reason — they have no changed e2e specs.

Not fixing it here: a CI relay-build problem is not in scope for a status-semantics change, and patching it from this branch would be unrelated drive-by scope.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

The 2 red e2e jobs are a CI relay-build problem, not this PR

Every failure across both jobs is the same line, thrown at ssh:connect before any test logic runs:

Error invoking remote method 'ssh:connect': Error: Orca's local relay build is missing its
version marker at /home/runner/work/orca/orca/out/relay/linux-x64/.version. This usually
indicates a packaging or build problem; reinstall Orca.

The job log says why, earlier in the same run:

[e2e] SKIP_BUILD set and SSH relay bundle exists — skipping relay build

The relay build was skipped because a bundle was already present, but that bundle carries no .version marker — so every SSH connection is refused and the specs fail before touching anything they test. It reproduces on rerun because the cached state is identical, which is why it looks deterministic rather than flaky.

Attribution: this branch changes no e2e spec, and its only src/relay/ edits are to the agent-hook envelope/server files — code that is never reached, because ssh:connect fails first. The same two jobs fail identically on the sibling PR in this batch, whose diff is confined to compact hook registration and shares almost nothing with this one. Sibling #15212 shows fully green (48/48) only because its merge base leaves those specs unchanged, so they never run there.

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.
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

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.

@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 Plus

Run ID: 424a8d42-a231-4c7c-85e8-a67df6cd6bed

📥 Commits

Reviewing files that changed from the base of the PR and between f0c718e and 234b07b.

📒 Files selected for processing (26)
  • src/main/agent-hooks/server-hook-http-ingest.test.ts
  • src/main/agent-hooks/server-interrupt-inference-guards.test.ts
  • src/main/agent-hooks/server-last-status-write.test.ts
  • src/main/agent-hooks/server-status-snapshot-background-work.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/index.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/agent-hook-envelope-build.ts
  • src/relay/agent-hook-server.test.ts
  • src/renderer/src/hooks/agent-hook-completion-background-turn-notifications.test.ts
  • src/renderer/src/hooks/ipc-events-agent-status-store-test-fixtures.ts
  • src/renderer/src/hooks/useIpcEvents-agent-status-turn-completion.test.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/lib/agent-hibernation-coordinator.test.ts
  • src/renderer/src/lib/agent-hibernation-planner.test.ts
  • src/renderer/src/lib/agent-hibernation-planner.ts
  • src/renderer/src/lib/agent-hibernation-snapshot-replay-guard.test.ts
  • src/renderer/src/lib/agent-pane-provider-background-work.ts
  • src/renderer/src/store/slices/agent-status.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-hook-listener-claude-subagents.test.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-status-types.ts
  • src/shared/claude-background-task-inventory.ts
  • src/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.

Comment on lines +123 to +126
const unknown = entry()
expect(
plannedWorktrees(snapshot({ agentStatusByPaneKey: { [unknown.paneKey]: unknown } }))
).toEqual(['wt-bg'])

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.

🎯 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

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 working while Claude reports provider-owned background work, and settle to done only once the lead session reports that work is gone. It fixed reported issue #10997 — Claude's footer saying 1 shell still running while Orca's sidebar and orca worktree ps already said done. It confirmed by binary inspection of Claude Code 2.1.220 that the inventory covers subagent, teammate, workflow, shell, monitor, MCP task, dream, auto-mode scan, and cloud session.

This PR settles that same pane to done. That is #10997 again.

Three independent lanes read the gate as a bug and none caught this, because resolveClaudePaneState and updateClaudeRunningNonAgentTask carry no comment pointing at #11838 — the mechanism is documented, the product intent never was. That is the durable lesson here, and worth a comment on the gate whichever way it lands.

Why the framing was wrong, not just the direction. STA-4119 and #11838 are the same observation from opposite sides: done is wrong while a shell is genuinely running, and working is wrong once the lead turn is over and nobody is waiting. Both complaints are correct, which is why every either/or fix reverts the other one. Neither state is right — the answer is a third state.

What supersedes it: #14205 (feat(agents): distinguish Claude background monitoring), which adds an optional workingMode: 'monitoring' for exactly this case. It is the better design on the point that matters most here: the wire state stays working, so workingMode is additive and older peers keep rendering Working — #11838's behavior preserved by construction, with no new enum crossing a version boundary. It also moots the hibernation exposure this PR had to guard against: a pane that never reaches done is never hibernation-eligible.

Not lost. Two findings from this PR's review stand on their own and are already filed:

  • STA-4747 — hibernatePaneIfStillEligible awaits its final re-plan and calls shutdown with no synchronous re-check, so a new turn can land mid-probe with every process identity unchanged and teardown kills a pane that is now working. Reproduced against clean main, independent of anything here.
  • STA-4744 — Windows has no process identity that survives PID reuse.

Also recorded, for whoever revisits this area: providerBackgroundWorkActive never traversed the snapshot/replay path (getSnapshot → toAgentStatusIpcPayload → enrichAgentStatusIpcPayload → setAgentStatus), so the guard added here was inert on an ordinary renderer reload. Not a problem once the state stops being done, but the same shape will bite any future field added to the live-push path alone.

Branch left in place. STA-4119 stays open and re-homed onto #14205.

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