fix(web): stop showing dead subagents as working after a restart #14630
main fromrefs/pull/14630/head·opened View on GitHubProblem#
When the T3 server restarts while a background subagent is running, the restart kills the provider process and the subagent with it. The sidebar correctly stops showing the thread as Working. The Agents panel still shows the dead agent as running: its timer keeps counting, the footer reads "1 working", and the timeline says "Kicked off 1 subagent". The panel and the sidebar disagree, and the panel is the one that is wrong.
To reproduce:
- Start a background subagent with Claude (
Agentwithrun_in_background) and let the main turn end. - Restart T3 Code while the subagent is still running.
- Open the Agents panel on that thread.
Change#
foldSubagentActivities already marks active agents as interrupted when sessionLive is false. ChatView set sessionLive only from the session phase, so it went false only for a stopped or failed session. Server startup reconciliation leaves idle ready sessions as they are, because they resume on the next message. After a restart, the session still reads ready and the dead agents stay live.
The panel now treats agents as live while the turn is running or connecting, or while the shell reports backgroundLiveness. The sidebar and the "agent working" composer banner already read that server signal. The server fills it from the same task.* events the fold reads, and it starts empty after a restart. One signal now drives all three surfaces, so they cannot disagree.
Mobile has no Agents panel, so this change does not affect it.
Scope and approval#
This is a very small, focused fix for an obvious bug. A dead agent shows as working forever, and the code already intends to prevent that (see the sessionLive comment in subagentRuntime.ts). The change is one condition in ChatView.tsx, with no server or contract changes.
Verification#
I ran a dev server from this branch against a copy of a real database. The copy contains a thread whose subagent was killed by a restart: it has a task.started row with no terminal row and a ready session. I drove the web app with a headless Chromium.
- Before (latest
main): the Agents panel shows the dead agent running at 31m 37s and climbing, with "1 working". The sidebar shows no Working state. - After: the same thread shows the agent as Stopped, with "12 settled" and "Ran 1 subagent".
- Live background subagent with Claude Opus 5.5, after the fix: the turn launched a background
sleep 90subagent and ended. The sidebar showed Working, the banner showed "1 agent working", and the panel showed the agent running. I repeated the check with Codex (GPT-6-Astra) and got the same result. After the subagent finished, the panel settled to idle. tsc --noEmitinapps/webpasses.vp test run packages/client-runtime/src/state/subagentRuntime.test.ts: 47 of 47 tests pass.
I did not add a unit test. The change is one condition inside a component, and the fold's interruption behavior already has tests. I did not test mobile, because it has no Agents panel.
| Before (main) | After (this PR) | Live background subagent (this PR) |
|---|---|---|
Done with Claude Opus 5.5 in Claude Code, running inside T3 Code.
- 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:XS
Approvability#
Verdict: Approved at
7ceba40Macroscope's review found this PR approvable — The change is limited to deriving subagent display liveness in the web UI, preserving active-turn behavior while using the server’s restart-cleared background signal to stop stale agents from appearing active. It introduces no schema, deployment, security-sensitive, or configuration-default changes.
Notes:
- Diff unchanged. Approvability was decided on eligibility alone.
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:
cc59c743-bc43-4b18-8f65-5c31c1962e7c📥 Commits
Reviewing files that changed from the base of the PR and between bed69f6ea41dab13ec37afbaaa2c911a19865f7a and 7ceba405398dbb43cc236d78a46453887483c785.
📒 Files selected for processing (1)
apps/web/src/components/ChatView.tsx
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#
agentSessionLivenow returns true for running or connecting sessions, or when the thread shell reports non-null background liveness. This value is passed tofoldSubagentActivities.Changes#
Agent session liveness
Layer / File(s) Summary Update agent session liveness
apps/web/src/components/ChatView.tsxagentSessionLivenow checks for a running or connecting phase, or non-null shell background liveness. Idle sessions without background liveness no longer count as live.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~5 minutes
Change: Bug fix
Suggested reviewers:
t3dotggMerge Risk: 🔵 Low · up to
7cebaThe Agents panel can still show a dead subagent as running while unrelated monitoring work continues. This is a bounded status inconsistency; merge with owner awareness or follow up on agent-specific liveness.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation 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. Title check ✅ Passed The title clearly and concisely describes the main fix: preventing dead subagents from appearing as working after a restart. Description check ✅ Passed The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains reproduction steps, implementation details, scope justification, before/after behavior… - 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.juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition.
This PR changes ChatView agentSessionLive and deriveAgentPanelModel using V1 backgroundLiveness. Those paths are absent from current ChatView; V2 projects child lifecycle on the server.
Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved.
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed