Repository navigation
fix(agent-status): stop foreground-idle Claude from rendering as active foreground work (STA-4119) - #14620
fix(agent-status): stop foreground-idle Claude from rendering as active foreground work (STA-4119)#14620brennanb2025 wants to merge 4 commits into
Conversation
…ve work (STA-4119) When a Claude lead turn ends while background work is still registered (background shell, subagent, monitor, session cron), resolveClaudePaneState gates the pane up to `working`. That is right for liveness — the work really is running — but it made the worktree card, tab glyph and agent row draw a finished turn as an active foreground spinner for the whole background lifetime. Carry the gate's provenance as an optional `backgroundOnly` marker instead of discarding it. `state` stays `working`, so keep-awake, auto-hibernation, teardown and every freshness gate are untouched; only surfaces that render FOREGROUND activity consult the marker. Fixes #14253
|
Warning Review limit reached
Next review available in: 50 seconds You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (24)
📝 WalkthroughWalkthroughThe change adds an optional 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6d8f8906-23a5-4d08-a101-8a813c3077ad
📒 Files selected for processing (19)
src/main/agent-hooks/server.tssrc/main/runtime/orca-runtime.tssrc/renderer/src/components/AgentStateDot.tsxsrc/renderer/src/components/AgentWorkingSpinner.tsxsrc/renderer/src/components/dashboard/DashboardAgentRow.tsxsrc/renderer/src/components/sidebar/background-only-agent-presentation.test.tssrc/renderer/src/components/sidebar/worktree-agent-activity-summary.tssrc/renderer/src/components/sidebar/worktree-card-agent-summary.tssrc/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsxsrc/renderer/src/components/tab-bar/terminal-tab-activity-status.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/agent-status.tssrc/shared/agent-background-only-activity.tssrc/shared/agent-hook-listener.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-status-types.tssrc/shared/claude-foreground-idle-background-work-status.test.tssrc/shared/runtime-types.ts
| case 'background': | ||
| return 'Background work' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Localize the new background label.
agentStateLabel('background') supplies accessible labels and tooltip text. The raw Background work string remains English for localized renderer sessions. Add the generated renderer locale key and use translate.
Based on learnings, generate locale keys from the first 10 characters of the SHA-1 hash of <filePath>:<text>.
Source: Learnings
Carry the background-only marker through dashboard snapshots and live popout patches so the board, map, and notes target menu do not retain a foreground spinner. Keep the agent state and dashboard grouping working for liveness.
QA visual proof (isolated Electron, HEAD
|
| surface | foreground working |
working + backgroundOnly |
|---|---|---|
| worktree card | Working main primary |
Done main primary |
| tab 1 / tab 2 | Working Terminal 1/2 |
Done Terminal 1/2 |
| parent rows | Working … - Bash: npm run dev |
Background work … - Claude |
| child row | n/a | Working scan the repo - explore |
| dashboard grouping | Working: 2 | Working: 2 (still live) |
| dashboard cards | main Working … |
main Background work … |
AgentTerminalDialog |
Claude · Working |
Claude · Background work |
| Activity | — | region Working activity / rows Background work |
Console: 0 errors (pre-existing tooltip / React Grab / xterm deadline warnings only).
Gap — drawer Agent Map hands off to dashboard.openPopout('map'); that pop-out did not appear as a CDP target, so map pixels were not captured. Board / Activity / dialog all used the same Background work label while grouping stayed Working.
Evidence
Foreground working (card + tabs + rows spinning):
Background-only: card/tabs settle; parent rows still ring + Background work; child stays Working:
Dashboard board stays in WORKING with Background work cards:
Board child remains Working:
AgentTerminalDialog reads Claude · Background work:
Activity group WORKING, rows Background work:
Ordinary working restores the spinner:
Dialog restores Claude · Working:
|
Closing after reviewing the original Codex/Claude transcripts and screenshot: the foreground was idle while a real Claude monitor was still running and visibly reported in the TUI, so the existing working state is correct and this presentation change is unnecessary. |








ELI5
When Claude finishes a turn but leaves something running in the background — a dev server it started as a background shell, a subagent, a monitor, a session cron — Orca keeps the pane marked
working. That is correct: the pane really is still live, and keep-awake, auto-hibernation and teardown all depend on it.But the picture was wrong. The worktree card, the tab glyph and the agent row all drew the spinning "Claude is working right now" indicator, forever, while the TUI sat at its idle
❯prompt. This PR keeps the pane live and stops it from looking like active foreground work.What Changed
resolveClaudePaneState(src/shared/agent-hook-listener.ts) already knows the difference between "the lead turn is running" and "the lead turn ended but background work gated it back up toworking". It threw that provenance away. Now it returns it, and the emitted row carries an optionalbackgroundOnlymarker.stateis unchanged — stillworking. Only surfaces that render foreground activity consult the marker:working(yellow spinner)done(green)workingdone(check)working(spinning ring)backgrounddot — the same yellow ring, complete and still, labeled "Background work"workingBash: npm run dev)entry.stateworkingworkingThe marker is cleared the moment a new foreground turn starts, so the next prompt spins again even while the dev server keeps running.
New module
src/shared/agent-background-only-activity.tsholds the one predicate all four presentation seams share.Why
resolveClaudePaneStategating up toworkingis correct and must stay — it is the only thing keeping the pane out of the hibernation planner and the keep-awake reaper while a real dev server runs. So the fix cannot be "reportdone". It has to be "reportworking, and say why".Keeping
statefixed is what makes this narrow: every liveness consumer readsstateand is untouched by construction. There is no new state inAGENT_STATUS_STATES, no capability negotiation, and no behavior change for panes with no background work (the marker is only ever set on the gated branch).Relationship to #14580 — independent behavior, shared plumbing
#14580 fixes notification timing. This PR fixes the picture. Neither behavior depends on the other, but both carry additive metadata through the same agent-status pipeline, so they share plumbing and will need conflict resolution if both land.
turnCompletedAtand changes when the completion banner fires; it explicitly preserves the spinner.backgroundOnlyand changes what the sidebar draws. It does not change notification identity or completion coordination.turnCompletedAtis a timestamp keyed to announcement identity;backgroundOnlyis a boolean keyed to presentation. Together they provide the complete behavior requested by the issue.src/main/agent-hooks/server.ts,src/main/runtime/orca-runtime.ts,src/renderer/src/hooks/useIpcEvents.ts,src/renderer/src/runtime/web-session-tabs-sync.ts,src/shared/agent-hook-listener.test.ts,src/shared/agent-hook-listener.ts,src/shared/agent-status-types.ts, andsrc/shared/runtime-types.ts.Not a duplicate of #14375 (merged). That one narrows when a phantom
workingmay be minted after a restart with no cached lead —buildClaudeCachedLeadStatusPayload's evidence path. This PR does not change any state value at all; it annotates aworkingthat #14375 already agrees is legitimate. The evidence-mintedworkingin that path is correctly left unmarked here: no lead boundary was observed, so there is nothing to claim finished.Linked Issue
Related: #14253 (presentation half only; completion notifications remain tracked separately).
Linear: STA-4119. Same mechanism as #13245.
Visual Proof
Captured live over CDP against an isolated Orca dev instance launched from this worktree, driving the real store through
setAgentStatusand reading the rendered accessibility tree.Worktree card + agent rows — before (all spinning) → after (card green, rows static ring, child row still spinning):
Terminal tab glyph — before → after:
Rendered accessibility tree, same instance, same panes:
Working main primaryDone main primaryWorking Terminal 1Done Terminal 1Working Terminal 2Done Terminal 2Working wire up the release checklist - Bash: npm run devBackground work wire up the release checklist - ClaudeWorking start the dev server - Bash: npm run devBackground work start the dev server - ClaudeWorking scan the repo - exploreWorking scan the repo - exploreThen re-published a plain
working(a new foreground turn while the background work persists) on the same panes: card, both tabs and both rows all returned toWorking. The marker round-trips.Design: no new tokens, no new color tier.
backgroundreuses the existingAgentWorkingSpinnerring in its documented reduced-motion form (complete ring, no rotation —#9515already established that as "an intentional static marker"), so it stays in theworkingcolor family because work really is running, and loses the motion because nothing is happening in the turn the user is watching.Testing
Two new suites, 24 cases, both proven red on
mainby reverting each production seam in turn:src/shared/claude-foreground-idle-background-work-status.test.ts(14) — replays real hook sequences through the realnormalizeHookPayload:Stop; long-lived background shell; background subagent (and its row staysworking); active session cronStopre-sets itworking; non-boolean values rejected; survivespickParsedAgentStatusPayload; an older peer that never stamps it reads as ordinary foreground work; an older receiver drops it on parsesrc/renderer/src/components/sidebar/background-only-agent-presentation.test.ts(10) — card summary, tab glyph, row dot:workingstill spins on every surfacehasLiveDone/done/backgroundworkingrow is ignoredworkingunder a background-only parentdonestatus, so keep-awake and hibernation see live workReverting
agent-hook-listener.tsalone turns 7 listener cases red; reverting the three presentation seams turns 3 presentation cases red.Also run:
pnpm typecheck(node + cli + web) exit 0;oxlint+oxfmt --checkclean on every touched file;pnpm exec vitest runoversrc/shared,src/main,src/renderer/src/components,src/renderer/src/store,src/renderer/src/hooks,src/renderer/src/lib,src/renderer/src/runtime— 800 files / 7998 tests green.Review
backgroundOnlyarrives from an untrusted agent hook payload. It is accepted only as literaltrueand only onworking; every other type or state normalizes toundefined, exactly likeinterruptedandsessionBoundary. It is never parsed, formatted into a path, or interpolated into a command. Worst case a hostile value makes that pane's own dot quieter; it cannot cross panes or suppress another agent's state.ParsedAgentStatusPayload, which is whatAgentHookRelayEnvelope.payloadalready carries and whatingestRemotere-validates at the trust boundary, so the relay path needs no change. New host → old client:normalizeAgentStatusObjectrebuilds field-by-field and drops the unknown key, so the client renders today's spinner. Old host → new client: the field is simply absent and the row reads as ordinary foreground work. Additive-optional both ways, no new stream opcode, no capability gate needed — unlikesessionBoundary, an old peer cannot misact on it, since ignoring it reproduces current behavior exactly. Both directions are pinned by tests.paneKey/tabIdas before.RuntimeWorktreeAgentRow.backgroundOnlyis forwarded soworktree psand paired clients can see it. Mobile's own row rendering is deliberately unchanged in this PR (same scope call#14375made forrestoredUnconfirmed); paired clients that predate the field decode fine and renderworking. Mobile presentation parity is a clean follow-up on top of the now-available field.AGENT_STATUS_STATESis unchanged;AgentStatusStategains no member.!==in the store's sort-relevance check. The new epoch term is required, not incidental: the whole transition isworking → working, so without it the memoized card/tab summaries would never recompute. Same reasonequivalentParsedAgentStatusPayloadinagent-hooks/server.tsnow compares it — deduping that edge would drop the fix before any receiver saw it.Deliberately out of scope
working). Background work is real work, so ordering by it is not a false claim, and the honest completion timestamp for the ranking isturnCompletedAt— which is fix(agent-status): announce Claude turn complete while background work runs #14580's field, not this one. Worth revisiting once both land.Checklist
N/Awith reasonpnpm buildleft to CI)Author