fix(web): a thread that left a shell running shows its unseen completion #14910
main fromrefs/pull/14910/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubFixes #14872.
Problem#
When an agent starts a background shell (a dev server, a long command it no longer needs) and ends its turn while you are in another thread, that thread's sidebar row reads "Waiting", dimmed, for as long as the shell lives. The unseen "Done" label and the unread style never show, so a finished thread looks like one that is still working; it only lights up when the shell exits, possibly hours later.
A shell that outlives the turn stays on the pending background roster as kind: "command". shellRuntime parks the thread's runtime at idle whenever that roster is not empty, and the sidebar maps idle to waiting before it looks for an unseen completion. Alerts already use a narrower rule since #14213: backgroundWorkHoldsCompletion holds a completion for subagents, monitors and unnamed background work, which wake the agent, but not for commands.
Change#
The runtime now parks at idle only when backgroundWorkHoldsCompletion says the roster holds the completion, in both places that derive it (shellRuntime in packages/client-runtime/src/state/models.ts and deriveThreadRuntime in threadExecution.ts). A roster of commands only presents the run's own status, so the row reads as ready: unread, "Done", not dimmed. Subagents, monitors and unnamed background work keep it at Waiting, as before, and a failed run still outranks the roster.
Two consumers looked at the roster themselves and follow the same rule:
resolveThreadStatusPill(command palette rows) checked the roster's length, so it would have kept saying Waiting.ThreadNotificationCoordinatortreated "waiting on commands only" as settled; that state can no longer occur, so the branch is gone and alerts fire onreadyas they did.
Because the split lives in the shared runtime, the mobile thread list gets it without a code change (resolveThreadListV2Status maps the same runtime status; only its comment is updated). The roster itself is untouched: the chat view's "Waiting on command" banner and its Stop button still show for the running shell, and server auto-settle still treats any roster as live work.
One visible consequence, the same one alerts have had since #14213: a short background command whose completion wakes the agent reads Done, then Working, then Done again.
Scope and approval#
Triaged bug #14872, following the triage comment: use the same kind split for the sidebar status, the dimmed row, the unread label and the mobile list; anything that holds completion stays Waiting. The optional "still running" hint is not added. Client only: client-runtime, the web sidebar logic and notification coordinator. No server, contract or provider change.
Verification#
Real web client, before and after. Headless Chromium at 1400×900 against vp run dev, main at cc1e634bfa versus this branch, isolated state, a synthetic project and a stand-in provider (no real account, model call or shell) that replays the background-task frames from the repo's claude_background_task_after_root recording and never clears the roster. Thread A gets the background-shell turn while thread B is open; thread C ends its turn with a monitor on the roster. Both databases show A's roster entry as kind: "command" and A's last visit before its completion.
Before (main): thread A finished unseen, row says Waiting, dimmed | After: thread A says Done, unread |
|---|---|
![]() | ![]() |
| Step on this branch | Observed |
|---|---|
| Thread C ends its turn with a monitor on the roster | C reads Waiting, dimmed; A stays Done (capture) |
| Open thread A | The "Waiting on command" banner and Stop are still there (capture) |
| Go back to thread B | A's Done label clears and its title returns to normal; the roster is unchanged |
Tests. entities.test.ts: a commands-only roster presents the run's status (completed, and a stale running or checkpoint-waiting shell keeps its own status), while a monitor, a subagent, unnamed background work, and a command together with a subagent park at idle; a failed run outranks holding work; the same split for the detail runtime. Sidebar.logic.test.ts: from real presentThreadShell output, a commands-only thread is ready, done, not receded, off the Working shelf and gets the Completed pill, and a monitor thread stays Waiting and receded. threadListV2.test.ts: the mobile list reads a commands-only thread as ready and unread and a monitor thread as waiting. Existing cases that used a command to stand for "holds the thread" now use a monitor. 379 tests pass across nine files; with the two runtime files reverted, 7 fail. Typecheck for client-runtime, web and mobile, targeted lint, format and knip are clean.
Not checked: the mobile app in a simulator (its list reads the shared runtime and is covered by its test), the packaged desktop app (it renders the web sidebar), OS notification delivery, and a real Claude session leaving a shell behind (the stand-in replays recorded frames).
Implemented with Claude Code (Claude Opus 5.5, coordinated by Claude Fable 5.1); tests, independent review and evidence capture by GPT-6 Astra via Codex.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- packages/client-runtime/src/state/models.ts line 174Resolvedby Mnigos(GitHub profile, opens in a new tab)@@ -159,12 +160,15 @@159160 );160161 }161162162-// Park runtime at idle when the post-settlement background roster is nonempty163-// so #4415 waiting-presentation Waiting (session.idle) can consume CTM runtime.163+// Park runtime at idle when the post-settlement background roster holds the164+// run's completion, so #4415 waiting-presentation Waiting (session.idle) can165+// consume CTM runtime. Only work that wakes the agent holds it: commands it166+// left running, such as a dev server, present the run's own status (#14872).164167 // The server suppresses the roster while an interruptible activity run exists,165168 // so a remaining roster is stronger than checkpoint-oriented waiting.166169 // latestRun keeps the latest run's status for history presentation.167170 // A failed latest run outranks the roster, so the failure stays visible.168171 function shellRuntime(thread: OrchestrationV2ThreadShell): ThreadRuntimeSummary | null {169172 if (thread.latestRunId === null && thread.activeProviderThreadId === null) return null;170- const parkAtIdle = (thread.pendingBackgroundTasks?.length ?? 0) > 0 && thread.status !== "failed";173+ const parkAtIdle =174+ backgroundWorkHoldsCompletion(thread.pendingBackgroundTasks ?? []) &&
🟡 Medium
state/models.ts:174An unrecognized pending task kind makes
parkAtIdlefalse, so the shell reports the root run as completed/ready instead of Waiting while background work remains pending; the detailed runtime path is affected as well.backgroundWorkKindHoldsCompletionneeds adefaultthat returnstrue, preserving the conservative fallback for unknown kinds.🤖 Copy this AI Prompt to have your agent fix this:
In file @packages/client-runtime/src/state/models.ts around line 174: An unrecognized pending task kind makes `parkAtIdle` false, so the shell reports the root run as completed/ready instead of Waiting while background work remains pending; the detailed runtime path is affected as well. `backgroundWorkKindHoldsCompletion` needs a `default` that returns `true`, preserving the conservative fallback for unknown kinds.Note
🤖 Claude Fable 5.1 on behalf of Mnigos
Not reachable.
backgroundWorkKindHoldsCompletion(unchanged by this PR) is exhaustive overPendingBackgroundWorkTask["kind"], and that type comes fromOrchestrationV2PendingBackgroundTaskinpackages/contracts/src/orchestrationV2.ts, which is built withkindUnionWithFallback: a roster entry whosekindis unknown to this build, or missing, decodes askind: "background_task"("Rosters persisted before kinds existed carry nokindand load asbackground_task"), and that kind holds the completion. The shell and the detail runtime only see decoded rosters, so an unrecognized kind cannot arrive at the switch; if a new member were added to the union without a case, the function would stop typechecking (its declaredbooleanreturn would becomeboolean | undefined). Adefaultreturningtruewould be dead code.Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Approvability#
Verdict: Approved at
ee255a5Macroscope's review found this PR approvable — This is a narrowly scoped client-side bug fix that corrects sidebar, mobile, and notification presentation for threads with command-only background work while preserving actual shell execution and server behavior. Regression tests cover the changed status combinations and the related runtime projections.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).juliusmarminge added labelsmacroscope-review
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
92c9d4c0-ac7a-44d7-a7ed-cd05273713b7📥 Commits
Reviewing files that changed from the base of the PR and between bf7121d7a25fe84d76561c3142b9433615a703a1 and 023bb6079f0dc680ddd6287b18a9688b4a349029.
📒 Files selected for processing (8)
apps/mobile/src/features/threads/threadListV2.test.tsapps/mobile/src/features/threads/threadListV2.tsapps/web/src/components/Sidebar.logic.test.tsapps/web/src/components/Sidebar.logic.tsapps/web/src/components/ThreadNotificationCoordinator.tsxpackages/client-runtime/src/state/entities.test.tspackages/client-runtime/src/state/models.tspackages/client-runtime/src/state/threadExecution.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
Runtime and sidebar status handling now distinguish background work that holds completion from commands that remain active after a run completes. Tests cover runtime states and sidebar presentation for command, monitor, subagent, and background-task cases.
Changes#
Completion status handling
Layer / File(s) Summary Runtime status derivation
packages/client-runtime/src/state/models.ts,packages/client-runtime/src/state/threadExecution.ts,packages/client-runtime/src/state/entities.test.tsRuntime derivation uses backgroundWorkHoldsCompletionto determine when pending background work parks a thread at idle. Tests cover completed, running, waiting, and failed states across different task kinds.Sidebar and completion presentation
apps/web/src/components/Sidebar.logic.ts,apps/web/src/components/Sidebar.logic.test.ts,apps/web/src/components/ThreadNotificationCoordinator.tsx,apps/mobile/src/features/threads/threadListV2.ts,apps/mobile/src/features/threads/threadListV2.test.tsThe sidebar uses the completion-hold predicate to resolve Waiting status. Completion timestamps are recorded only for ready threads with completed runs and finite completion times. Tests cover unseen completions with command and monitor tasks. Priority: ⬆️ High
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: High
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
023bbThis change makes threads that leave a command running show their completion instead of Waiting. No merge-blocking risk is evident, and the author reports passing tests.
Security Architecture Review#
Security architecture risk: 🔵 Low · up to
023bbThe change affects completion indicators and alerts, not command execution or permissions. Existing environment identity checks and notification controls remain intact. Remaining uncertainty concerns older-server timestamps and unusual recovery states, rather than a demonstrated security regression.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
- inferred — The evidenced exposure is completion presentation and alerts for threads already included in the client's environment shells. The patch does not change command execution, provider ownership, credentials, or the environment and thread identities passed to notification actions.
Trust Boundaries and Controls
- observed — Thread titles continue to flow into existing toast descriptions and desktop notification bodies. Desktop presentation still requires enabled settings, an unfocused or hidden document, and granted browser permission. Notification tags and navigation remain bound to the owning environment and thread; these sinks and controls are unchanged by the PR.
Resilience and Maintainability Implications
- observed — Holding work continues to park cancelled or interrupted runs as it could before the change, while failed status remains explicitly protected. Notification deduplication and reconnect baselining are also unchanged. Legacy shells still substitute updatedAt for an omitted completion timestamp; stability of that producer timestamp was not established.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Title check ✅ Passed The title clearly and concisely describes the primary fix: showing an unseen completion when a thread leaves a shell running. Description check ✅ Passed The description includes all required sections, explains the problem and change, documents scope and approval, and provides focused verification results, screenshots, limitations, and agent attributio… Linked Issues check ✅ Passed Issue [ #14872] requires a finished, unread sidebar state when only a background shell remains.shellRuntimeandderiveThreadRuntimenow usebackgroundWorkHoldsCompletion, so command-only work do…Out of Scope Changes check ✅ Passed The changes stay within the client-side status presentation scope for [ #14872]. Runtime derivation, sidebar presentation, notification completion tracking, shared mobile presentation coverage, and rel…- Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Autopilot is currently an internal CodeRabbit preview.
Comment `@coderabbitai help` to get the list of available commands.macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed