Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): stop showing dead subagents as working after a restart #14630

Closedtheomilll(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/14630/headopened View on GitHub

Problem

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:

  1. Start a background subagent with Claude (Agent with run_in_background) and let the main turn end.
  2. Restart T3 Code while the subagent is still running.
  3. 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 90 subagent 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 --noEmit in apps/web passes.
  • 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

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

      Approvability

      Verdict: Approved at 7ceba40

      Macroscope'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.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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: 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

      agentSessionLive now returns true for running or connecting sessions, or when the thread shell reports non-null background liveness. This value is passed to foldSubagentActivities.

      Changes

      Agent session liveness

      Layer / File(s)Summary
      Update agent session liveness
      apps/web/src/components/ChatView.tsx
      agentSessionLive now 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: t3dotgg

      Merge Risk: 🔵 Low · up to 7ceba

      The 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 nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly and concisely describes the main fix: preventing dead subagents from appearing as working after a restart.
      Description check✅ PassedThe 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.
    4. juliusmarminge added labelsmacroscope-review

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

    6. juliusmarminge closed this

Sign in to join this conversation.