Skip to content

Reduce chat timeline activity rerenders#2660

Merged
juliusmarminge merged 4 commits into
mainfrom
cursor/react-performance-optimization-d91c
May 12, 2026
Merged

Reduce chat timeline activity rerenders#2660
juliusmarminge merged 4 commits into
mainfrom
cursor/react-performance-optimization-d91c

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 12, 2026

What Changed

  • Moved active-turn copy visibility and completion summary into the derived MessagesTimelineRow data.
  • Narrowed the timeline activity context to only the revert button state that truly remains global.
  • Added coverage proving only the active assistant turn is marked streaming for copy controls.
  • Added React Scan recordings:
    • Before: artifacts/react-scan-before/settings-connections-before.webm
    • After: artifacts/react-scan-after/settings-connections-after.webm

Why

React Doctor highlighted the chat timeline as a large/hot component area. A manual pass found that TimelineRowActivityCtx carried active-turn and completion-summary state used by assistant row controls, which forced unrelated assistant copy buttons to observe context changes even when their row data was stable. Projecting those values onto row data lets computeStableMessagesTimelineRows preserve unaffected row identity and limits React work to rows whose rendered state can actually change.

UI Changes

No intentional visual changes. The committed React Scan before/after recordings show the app running with React Scan enabled during the scan pass.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Verification:

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run test --filter=@t3tools/web -- MessagesTimeline.logic.test.ts
Open in Web View Automation 

Note

Reduce chat timeline rerenders by moving streaming state into row derivation

  • Moves completionSummary, activeTurnInProgress, and activeTurnId out of the shared TimelineRowActivityCtx context and into deriveMessagesTimelineRows, so each row carries its own assistantCopyStreaming and completionSummary fields.
  • Only the assistant row whose turn matches the active in-progress turn gets assistantCopyStreaming=true, preventing all assistant copy buttons from re-rendering on every streaming update.
  • Updates isRowUnchanged to include the two new fields, ensuring rows update correctly when these values change.

Macroscope summarized 91ae7e9.


Note

Medium Risk
Medium risk because it changes how assistant streaming state and completion summaries are derived and rendered, which could subtly affect copy-button visibility and divider labeling during active turns.

Overview
Reduces chat timeline rerenders by moving active-turn copy streaming state and completion divider summary text out of TimelineRowActivityCtx and onto each derived MessagesTimelineRow.

deriveMessagesTimelineRows now accepts completionSummary, activeTurnInProgress, and activeTurnId, and computes per-row assistantCopyStreaming and completionSummary; AssistantCopyButton/AssistantCompletionDivider consume these row fields, and stable-row equality (isRowUnchanged) accounts for them. Adds a test ensuring only the active assistant turn is treated as streaming for copy controls.

Reviewed by Cursor Bugbot for commit 91ae7e9. Bugbot is set up for automated code reviews on this repo. Configure here.

cursoragent and others added 2 commits May 12, 2026 16:10
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels May 12, 2026
@juliusmarminge juliusmarminge marked this pull request as ready for review May 12, 2026 18:17
Copy link
Copy Markdown
Contributor Author

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5478fd5. Configure here.

Comment thread apps/web/src/components/chat/MessagesTimeline.logic.ts Outdated
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 12, 2026

Approvability

Verdict: Approved

Performance refactor that moves computation from render-time context reads to row derivation time, reducing unnecessary React rerenders. The logic is equivalent and a test confirms correct behavior.

You can customize Macroscope's approvability policy. Learn more.

- Only attach `completionSummary` when the assistant completion divider is shown
- Add a regression test for non-divider assistant rows
@juliusmarminge juliusmarminge merged commit a41f489 into main May 12, 2026
11 checks passed
@juliusmarminge juliusmarminge deleted the cursor/react-performance-optimization-d91c branch May 12, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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.

2 participants