Optimize chat timeline render stability#2982
Draft
cursor[bot] wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Contributor
|
🚀 Expo continuous deployment is ready!
|
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
MessagesTimelineby replacing render-time ref cache mutation with guarded render-state structural sharing.Why
react-doctorflaggedMessagesTimeline.tsxfor performance errors (refsandstatic-components) that prevented React Compiler optimization on a hot streaming chat path. The new implementation preserves unchanged row references while avoiding ref reads/writes during render, and makes work-log icon rendering compiler-friendly.UI Changes
No intentional visual UI change. React Scan recordings captured the same timeline pulse interaction before and after:
react_scan_timeline_before.mp4react_scan_timeline_after.mp4Video review confirmed the before recording highlighted larger timeline/message wrappers, while the after recording localized highlights to the changing streaming text/timer.
Checklist
Validation:
react-doctor ./apps/web --json --no-score --blocking none(MessagesTimeline.tsx: 3 errors before, 0 errors after)vp checkvp run typecheckvp test run --passWithNoTests --project unit src/components/chat/MessagesTimeline.test.tsxNote
Optimize chat timeline render stability in
MessagesTimelineuseStableRowsto cache aStableRowsSnapshotin React state and update it when the input rows reference changes, replacing the previoususeMemo/ref approach for more reliable structural sharing.createStableRowsSnapshotas a standalone helper to package stable row computation for reuse.WorkToneIconGlyphandWorkEntryIconGlyph, which return rendered JSX instead of icon types;workToneIconClassnow returns only a CSS class string.Macroscope summarized 53eea2a.