Reduce chat timeline activity rerenders#2660
Merged
Merged
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Contributor
Author
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
Contributor
ApprovabilityVerdict: 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What Changed
MessagesTimelineRowdata.artifacts/react-scan-before/settings-connections-before.webmartifacts/react-scan-after/settings-connections-after.webmWhy
React Doctor highlighted the chat timeline as a large/hot component area. A manual pass found that
TimelineRowActivityCtxcarried 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 letscomputeStableMessagesTimelineRowspreserve 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
Verification:
bun fmtbun lintbun typecheckbun run test --filter=@t3tools/web -- MessagesTimeline.logic.test.tsNote
Reduce chat timeline rerenders by moving streaming state into row derivation
completionSummary,activeTurnInProgress, andactiveTurnIdout of the sharedTimelineRowActivityCtxcontext and intoderiveMessagesTimelineRows, so each row carries its ownassistantCopyStreamingandcompletionSummaryfields.assistantCopyStreaming=true, preventing all assistant copy buttons from re-rendering on every streaming update.isRowUnchangedto 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
TimelineRowActivityCtxand onto each derivedMessagesTimelineRow.deriveMessagesTimelineRowsnow acceptscompletionSummary,activeTurnInProgress, andactiveTurnId, and computes per-rowassistantCopyStreamingandcompletionSummary;AssistantCopyButton/AssistantCompletionDividerconsume 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.