Skip to content

feat(web): a finished turn's fold row names what the turn did - #595

Merged
NoahHendrickson merged 5 commits into
customfrom
t3/turn-work-log-labels
Nov 29, 2026
Merged

NoahHendrickson merged 5 commits into
customfrom
t3/turn-work-log-labels

Conversation

@NoahHendrickson

@NoahHendrickson NoahHendrickson commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

A finished turn folds its work into a row that only said "Worked for 10s". The owner wanted it to say what actually happened in the turn.

The label is derived on the client from work already loaded, with no model call. It picks the first of these that applies:

  1. The last thought's heading, when the provider writes one: Checking newer hold overwrite · 31s. Only Codex does this; every Codex thought opens with a **Heading** line.
  2. The turn's actions, at most two clauses: Changed 1 file, ran 4 commands · 25s or Changed 3 files, ran tests · 4m 2s.
    • Commands are named through the shell reader in custom/backgroundWorkActivity.logic.ts (new commandWorkDone). An unknown command is only counted, never shown as written.
    • T3 tools and integrations use upstream's own summary words.
    • Only work the row folds away counts. A superseded attempt's work, tools left visible below the row, and tools that failed or were declined are all skipped.
  3. Upstream's label in three cases:
    • A turn with only plain-prose thoughts (Claude, Gemini) and no named tools.
    • A turn you stopped ("You stopped after…").
    • A turn whose work the server deferred (over 150 work items), until opening the row loads that work.

How it looks

  • The summary truncates to one line; the time always shows.
  • On a row above a steer, the time is that segment's own. Steer segments ("Continued for") get the same treatment.
  • The row keeps upstream's label field; the summary rides beside it as forkSummary.
  • It's memoized per turn, so streaming doesn't re-summarize history.

How often each provider gets which label (live data, runs since Nov 15)

Provider Runs Heading Actions Falls back
Codex (Nov) 864 550 303 11
Claude 5,998 0 5,441 about 9%
Gemini 429 0 407 about 5%

The owner is happy with the action summary and declined a generated summary for the fallback turns.

Where the code lives

  • Fork code: custom/forkTurnFoldSummary.logic.ts and custom/ForkTurnFoldLabel.tsx, plus fenced hooks in MessagesTimeline.logic.ts and MessagesTimeline.tsx.
  • Manifest entry: fork-turn-fold-summary.
  • Tests: a guard test and a logic test.
  • Story: Fork/Turn fold label.
  • Upstream test: one fenced line in GuestPage.browser.test.tsx, whose button name is now the summary.
  • Figma kit: the "Work log toggle" (352:396) description is updated.
  • Mobile's fold row is unchanged.

Reviewed with sol-loop: 3 rounds with GPT-6.1 Sol. Sol verdict: approved

  • Round 1 found that a stopped turn's steer segments still got a summary; fixed.
  • Round 3 checked the fixes for the PR review comments. 11 of the 12 comments are fixed; the mixed-language comment was declined, because fork copy stays English.

🤖 Signed: Claude Opus 5.5 (claude-opus-5-5) via Claude Code

  • GPT-6.1 Sol (gpt-6.1-sol, high effort) via Codex: sol-loop review, 3 rounds; its one finding was fixed

🤖 Generated with Claude Code

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 29, 2026

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Code-quality review of 59eacf4 (base e017950).

The feature is well placed. The summarizer lives in custom/, it reuses the shell reader through commandWorkDone rather than parsing commands a second time, and the Record<Work, …> table is exhaustive. I'm not approving yet, because the way it plugs into upstream carries a dead second representation and more fence surface than the feature needs.

1. The rewritten label is never read. Delete it, and the upstream test fence goes with it. (structural)
forkSegmentSummary overwrites TurnFold.label with forkTurnFoldLabel(forkSummary). But the only place a turn-fold row's label is rendered (MessagesTimeline.tsx, TurnFoldTimelineRow) is the branch taken when forkSummary is absent. Nothing else reads it: useThreadFindPositionReader matches on runId, and useTimelineRows only passes it through. So every summarized row carries the same data twice, and the row-type comment has to explain it ("which then reads the same, joined"). That duplicate is also why MessagesTimeline.logic.test.ts needs a fence that rebuilds upstream's English copy (`Worked for ${row.forkSummary.duration}`).
Fix: leave label as upstream's, return only { forkSummary }, and delete forkTurnFoldLabel, the Pick<TurnFold, "label" | "forkSummary"> return type, and the upstream test fence. The guard test should assert on forkSummary and keep label as upstream's.

2. Move the segment closure and the stopped-turn check out of deriveTurnFolds. (spaghetti growth in a 3.3k-line upstream function)
The PR defines a 12-line closure inside upstream's per-group loop and writes isLatestInterruptedTurn ? null : forkSegmentSummary(...) at both call sites. The steer site also calls formatDuration(segmentMs, resolve) a second time, after upstream has already formatted it for the label. Export one helper from the custom module that takes TimelineEntrys, filters the work entries, and returns { forkSummary } | null. Then gate it once, for example const forkSummarize = isLatestInterruptedTurn ? () => null : (entries, duration) => …, so each call site is a one-line spread. The rule "a turn you stopped keeps saying so" then lives in one place, not two.

