fix(clients): native subagent threads show when they are working #13614
t3code/codex-turn-mapping fromrefs/pull/13614/head·merged by juliusmarminge View on GitHubDepends on #13619: merge it first or together. Without it, a server restart mid-subagent leaves the child's runless root turn
running, and this PR would show that child as "Working 3h" forever.
Opening a provider-native subagent's thread (for example one of the three Claude Agent-tool subagents in an audit prompt) showed the task message and a work log, but no "Working for" timer, no live tool row, and no Thinking slot while the subagent was still running. The parent thread showed "3 working" at the same time.
Root cause. Provider-native subagent threads never get app runs (fixtures assert this on purpose via assertNoExtraAppRunsForProviderChildren). Their work is a single runless root_turn node whose status follows the subagent. Every working signal on web and mobile is derived from projection.runs, so the child always looked idle.
What changed#
packages/client-runtimederiveRunlessWorkStartedAt(projection): the start time of the thread's active runless root turn, or null. It reads nodes the child projection already has, so it adds no websocket payload.- Web (
ChatView):isWorkingandactiveWorkStartedAtalso come from that helper, which brings back the working header and its timer.phaseis unchanged, so stop, queue, steer, and interrupt stay run-only (a native subagent can't be stopped from its own thread).MessagesTimelinegetsrunlessWorkActive, so runless entries count as the live response while the root turn is active: a running tool becomes the live activity row, and the Thinking slot fills the gap between tools. - Mobile:
activeWorkStartedAtfalls back to the same helper, which brings back the floating working timer and the Thinking row.deriveThreadFeedPresentationtakes an explicitrunlessWorkActiveflag (as web does): a runless tail group goes live only for runless subagent work, never for a normal thread in the optimistic-send window or with a queued latest run. Null-run activities were already matched against the nullactiveRunId. - Replay-fixture invariant (
assertProviderNativeSubagentRootTurns, run after every fixture). For each provider-native subagent it checks that the child iscreationSource: "provider", is forked from the subagent node, has no runs, and has only runless root turns. It also checks that the root turn isrunningbefore the child's first non-prompt item, and that its active/terminal sequence matches the subagent's (including the ClaudeSendMessageresume inclaude_background_subagent_lifecycle, which goes running → completed → running → completed). All 23 native subagents recorded in 13 fixture/provider variants (Claude, Codex v1/v2/nested/continue, Cursor, Grok, OpenCode) satisfy it.
Delegated delegate_task children have real runs, so their behavior doesn't change.
Verification#
packages/client-runtime:vp test run src/state/threadExecution.test.ts src/state/entities.test.ts: 39 passed. New cases: running root turn gives its start time with a null runtime (still no interrupt); each terminal status andidlegives null; a run-owned root turn is ignored.apps/web:vp test run src/components/chat/MessagesTimeline.logic.test.ts src/session-logic.test.ts: 176 passed. New cases: a runless running tool becomes the livework-liverow under the working header, and reads as settled history once the subagent stops; runless entries are not live on a thread that has a run. I reverted the logic change and confirmed the first case fails.apps/mobile:vp test run src/lib/threadActivity.test.ts: 72 passed. The runless live-tail case fails without the fix; a second case checks that a normal thread in the optimistic window (no run, or a queued latest run) keeps its runless tail settled, and it fails without therunlessWorkActivegate.apps/server:vp test run src/orchestration-v2/testkit/OrchestratorReplayFixtures.integration.test.ts: 87 passed with the new invariant.tsc --noEmiton client-runtime, web, mobile, server: no errors.vp linton touched files: no new findings.vp run knip:check: clean.- Not run: browser, desktop, or simulator checks (no dev servers, per maintainer rule), and repo-wide checks.
Model: Claude Opus 5.5 (Claude Code)
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Approved at
6a93faeMacroscope's review found this PR approvable — This is a targeted client presentation fix that surfaces existing runless subagent activity in web and mobile without changing ordinary run-backed behavior or persistence contracts. The added tests cover active, terminal, and optimistic-send cases, while server changes are limited to replay-fixture validation.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged thisb64278c
juliusmarminge closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result:
6a93fae· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.