perf(web): reduce minimap work during streaming and scrolling - #9771
perf(web): reduce minimap work during streaming and scrolling#9771t3dotgg wants to merge 1 commit into
Conversation
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a localized, behavior-preserving minimap performance refactor that caches immutable previews and avoids redundant marker DOM writes. Focused tests cover streaming updates, row reordering, cache eviction, and recycled references, with no API, schema, security, billing, or deployment changes. You can add or adjust custom eligibility rules. Learn more. |
Streaming rebuilt full minimap previews for every loaded turn. Scrolling rewrote every marker's visibility attribute, even when nothing changed.
The minimap now reuses previews by immutable message identity and skips unchanged marker writes. Its cache keeps only the latest projection, so unused completed replies do not retain extra preview strings. Preview text, row indexes, geometry, and navigation stay unchanged.
Checks
Small cold cases added about 0.002 ms or improved. The 1,000-turn cold stress case added 0.23 to 1.2 ms across runs. These are source measurements, not browser frame times. No browser or device run was used.
Created with GPT-6 Astra (preview) in Codex.
Note
Low Risk
UI-only performance refactor in the timeline minimap with behavior-preserving tests; no auth, data, or API changes.
Overview
Reduces chat timeline minimap cost during streaming and scroll by caching preview text and skipping redundant DOM updates.
Minimap item building moves from
MessagesTimeline.tsxintocreateTimelineMinimapProjector: a stable projector caches compact user/assistant preview strings keyed byChatMessageobject identity, evicts previews not in the latest projection, and still updatesrowIndexwhen rows reorder. Scroll handling delegates toupdateTimelineMinimapMarkers, which sets each strip’sdata-in-viewonly when visibility actually changes (including remounted/recycled refs).The component keeps one projector instance via
useState(createTimelineMinimapProjector)instead of recomputing all previews on every row change. New unit tests cover marker write counts, ref recycling, cache reuse, and parity when turns reorder or supersede earlier replies.Reviewed by Cursor Bugbot for commit 1e9eca8. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Cache minimap previews and skip redundant marker writes in
MessagesTimelinecreateTimelineMinimapProjectorcaches preview strings byChatMessageobject identity for only the latest projection, scans rows backward to pair each user row with its first assistant row, and returns null for blank previewsupdateTimelineMinimapMarkersresolves the visible interval from scroll state, computes row intersections using finite row positions, and writes dataset only when the marker's visible state actually changesresolveTimelineRowTopandresolveTimelineRowHeightreturn false when row positions are non-finite; marker visibility falls back to false in that caseMacroscope summarized 1e9eca8.