fix(web): a streamed reply no longer re-renders every row in the timeline #32756
maria/redesign/2-composer-timeline fromrefs/pull/32756/head·opened View on GitHubProblem#
Since #30478, every row in the timeline re-renders on every update. Each streamed text delta of a reply re-renders all mounted rows, not just the reply. On a long thread with a live turn that is 318 component renders per delta, where the reply alone needs 26.
Change#
#30478's fold reveal made onToggleTurnFold and onToggleWorkGroup read rows, which ConversationTimeline declares further down. The React Compiler can't memoize a closure that reads a later binding, so both toggles were new on every render. So were the row context built from them (sharedState), renderItem and extraData. Legend re-rendered every row, and every row that reads the context re-rendered with it.
- The reveal helper and the two toggles move below
rowsand useuseStableCallback, so the row context stays the same across updates. A click still reads the latest rows. foldRevealBaseIdsjoinsextraData. Legend re-renders rows only whendataorextraDatachanges, and the per-render churn had been doing that for the reveal. Without it, "keeps the worked-for heading in place when expanded at the bottom" fails.
main doesn't have this, since its toggles don't read rows: 24 component renders per delta.
@maria-rcks: if you'd rather fold this into the stack yourself, the diff is small, and either way is fine with me.
Scope and approval#
A focused fix of a render regression, with no visible change, on the branch #30478 merged into. It qualifies as a very small fix of an obvious bug: rows re-render although nothing in them changed.
Verification#
New test in
MessagesTimeline.browser.test.tsx, "leaves earlier rows alone while a reply streams". An HTML render row counts its renders while a later reply streams 10 deltas: before the fix it goes from 3 to 13; with it, it stays at 3.Render counts in headless Chromium (dev build), with a 2,000-item thread and a live turn of 200 settled edits:
Per update Before After Components rendered, text delta 318 26 Components rendered, new work item about 353 84 React time across 150 text deltas 732–1,087 ms 326–336 ms Slowest 10% of text deltas 9.7–14.8 ms 2.5–2.9 ms The milliseconds are from React's development build, which exaggerates them. The render counts hold in any build.
The render scenarios in
test/renderScenarios.renders.tsx(viascripts/render-metrics.ts compare): mount-thread 1,163 → 818 renders (−30%), switch-thread 1,265 → 1,001 (−21%), the others unchanged.stream-assistant-turnpasses new callbacks on every rerender, so every row re-renders there onmaintoo, and it can't show this.Real client: a dev build of the full redesign stack with this commit on top, using a Replay (dev) showcase turn. I read React's fibers read-only during the stream. Before the fix, the row context changed on all 23 updates, each time naming the toggles, and the prompt row re-rendered 11 times. After the fix, the toggles never changed; only
pendingApprovalsdid, while the approval request arrived. I also opened and closed a turn fold, which ran its reveal animation and cleared it, and expanded and collapsed a work entry. The background-group test inMessagesTimeline.browser.test.tsxcoversonToggleWorkGroup.vp run check:changed origin/maria/redesign/2-composer-timelinepasses: format, lint, knip, typecheck, the tests beside the change, and React Compiler coverage.
Claude Opus 5.5 via Claude Code, in T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Note
Written by
claude-opus-5-5on behalf of MariaTook this over to clear the conflict with
maria/redesign/2-composer-timeline.- The base branch was rebased again (now
cb2ce53126, which adds main's Orchestrator and GitActionsControl changes). I merged it with a merge commit, no rebase. The resolution keeps the base's tree and reapplies only this PR's change, so the diff is again justMessagesTimeline.tsxand its browser test. - The bug still exists on the new base:
onToggleTurnFoldandonToggleWorkGroupare still declared beforerows. The fix applies unchanged. vp run check:changedagainst the base passes: format, lint, knip, typecheck, 3 test files (including "leaves earlier rows alone while a reply streams"), and React Compiler coverage.
No code changes beyond the merge. No open review findings.
- The base branch was rebased again (now
tanstack-source added labelsbug
This PR conflicts with
maria/redesign/2-composer-timeline. Rebase it or mergemaria/redesign/2-composer-timelineinto it. If it still conflicts after 7 days with no activity, it will be closed automatically.See the conflict window.
github-actions[bot](GitHub profile, opens in a new tab) added labelsneeds-rebase
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Closing. This PR conflicts with
mainin 47 files, which is more than we will review as a rebase. If the change still matters, open a fresh PR from currentmain.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Approvability#
Verdict: Approved at
6479ddbMacroscope's review found this PR approvable — This change reduces unnecessary timeline-row rendering during streamed replies while retaining fold-reveal updates. Its effects are limited to client-side rendering, with no changes to product defaults or persistent data.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).