Skip to content

Avoid rerendering the branch picker while scrolling#4013

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/component-performance-optimization-7207
Draft

Avoid rerendering the branch picker while scrolling#4013
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/component-performance-optimization-7207

Conversation

@cursor

@cursor cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • update branch-list fade masks directly on the scroll element instead of storing them in React state
  • move the required DOM synchronization and initial worktree synchronization effects into named hooks
  • preserve pagination, search reset, and top/bottom fade behavior

Why

React Doctor identified the synchronous scroll-fade state update as a cascading-render issue. React Scan confirmed that one branch-list scroll increased BranchToolbarBranchSelector renders 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:

  • Before: branch_picker_react_scan_before.mp4 (66 → 76 selector renders)
  • After: branch_picker_react_scan_after_final.mp4 (Last scroll selector renders: 0)

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after React Scan recordings for the interaction
  • I included a video for the interaction change

Validation: vp check, vp run typecheck, 30 branch-toolbar unit tests, and React Doctor performance scan (web findings 114 → 113).

Open in Web View Automation 

Note

Avoid rerendering the branch picker scroll fades while scrolling

Replaces React state-driven scroll fade toggling in BranchToolbarBranchSelector with imperative classList updates 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) and useInitialWorktreeBranch (worktree branch auto-selection), with no changes to props or external behavior.

Macroscope summarized 477c9aa.

Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant