Skip to content

feat(code): add useComboboxFilter hook to improve branch and repo picker performance#1588

Merged
VojtechBartos merged 4 commits intomainfrom
vojta/branch-picker-perf
Apr 9, 2026
Merged

feat(code): add useComboboxFilter hook to improve branch and repo picker performance#1588
VojtechBartos merged 4 commits intomainfrom
vojta/branch-picker-perf

Conversation

@VojtechBartos
Copy link
Copy Markdown
Member

Problem

The branch selector combobox was slow to open on repos with many branches. cmdk renders every item as a DOM node (no virtualization), and each ComboboxItem carries significant per-instance overhead (Tooltip, refs, effects). With hundreds of branches, opening the picker caused a noticeable lag.

Solution

Instead of rendering all items and letting cmdk filter via display: none, we:

  1. Disable cmdk's built-in filtering (shouldFilter={false})
  2. Let cmdk manage the input natively (uncontrolled)
  3. Listen for search changes via onValueChange and debounce them
  4. Score items with cmdk's own defaultFilter (fuzzy matching), filter out noise below a 0.1 threshold, and cap rendered results at 50

Applying it to branch combobox and also to github repo combobox

Showcase

code-filtering.mov

@VojtechBartos VojtechBartos requested a review from a team April 9, 2026 14:58
@VojtechBartos VojtechBartos self-assigned this Apr 9, 2026
Comment on lines +28 to +30
* `shouldFilter={false}` to `Combobox.Content` and wire `onSearchChange`
* to `Combobox.Input`'s `onValueChange`. Do not pass a controlled `value`
* to the input -- let cmdk manage the input display natively.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we build this as a wrapper on ComboBox.Content so future devs don't have to remember (or be aware of) these requirements?

Copy link
Copy Markdown
Member Author

@VojtechBartos VojtechBartos Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sure :) you would like to see it as part of the ComboBox.Content or just new component like ComboBox.FilteredContent?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!!

i think either way is fine by me :) just something to make it a little smoother and less likely that someone forgets to do this, since it seems to be a nice perf improvement all around

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adboio see latest commit if looks good ;)

Copy link
Copy Markdown
Contributor

@adboio adboio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful, thank you!!!

@VojtechBartos VojtechBartos enabled auto-merge (squash) April 9, 2026 15:53
@VojtechBartos VojtechBartos merged commit 02b26ae into main Apr 9, 2026
15 checks passed
@VojtechBartos VojtechBartos deleted the vojta/branch-picker-perf branch April 9, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants