Reduce model picker rerenders for whitespace search input#3690
Draft
cursor[bot] wants to merge 2 commits into
Draft
Reduce model picker rerenders for whitespace search input#3690cursor[bot] wants to merge 2 commits into
cursor[bot] wants to merge 2 commits into
Conversation
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 expensive picker/list only receives semantic query changes (trimmed, lowercased, whitespace-collapsed).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
ModelPickerContentcomponent:react_scan_model_picker_before_whitespace_counter.mp4— typing five spaces shows React Scan rerender highlights over the picker/list rows.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
Validation:
corepack pnpm --filter @t3tools/web exec vp test run --passWithNoTests --project unit src/components/chat/modelPickerSearch.test.tsNODE_OPTIONS="--experimental-strip-types" corepack pnpm exec vp checkcorepack pnpm exec vp run typecheckNote
Reduce model picker rerenders by normalizing whitespace in search input
normalizeModelPickerSearchQueryinmodelPickerSearch.tsto lowercase and collapse consecutive whitespace to a single space.ModelPickerSearchInputcomponent inModelPickerContent.tsxthat holds raw input state internally and only callsonNormalizedQueryChangewhen the normalized value actually changes.ModelPickerContentnow use the normalized query, so purely whitespace differences in the input no longer trigger rerenders or recompute the model list.Macroscope summarized 602ee51.