Skip to content

fix(clients): subagent threads fold their work like other threads - #13725

Merged
juliusmarminge merged 1 commit into
t3code/codex-turn-mappingfrom
v2/subagent-thread-folds
Sep 26, 2026
Merged

juliusmarminge merged 1 commit into
t3code/codex-turn-mappingfrom
v2/subagent-thread-folds

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

A provider-native subagent thread (a Claude/Codex subagent's child thread) showed every command and thought expanded, with no "Worked for …" row. Turn folds are keyed by run, and these threads have no runs by design (#13614): the whole child is one runless root turn, and each SendMessage resume adds another user prompt to it (#13668).

What changed

In a thread without runs (latestRun === null), each user prompt now provides the fold key for its response (runless:<prompt entry id>). That key stands in for the missing runId of the items after it, so web (deriveTurnFolds) and mobile (deriveThreadFeedRunFolds) apply their normal fold rules per subagent run:

  • The final assistant message stays visible, and the prompt stays above the fold.
  • The duration runs from the prompt to the answer.
  • A response that is still working (runless work active) stays open, and so does one with a failed top-level error item.
  • Expand/collapse state is keyed per prompt, so each run opens on its own.

Threads with runs are unchanged, because the runless key is only used when there is no run at all. No contract or server change. I did not use providerTurnId or the node id as the key: every child item has providerTurnId: null, and every item shares the one root node, so neither separates a launch from a resume.

Verification

  • apps/web: vp test run src/components/chat/MessagesTimeline.logic.test.ts src/components/chat/MessagesTimeline.test.tsx: 207/207 pass. The new test builds a child thread shaped like the live "Review src/math.ts" projection (no runs, one root node, a launch prompt and a resume prompt). It covers settled, expanded, resume-running, and failed-resume. It fails without the fix.
  • apps/mobile: vp test run src/lib/threadActivity.test.ts: 73/73 pass, including the same case for the mobile feed.
  • One existing web test (shows a provider-native subagent's runless tools as live work while it works) expected a settled runless response to stay unfolded. It now expects the fold, the same as a settled run with no answer on a normal thread.
  • vp exec tsc --noEmit -p . in apps/web and apps/mobile: no errors or warnings. vp lint on the touched files is clean. vp run knip:check is clean.
  • Not run: a live client pass (no browser or simulator verification).

Model: Claude Opus 5.5 (Claude Code)

🤖 Generated with Claude Code


Devin Review

A provider-native subagent thread has no runs, and turn folds were keyed
by run, so its work never folded behind "Worked for ...". In a thread
without runs, each prompt now keys its own response, which folds with
the usual rules: the final answer stays visible, a failed or working
response stays open, and the duration runs from the prompt to the answer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 26, 2026
terminalAssistantMessageIds,
latestRun: input.latestRun ?? null,
unfoldedRunIds: new Set([...activeVisualResponseRunIds, ...failedRunIds]),
isWorking: input.isWorking,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium chat/MessagesTimeline.logic.ts:1106

A settled runless response is unfolded whenever the broad input.isWorking flag is true, including during sending, connecting, checkpoint reverts, or compaction, so its existing fold is lost during those transient states. Pass the runless-specific input.runlessWorkActive state to deriveTurnFolds instead.

Suggested change
isWorking: input.isWorking,
isWorking: input.runlessWorkActive === true,
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/components/chat/MessagesTimeline.logic.ts around line 1106:

A settled runless response is unfolded whenever the broad `input.isWorking` flag is true, including during sending, connecting, checkpoint reverts, or compaction, so its existing fold is lost during those transient states. Pass the runless-specific `input.runlessWorkActive` state to `deriveTurnFolds` instead.

@macroscopeapp

macroscopeapp Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — This is a focused presentation bug fix that adds runless subagent work folding in web and mobile while preserving active and failed responses, with targeted test coverage. An unresolved medium-severity finding remains about transient isWorking states unfolding settled runless responses.

Not approved because:

  • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 4.9 KiB — 6.8 KiB ✅
Codex Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.1 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 20.4 KiB — 29.3 KiB ✅
Codex Live turn messages — 1 — 8 ✅
Claude Total thread wire — 4.9 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 20.8 KiB — 29.3 KiB ✅
Claude Live turn messages — 2 — 8 ✅

Baseline: unavailable · PR result: de4a68a · Source CI: success

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

  • Codex decoded thread snapshot: 106.1 KiB
  • Claude decoded thread snapshot: 106.4 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@juliusmarminge
juliusmarminge merged commit bb89d58 into t3code/codex-turn-mapping Sep 26, 2026
24 of 25 checks passed
@juliusmarminge
juliusmarminge deleted the v2/subagent-thread-folds branch September 26, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant