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 <help@stably.ai>
This commit is contained in:
Jinjing
2026-04-30 20:13:14 -07:00
co-authored by Orca
parent dcf46e367e
commit 1f19fb5ce6
@@ -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()
})