3. The TSX fence splits a ternary across fence boundaries. (legibility, fence fragility)
In TurnFoldTimelineRow the fence opens before the ternary, closes inside the else branch around upstream's <span>, and reopens after it to change the chevrons. It's hard to read, and the next upstream merge will conflict there. Instead, let ForkTurnFoldLabel take label, forkSummary and error and own the fallback (render upstream's span when forkSummary is absent). The upstream <span> is then replaced by one fenced line, and the guard's regex has one fixed shape to pin.

4. actionsLine partitions in three passes and edits translated text by hand. (direct code over incidental control flow)
It runs toolGroupAction(entry) in three separate filter passes, then picks the command clause with a nested ternary (done.length > 0 ? done : commands.length > 0 ? […] : []). Classify each entry once (group by action into edits, commands and named), then build the clauses as a flat list of clause | null. Separately, the charAt(0).toLowerCase() / toUpperCase() stitching runs on strings that resolve may already have translated, alongside English-only DONE words. In any non-English locale that yields mixed-language, wrongly cased labels. If fork copy stays English, say so in one place (resolve the summaries in English, or build the clauses from the counts). Don't case-fold localized output.

5. THOUGHT_HEADING copies a regex from liveThoughtLine. (canonical helper drift)
liveThoughtLine in packages/client-runtime/src/work-log/presentation.ts uses the same pattern. If the two ever disagree, the fork's test() matches a thought but liveThoughtLine falls back to its first prose sentence, and the fold shows a sentence from Claude's prose as if it were a heading. Use a capture group once (THOUGHT_HEADING.exec(detail)?.[1]) and clean only that, so the heading match isn't written twice.

6. The WeakMap cache only partly checks the identity assumption it relies on. (magic)
It is keyed on the last entry, then checked against the first entry, the count and resolve. That checks some identity and trusts the rest: an entry changed in the middle with the same first, last and count returns a stale summary. Either rely on identity fully (settled turns keep their entry objects, per the comment), or measure whether summarizing is a real cost next to the O(n) work deriveTurnFolds already does for every turn on every derive. If it isn't, delete the cache. Of the six this has the lowest conviction.

File size: MessagesTimeline.logic.ts (3302 lines) and MessagesTimeline.tsx (2169) were already over 1k lines, and this PR adds about 55 lines across them. No threshold is crossed. Items 1–3 together would remove most of those lines.


Reviewed commit 59eacf4 · 🤖 Claude Opus 5.5 (claude-opus-5-5) via Claude Code

@NoahHendrickson NoahHendrickson left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Correctness review of 59eacf4 (base e017950). This doesn't repeat the code-quality review already on this commit (label duplication, fences, i18n stitching, cache). These five are about what the label says.

Important

  1. The summary counts work the turn threw away or that stayed visible. forkSegmentSummary reads every work entry in the segment, and the run's group includes superseded attempts (deriveTurnFolds doesn't skip attempt.status === "superseded"). It also includes trailing failed or in-progress tools after the terminal message, which the fold leaves visible. Example: the first attempt edits 3 files and is superseded, and the retry only reads. The row says "Changed 3 files · 40s", and the fork's inline diff stat beside it shows no changes.
  2. Failed or declined edits read as done. actionsLine keeps only .summary from summarizeToolGroup and drops hasFailure. It never filters workEntryDisplayIndicatesToolFailure. Example: the user declines the turn's only file-change approval, and the row says "Changed 1 file · 12s".

Nits
3. A deferred turn's label flips once its work loads. threadHistoryMerge.ts:172 deletes deferredWork when the last page arrives. Expanding a 200-item turn turns "Worked for 3m" into "Changed 40 files, ran tests · 3m" under the click, and a reload turns it back. The manifest says deferred turns keep upstream's label.
4. On a steered turn, the top row's time doesn't match its text. The top row's time still covers the whole turn, steers included, but its text now describes only the first segment. So "Changed 1 file · 30s" sits above "Ran tests · 25s".
5. ForkTurnFoldLabel's error can't show. error exists only when the fold has deferredWorkItemIds, and any deferred entry makes summarize return null. That row then renders upstream's span, so the LoadError story shows a state the app never reaches.

I read the code but didn't run the tests: this worktree's dependencies aren't installed.


Reviewed commit 59eacf4 · 🤖 Claude Opus 5.5 (claude-opus-5-5) via Claude Code

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 7a6bbc1 · PR result: 73ff3ea · 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: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

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

xxxxxxxxxxxxx and others added 2 commits November 29, 2026 12:37
Keeps upstream's label on the row, leaves out superseded attempts and failed
or declined tools, gives the top row above a steer its own time, and lets
ForkTurnFoldLabel own the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NoahHendrickson
NoahHendrickson merged commit ffc58d3 into custom Nov 29, 2026
49 of 51 checks passed
@NoahHendrickson
NoahHendrickson deleted the t3/turn-work-log-labels branch November 29, 2026 18:10
NoahHendrickson pushed a commit that referenced this pull request Nov 29, 2026
…ry types

Point #595's fold summary at the shared forkBackgroundWork, have
threadRowLiveState take the two facts it reads (settled, waiting) with web
mapping its sidebar status, move the library size limits beside their copy,
and share one StartTurnCommand between the coordinator's two halves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants