Reduce model picker search rerenders#3708
Draft
cursor[bot] wants to merge 3 commits into
Draft
Conversation
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>
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
normalizeModelPickerSearchQueryso the parent picker only receives effective search-query changes.Why
react-doctorand 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, yetModelPickerContentstill 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:
react_scan_model_picker_before_whitespace_rerenders.mp4— typing five spaces incrementsModelPickerContentto 20 renders.react_scan_model_picker_after_whitespace_rerenders.mp4— typing five spaces keepsModelPickerContent,ModelListRow, andModelPickerSidebarat 0 renders.Checklist
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.tsNODE_OPTIONS="--experimental-strip-types" corepack pnpm exec vp checkcorepack pnpm exec vp run typecheckNote
Reduce rerenders in model picker search by memoizing input and normalizing queries
ModelPickerSearchInputcomponent in ModelPickerContent.tsx that wrapsComboboxInputand manages its own raw input state.normalizeModelPickerSearchQueryin modelPickerSearch.ts to lowercase and collapse whitespace, publishing upstream state changes only when the normalized value actually differs.onRequestClose, Enter selects the highlighted model viahighlightedModelKeyRef.Macroscope summarized 8481e20.