From d68948d67c7709cc28076002e9d6345f9bdcb6fb Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 30 Jul 2026 16:39:18 +0200 Subject: [PATCH] perf(web): keep timeline minimap animations off the main thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A renderer performance trace showed the minimap strips as a standing source of main-thread frame work: each strip transitioned background-color (paint) and width (layout), and both fire constantly — scrolling or streaming flips a band of in-view states at once, and the hover fisheye animates several widths at a time — so any interaction kept a 60fps style/layout/paint pipeline running. The strip now animates only compositor-friendly properties: width tiers are scale-x on a fixed-width box, and the in-view highlight is a bright overlay faded with opacity. The scroll handler also skips no-op data-in-view attribute writes, which previously re-dirtied style state for every strip on every scroll tick. Co-Authored-By: Claude Fable 5 --- .../src/components/chat/MessagesTimeline.tsx | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx index 27e41b7db0..c829b08699 100644 --- a/apps/web/src/components/chat/MessagesTimeline.tsx +++ b/apps/web/src/components/chat/MessagesTimeline.tsx @@ -442,7 +442,12 @@ export const MessagesTimeline = memo(function MessagesTimeline({ rowTop < scrollBottom && rowTop + Math.max(1, rowHeight ?? 1) > scrollTop; - strip.dataset.inView = inView ? "true" : "false"; + // Skip no-op attribute writes: this runs for every strip on every scroll + // tick, and rewriting an unchanged attribute still dirties style state. + const next = inView ? "true" : "false"; + if (strip.dataset.inView !== next) { + strip.dataset.inView = next; + } } }, [listRef, minimapItems, minimapStripMap, onIsAtEndChange]); @@ -842,17 +847,25 @@ function TimelineMinimap({ const activeDistance = resolvedActiveIndex === null ? null : Math.abs(index - resolvedActiveIndex); return ( + // Compositor-friendly on purpose: in-view state and the hover + // fisheye animate constantly (every scroll tick and streaming + // update flips a band of strips), so the strip animates only + // transform and opacity. Width tiers are a scale-x on a fixed + // w-6 box, and the in-view highlight is an opacity-faded bright + // overlay — never background-color or width, which would force + // main-thread style/layout/paint at 60fps for each transition.