Repository navigation
fix(tui): keep the model picker responsive with large catalogs - #66370
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Looks good. I reproduced the lag on the base with the #66326 script (2 providers x 1,000 models, typing gatewaya model 512 one key at a time): each key took 0.9–1.8 s, about 25 s for the query. With this PR each key takes 21–357 ms, 1.9 s in total, and the picker opens in about half the time. The search results look the same before and after. The new test fails on the base and passes here, and the TUI tests (445) and tsc -b pass.
Public API is unchanged: searchDescription is a new optional field on the TUI-internal DialogSelectOption.
I didn't find anything blocking.
3 of 6 tasks
1 task
This was referenced Nov 26, 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.


Issue for this PR
Closes #66326
Type of change
What does this PR do?
the tui model picker got really slow with big catalogs (openrouter, kilo). there were 3 problems:
findModelincontext/local.tsxwas a linear scan, and the picker callsisSpeed(sofindModeltwice) for every model on every key. that's O(n²): ~190ms per key at 2k models. it's now a map lookupdialog-model.tsxrebuilt every option object on every key. the model options are now a memo that doesn't depend on the query, so search returns the same objects. new designs no longer clones each result to swap the description and footer; they usesearchDescription(new, next to the existingsearchFooter) andsearchFooterDialogSelectrendered<For each={grouped()}>, and every update builds new[category, options]tuples, so every row got mounted again on every key. headers and rows are now one flat list keyed by identity, so rows that stay listed are kept, including when the list switches between grouped and flatrows that a search removes still mount again when you widen the search, because
<For>disposes them. that now costs about as much as opening the picker. no visual changes: frames before and after are identical with new designs on and offno flag, it's a fix
How did you verify your code works?
timed opening the picker and typing
gatewaya model 512one key at a time (component render, 2 generated providers, the same setup as the repro in the issue):keeps rows mounted while the filter changestotest/cli/tui/dialog-select.test.tsx. it fails on dev and passes 10 of 10 reruns herebun typecheckcleanScreenshots / recordings
no visual change
Checklist