From df2393023759eebcbacf2e7e411c67af9992385b Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 31 May 2026 09:40:48 -0700 Subject: [PATCH] perf: move worktree reveal cleanup to scroll root ref --- .../src/components/sidebar/WorktreeList.tsx | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/renderer/src/components/sidebar/WorktreeList.tsx b/src/renderer/src/components/sidebar/WorktreeList.tsx index b24f6fe544e..6706110566c 100644 --- a/src/renderer/src/components/sidebar/WorktreeList.tsx +++ b/src/renderer/src/components/sidebar/WorktreeList.tsx @@ -878,16 +878,6 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp }, [clearRevealHighlightFrame, clearRevealHighlightTimeout] ) - // Why: reveal frames capture virtualized row snapshots and set state later; - // cancel them when the list goes away so stale reveal work cannot survive teardown. - useEffect( - () => () => { - cancelPendingRevealFrames() - clearRevealHighlightFrame() - clearRevealHighlightTimeout() - }, - [cancelPendingRevealFrames, clearRevealHighlightFrame, clearRevealHighlightTimeout] - ) const suppressWorktreeClickUntilRef = useRef(0) const hasProjectGroups = projectGroups.length > 0 const canReorderRepoHeaders = @@ -1656,14 +1646,21 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp const setScrollRootRef = useCallback( (node: HTMLDivElement | null) => { if (node === null && scrollRef.current !== null) { - // Why: sidebar drag previews, autoscroll frames, and reveal glow timers - // are tied to the scroll root surface; clear them before it disappears. + // Why: sidebar drag previews, autoscroll frames, and reveal row + // snapshots are tied to the scroll root; clear them before it disappears. + cancelPendingRevealFrames() + clearRevealHighlightFrame() clearRevealHighlightTimeout() clearWorktreeDrag() } scrollRef.current = node }, - [clearRevealHighlightTimeout, clearWorktreeDrag] + [ + cancelPendingRevealFrames, + clearRevealHighlightFrame, + clearRevealHighlightTimeout, + clearWorktreeDrag + ] ) const flushWorktreePointerDrag = useCallback(() => {