From 1f19fb5ce63cf8d03c1598d2dc8a5907d41d12f5 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:13:14 -0700 Subject: [PATCH] fix(sidebar): avoid re-centering on worktree selection unless out of view Switch the reveal scroll from align:'center' to align:'auto' so clicking a worktree only scrolls the sidebar when its card is not already visible. Centering on every click made the list feel jumpy during normal navigation. Co-authored-by: Orca --- src/renderer/src/components/sidebar/WorktreeList.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/sidebar/WorktreeList.tsx b/src/renderer/src/components/sidebar/WorktreeList.tsx index 06857e45648..6f119097609 100644 --- a/src/renderer/src/components/sidebar/WorktreeList.tsx +++ b/src/renderer/src/components/sidebar/WorktreeList.tsx @@ -150,7 +150,11 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp (row) => row.type === 'item' && row.worktree.id === pendingRevealWorktreeId ) if (targetIndex !== -1) { - virtualizer.scrollToIndex(targetIndex, { align: 'center' }) + // Why: `align: 'auto'` is a no-op when the card is already visible and + // otherwise scrolls the minimum amount to bring it into view. Using + // 'center' here made every worktree click re-center the sidebar, which + // is visually jumpy even when nothing needed to move. + virtualizer.scrollToIndex(targetIndex, { align: 'auto' }) } clearPendingRevealWorktreeId() })