Reduce timeline row rerenders#2498
Conversation
|
@cursor pls resolve conflcits |
|
The PR is now MERGEABLE (no more conflicts). The Resolved the merge conflicts by rebasing the branch onto the latest
Both changes are now preserved. All checks pass ( |
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
7bad53f to
6c17b08
Compare
ApprovabilityVerdict: Approved Pure React performance optimization that splits context state to reduce rerenders and extracts inline components into named functions. No behavioral changes - same data flows through same rendering logic, just reorganized for better memoization. You can customize Macroscope's approvability policy. Learn more. |
Brings in: server CLI submodule split (pingdotgg#2545), process/trace diagnostics views (pingdotgg#2532), JetBrains editor support (pingdotgg#2475), MessagesTimeline render optimizations (pingdotgg#2527, pingdotgg#2498), git/terminal test stabilization (pingdotgg#2540), keybindings settings editor (pingdotgg#2533), and provider update advisories (pingdotgg#2312). Conflict resolutions: - packages/contracts/src/settings.ts: kept aa's diffFontFamily and terminalFontFamily alongside upstream's dismissedProviderUpdateNotificationKeys. - apps/desktop/src/clientPersistence.test.ts: same shape, fixture mirrors the schema. - apps/web/src/components/settings/SettingsPanels.tsx: kept both import groups (FontPicker from aa, ProviderUpdateLaunchNotification.logic from upstream). - apps/web/src/localApi.test.ts: extended both fixtures with diffFontFamily and terminalFontFamily so the merged ClientSettings shape typechecks against the strict desktop bridge contract. Pre-existing aa typecheck issues fixed at the root so the merge commit is green: - apps/desktop/src/electron.d.ts: declaration-merge "local-fonts" into Electron's Session.setPermissionRequestHandler permission union (the Electron 40 typings omit it even though the runtime supports it). - apps/web/src/components/DiffPanel.tsx: conditionally spread style on Virtualizer instead of passing undefined, satisfying exactOptionalPropertyTypes.


What Changed
MessagesTimelinecontext into stable shared state and activity-only state.Why
react-doctorand a manual pass pointed to the chat timeline as a hot rendering path. A temporaryreact-scanharness showed static timeline rows rerendering during active-turn state changes:TimelineRowContentrendered 137 times across the recording.TimelineRowContentrendered 43 times across the same recording.Heavy markdown/code-rendering counts stayed flat, while the activity-sensitive leaf controls continued to update.
UI Changes
No intended visual changes.
Checklist
Validation:
bun fmtbun lintbun typecheckbun run test src/components/chat/MessagesTimeline.test.tsxNote
Reduce rerenders in timeline rows by splitting shared and activity state into separate contexts
TimelineRowSharedStateinto two contexts in MessagesTimeline.tsx: a stableTimelineRowCtxfor view/config props and a newTimelineRowActivityCtxfor frequently-changing activity state (active turn, working status, revert state).TimelineRowContentinto focused sub-components (UserTimelineRow,AssistantTimelineRow,ProposedPlanTimelineRow,WorkingTimelineRow) that each consume only the context they need.RevertUserMessageButton,AssistantCompletionDivider,AssistantCopyButton) consumeTimelineRowActivityCtxdirectly, so only they rerender when activity state changes rather than the entire row tree.Macroscope summarized 6c17b08.
Note
Low Risk
Low risk UI refactor focused on memoization/context splitting; main risk is subtle regressions in per-row controls due to changed component boundaries and context consumption.
Overview
Reduces chat timeline rerenders by splitting the row context into a stable
TimelineRowCtx(config/callbacks) and a frequently-changingTimelineRowActivityCtx(active turn/working/revert/completion summary), so activity updates don’t invalidate every visible row.Refactors
TimelineRowContentinto memoized, role/kind-specific subcomponents and moves activity-sensitive UI (revert button, completion divider, assistant copy button) to consume the activity context directly, preserving row identity and limiting re-renders to the affected leaf controls.Reviewed by Cursor Bugbot for commit 6c17b08. Bugbot is set up for automated code reviews on this repo. Configure here.