Skip to content

Reduce model picker rerenders for whitespace search input#3690

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/component-performance-optimization-7b06
Draft

Reduce model picker rerenders for whitespace search input#3690
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/component-performance-optimization-7b06

Conversation

@cursor

@cursor cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Split the model picker search box into a small memoized input component that owns raw keystroke state.
  • Added normalizeModelPickerSearchQuery so the expensive picker/list only receives semantic query changes (trimmed, lowercased, whitespace-collapsed).
  • Added a focused unit test covering whitespace normalization.

Why

react-doctor/manual inspection pointed at hot React surfaces in the chat/model-picker area. React Scan showed whitespace-only typing in the model picker search was still invalidating the picker/list even though the effective search query did not change. Keeping raw input state local avoids recomputing/filtering/rerendering the model list for no-op whitespace edits while preserving normal search behavior.

UI Changes

React Scan recordings captured with the temporary fixture around the real ModelPickerContent component:

  • Before: react_scan_model_picker_before_whitespace_counter.mp4 — typing five spaces shows React Scan rerender highlights over the picker/list rows.
  • After: react_scan_model_picker_after_whitespace_counter.mp4 — the same five-space input no longer highlights the visible model rows; the search field still accepts the raw spaces locally.

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 --filter @t3tools/web exec vp test run --passWithNoTests --project unit 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 model picker rerenders by normalizing whitespace in search input

  • Adds normalizeModelPickerSearchQuery in modelPickerSearch.ts to lowercase and collapse consecutive whitespace to a single space.
  • Extracts a memoized ModelPickerSearchInput component in ModelPickerContent.tsx that holds raw input state internally and only calls onNormalizedQueryChange when the normalized value actually changes.
  • Filtering and ranking in ModelPickerContent now use the normalized query, so purely whitespace differences in the input no longer trigger rerenders or recompute the model list.

Macroscope summarized 602ee51.

cursoragent and others added 2 commits July 4, 2026 16:20
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 size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Jul 4, 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