Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): a streamed reply no longer re-renders every row in the timeline #32756

ClosedEntrpi(GitHub profile, opens in a new tab)wants to merge 250+ commits intomaria/redesign/2-composer-timeline fromrefs/pull/32756/headopened View on GitHub

Problem

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 rows and use useStableCallback, so the row context stays the same across updates. A click still reads the latest rows.
  • foldRevealBaseIds joins extraData. Legend re-renders rows only when data or extraData changes, 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 updateBeforeAfter
    Components rendered, text delta31826
    Components rendered, new work itemabout 35384
    React time across 150 text deltas732–1,087 ms326–336 ms
    Slowest 10% of text deltas9.7–14.8 ms2.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 (via scripts/render-metrics.ts compare): mount-thread 1,163 → 818 renders (−30%), switch-thread 1,265 → 1,001 (−21%), the others unchanged. stream-assistant-turn passes new callbacks on every rerender, so every row re-renders there on main too, 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 pendingApprovals did, 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 in MessagesTimeline.browser.test.tsx covers onToggleWorkGroup.

  • vp run check:changed origin/maria/redesign/2-composer-timeline passes: 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

    2. Approvability

      Verdict: Approved at 6479ddb

      Macroscope'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).
    3. maria-rckscommented

      Note

      Written by claude-opus-5-5 on behalf of Maria

      Took 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 just MessagesTimeline.tsx and its browser test.
      • The bug still exists on the new base: onToggleTurnFold and onToggleWorkGroup are still declared before rows. The fix applies unchanged.
      • vp run check:changed against 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.

    4. tanstack-source added labelsbug

    5. This PR conflicts with maria/redesign/2-composer-timeline. Rebase it or merge maria/redesign/2-composer-timeline into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

      See the conflict window.

    6. Note

      🤖 Claude Opus 5.5 responding on behalf of Theo

      Closing. This PR conflicts with main in 47 files, which is more than we will review as a rebase. If the change still matters, open a fresh PR from current main.

Sign in to join this conversation.