Skip to content

Optimize model picker search rerenders#3619

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

Optimize model picker search rerenders#3619
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/component-performance-optimization-c6a5

Conversation

@cursor

@cursor cursor Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Split the model picker search input into a small memoized component that owns the raw input text.
  • Keep ModelPickerContent subscribed only to the normalized search query, so whitespace-only edits do not invalidate the picker/list tree.
  • Preserved Escape and Enter behavior by passing stable callbacks into the search input.

Why

React Doctor highlighted a broader React performance backlog, and a manual React Scan pass found a measurable model-picker hotspot: typing whitespace in the model search box changed no visible rows but still rerendered the picker content and row area. This change keeps behavior predictable while avoiding those no-op parent/list renders.

UI Changes

No visual UI change. React Scan recordings captured with the temporary harness and toolbar enabled:

  • Before: react_scan_model_picker_before.mp4 — whitespace typing triggered React Scan highlights/rerenders in the picker path.
  • After: react_scan_model_picker_after.mp4 — the same whitespace typing produced no picker/list rerender highlights; counts stayed at ModelPickerContent: 2, ModelListRow: 19.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Validation:

  • react-doctor --verbose -y --offline --category performance --blocking none
  • vp check
  • vp run typecheck
Open in Web View Automation 

Note

Reduce rerenders in model picker search by memoizing the search input component

  • Extracts the search input into a memoized ModelPickerSearchInput component in ModelPickerContent.tsx to prevent unnecessary rerenders.
  • Trims whitespace from search queries via normalizeModelSearchQuery and skips calling onSearchQueryChange when the normalized value is unchanged.
  • Memoizes the submitHighlightedModel callback and wires Enter key submission through the new child component.

Macroscope summarized 6d9e4a1.

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 Jun 30, 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