Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): a thread that left a shell running shows its unseen completion #14910

MergedMnigos(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/14910/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Fixes #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.
  • ThreadNotificationCoordinator treated "waiting on commands only" as settled; that state can no longer occur, so the branch is gone and alerts fire on ready as 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, dimmedAfter: thread A says Done, unread
Before: thread A's sidebar row reads Waiting and is dimmed while thread B is openAfter: thread A's sidebar row reads Done with the unread title style while thread B is open
Step on this branchObserved
Thread C ends its turn with a monitor on the rosterC reads Waiting, dimmed; A stays Done (capture)
Open thread AThe "Waiting on command" banner and Stop are still there (capture)
Go back to thread BA'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

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at ee255a5

      Macroscope'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).
    3. juliusmarminge added labelsmacroscope-review

    4. Review in Change Stack →

      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.ts
      • apps/mobile/src/features/threads/threadListV2.ts
      • apps/web/src/components/Sidebar.logic.test.ts
      • apps/web/src/components/Sidebar.logic.ts
      • apps/web/src/components/ThreadNotificationCoordinator.tsx
      • packages/client-runtime/src/state/entities.test.ts
      • packages/client-runtime/src/state/models.ts
      • packages/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.ts
      Runtime derivation uses backgroundWorkHoldsCompletion to 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.ts
      The 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: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 023bb

      This 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 023bb

      The 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 nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the primary fix: showing an unseen completion when a thread leaves a shell running.
      Description check✅ PassedThe 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✅ PassedIssue [#14872] requires a finished, unread sidebar state when only a background shell remains. shellRuntime and deriveThreadRuntime now use backgroundWorkHoldsCompletion, so command-only work do…
      Out of Scope Changes check✅ PassedThe 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.

Sign in to join this conversation.