Avoid rerendering the branch picker while scrolling#4013
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
Why
React Doctor identified the synchronous scroll-fade state update as a cascading-render issue. React Scan confirmed that one branch-list scroll increased
BranchToolbarBranchSelectorrenders from 66 to 76. The optimized scroll path now records 0 parent selector renders; newly virtualized rows still render as expected.UI Changes
No visual change; this is a branch-picker interaction performance fix.
React Scan recordings are attached to the Cursor run:
branch_picker_react_scan_before.mp4(66 → 76 selector renders)branch_picker_react_scan_after_final.mp4(Last scroll selector renders: 0)Checklist
Validation:
vp check,vp run typecheck, 30 branch-toolbar unit tests, and React Doctor performance scan (web findings 114 → 113).Note
Avoid rerendering the branch picker scroll fades while scrolling
Replaces React state-driven scroll fade toggling in
BranchToolbarBranchSelectorwith imperativeclassListupdates on the scrollable DOM node. This eliminates rerenders triggered by scroll events. The logic is extracted into two new hooks:useBranchListScrollBehavior(fade class management, scroll reset, pagination) anduseInitialWorktreeBranch(worktree branch auto-selection), with no changes to props or external behavior.Macroscope summarized 477c9aa.