perf(vscode): open model, mode, and variant selectors instantly - #11774
Merged
Conversation
Virtualize the model catalog so opening the picker mounts only the visible window instead of the entire model list, and remove artificial open latency from the mode and variant pickers. The model selector built every catalog row up front (~6k DOM elements, ~11k transient nodes for a ~630-model catalog), blocking the main thread on element creation, style recalculation, and layout before first paint. The active-model lookup also re-scanned the list on every reactive read. The mode and variant pickers were cheap to build but felt slow because of the shared popover enter animation and a deferred focus frame. Render the catalog through a virtualizer, memoize the active-model lookup, anchor scroll restoration to virtual item offsets so favorite toggles no longer jump when the anchored row is virtualized out, disable the popover open animation for these selectors, and focus the selected option during initial mount instead of a later frame.
chrarnoldus
approved these changes
Jun 29, 2026
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (9 files)
Reviewed by gpt-5.4-20260305 · Input: 92.1K · Output: 15.6K · Cached: 704.3K Review guidance: REVIEW.md from base branch |
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
perf(vscode): open model, mode, and variant selectors instantly
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.
Problem
Opening the chat model selector had a visible delay before the popup appeared, and the mode and variant pickers also felt sluggish to open. Each selector was slow for a different reason.
Model selector — real main-thread work
The popup rendered the entire model catalog eagerly on open. With the live Kilo Gateway catalog (~630 models) that meant a large synchronous burst of work on click, before the popup could paint:
activeModel()was a plain function, so every consumer re-scanned the model list withfind()on each reactive read instead of computing once.Mode and variant selectors — artificial latency, not CPU
These have only a handful of options and were always cheap to build (~4–5 ms to mount). Their perceived lag came from two non-JS sources:
requestAnimationFrameafter open, adding a frame of latency and a second focus pass.Changes
activeModelso the lookup runs once per change instead of on every reactive read.getItemOffsetso the list does not jump when the anchored row is offscreen. The now-dead per-row ref map was removed.data-autofocus) instead of a deferred frame, so mode and variant open without the animation/focus latency.Before / after
Measured in the VS Code self-test harness against the live ~630-model catalog (model picker) and the real chat pickers (mode/variant). Model timings are from CPU/trace profiles; mode/variant DOM-mount timings were already in the single-digit-ms range, so the meaningful win there is the removed animation and focus frame.
Net: the model selector is fixed by doing far less work (virtualization + memoization); the mode and variant selectors are fixed by removing artificial latency (animation + deferred focus). Post-fix the model picker mounts a bounded window regardless of catalog size, so timings no longer scale with the number of models.
Tests