Reduce model picker whitespace search rerenders#3676
Draft
cursor[bot] wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
mrpunyetaz-cloud
approved these changes
Jul 3, 2026
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
ModelPickerSearchInputcomponent.ModelPickerContentstate, so whitespace-only or redundant-spacing edits do not rerender the full picker.useModelPickerJumpShortcutshook.Why
A React best-practices/performance scan found large hot spots around chat/model picker surfaces. Manual React Scan profiling of the model picker showed that typing whitespace in the search box caused
ModelPickerContentto rerender once per keypress even though the visible model results were unchanged. Keeping raw input churn local to the search input preserves behavior while avoiding unnecessary parent picker work.UI Changes
Before/after React Scan recordings were captured as Cursor walkthrough artifacts:
react_scan_model_picker_before_whitespace_rerenders.mp4— five spaces increasedModelPickerContentrenders from 0 to 5.react_scan_model_picker_after_whitespace_rerenders_fixed.mp4— the same five-space interaction leftModelPickerContent,ModelListRow, andModelPickerSidebarat 0; only the search input highlighted.Checklist
Validation:
corepack pnpm dlx react-doctor@latest . --verbose --category performance --no-telemetry(reported performance findings; used to select/manual-profile hot spots)corepack pnpm dlx react-scan@latest --help(CLI only exposesinit; runtime overlay used for recordings)corepack pnpm --filter @t3tools/web test -- src/components/chat/modelPickerSearch.test.ts(148 files / 1279 tests passed)NODE_OPTIONS="--experimental-strip-types" corepack pnpm exec vp check(passed; existing lint warnings remain)corepack pnpm exec vp run typecheck(passed)Note
Reduce rerenders in model picker by normalizing search queries before updating state
ModelPickerSearchInputcomponent that maintains raw input locally and publishes a normalized query (lowercased, whitespace-collapsed) viaonSearchQueryChange, preventing redundant state updates when only whitespace changes.normalizeModelPickerSearchQueryin modelPickerSearch.ts and reuses it inscoreModelPickerSearchtokenization.useModelPickerJumpShortcutshook in ModelPickerContent.tsx.ModelPickerContentnow stores a normalized search string instead of raw input; filtering checkssearchQuerydirectly rather than trimming at each use site.Macroscope summarized bdd4455.