Skip to content

Reduce model picker search rerenders#3708

Draft
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/component-performance-optimization-1215
Draft

Reduce model picker search rerenders#3708
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/component-performance-optimization-1215

Conversation

@cursor

@cursor cursor Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Split the model picker search field into a small memoized component that owns raw input text locally.
  • Added normalizeModelPickerSearchQuery so the parent picker only receives effective search-query changes.
  • Added unit coverage for whitespace/case normalization used by model picker ranking.

Why

react-doctor and a manual React hot-spot pass pointed at the model picker/search flow as a UI path worth measuring. With React Scan enabled, typing whitespace into the model search field changed the raw input but not the effective search query, yet ModelPickerContent still re-rendered repeatedly. Keeping raw text local avoids rerendering the full picker/list for no-op query edits while preserving normal filtering for real query text.

UI Changes

React Scan before/after recordings captured in Cursor artifacts:

  • Before: react_scan_model_picker_before_whitespace_rerenders.mp4 — typing five spaces increments ModelPickerContent to 20 renders.
  • After: react_scan_model_picker_after_whitespace_rerenders.mp4 — typing five spaces keeps ModelPickerContent, ModelListRow, and ModelPickerSidebar at 0 renders.

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:

  • corepack pnpm dlx react-doctor@latest . --verbose --category performance --no-telemetry (completed with performance findings used for scan selection)
  • corepack pnpm --filter @t3tools/web test -- src/components/chat/modelPickerSearch.test.ts
  • NODE_OPTIONS="--experimental-strip-types" corepack pnpm exec vp check
  • corepack pnpm exec vp run typecheck
Open in Web View Automation 

Note

Reduce rerenders in model picker search by memoizing input and normalizing queries

  • Extracts a new memoized ModelPickerSearchInput component in ModelPickerContent.tsx that wraps ComboboxInput and manages its own raw input state.
  • Adds normalizeModelPickerSearchQuery in modelPickerSearch.ts to lowercase and collapse whitespace, publishing upstream state changes only when the normalized value actually differs.
  • Escape and Enter key handling are moved into the new component: Escape calls onRequestClose, Enter selects the highlighted model via highlightedModelKeyRef.

Macroscope summarized 8481e20.

cursoragent and others added 3 commits July 5, 2026 16:20
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
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 5, 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