Repository navigation
feat(web): a finished turn's fold row names what the turn did - #595
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NoahHendrickson
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
- The summary counts work the turn threw away or that stayed visible.
forkSegmentSummaryreads every work entry in the segment, and the run's group includes superseded attempts (deriveTurnFoldsdoesn't skipattempt.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. - Failed or declined edits read as done.
actionsLinekeeps only.summaryfromsummarizeToolGroupand dropshasFailure. It never filtersworkEntryDisplayIndicatesToolFailure. 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
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 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. |
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>
…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>
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:
Checking newer hold overwrite · 31s. Only Codex does this; every Codex thought opens with a**Heading**line.Changed 1 file, ran 4 commands · 25sorChanged 3 files, ran tests · 4m 2s.custom/backgroundWorkActivity.logic.ts(newcommandWorkDone). An unknown command is only counted, never shown as written.How it looks
labelfield; the summary rides beside it asforkSummary.How often each provider gets which label (live data, runs since Nov 15)
The owner is happy with the action summary and declined a generated summary for the fallback turns.
Where the code lives
custom/forkTurnFoldSummary.logic.tsandcustom/ForkTurnFoldLabel.tsx, plus fenced hooks inMessagesTimeline.logic.tsandMessagesTimeline.tsx.fork-turn-fold-summary.Fork/Turn fold label.GuestPage.browser.test.tsx, whose button name is now the summary.Reviewed with sol-loop: 3 rounds with GPT-6.1 Sol. Sol verdict: approved
🤖 Signed: Claude Opus 5.5 (
claude-opus-5-5) via Claude Codegpt-6.1-sol, high effort) via Codex: sol-loop review, 3 rounds; its one finding was fixed🤖 Generated with Claude Code