[PR #6514] perf: optimize model picker dialog for instant response #11945

Open
opened 2026-02-16 18:16:53 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6514

State: open
Merged: No


Summary

  • Split options memo into baseOptions (stable computation) and options (filtering only)
  • Add 50ms debounce to search input to reduce fuzzy search frequency
  • Extract shared selectModel handler to avoid creating new closures per option

Problem

The model picker dialog (ctrl+x m) was sluggish to open and search. Every keystroke triggered:

  1. Full recomputation of ALL option objects (favorites, recents, providers)
  2. Creation of new onSelect closure functions for every single model
  3. 4x fuzzy search calls across all option arrays

Solution

Now baseOptions memo only recomputes when providers/favorites/recents actually change. The options memo just filters the pre-computed arrays. Combined with debouncing, this makes the dialog feel instant.

Testing

Tested locally - dialog opens instantly and search is responsive even with many providers connected.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6514 **State:** open **Merged:** No --- ## Summary - Split `options` memo into `baseOptions` (stable computation) and `options` (filtering only) - Add 50ms debounce to search input to reduce fuzzy search frequency - Extract shared `selectModel` handler to avoid creating new closures per option ## Problem The model picker dialog (`ctrl+x m`) was sluggish to open and search. Every keystroke triggered: 1. Full recomputation of ALL option objects (favorites, recents, providers) 2. Creation of new `onSelect` closure functions for every single model 3. 4x fuzzy search calls across all option arrays ## Solution Now `baseOptions` memo only recomputes when providers/favorites/recents actually change. The `options` memo just filters the pre-computed arrays. Combined with debouncing, this makes the dialog feel instant. ## Testing Tested locally - dialog opens instantly and search is responsive even with many providers connected.
yindo added the pull-request label 2026-02-16 18:16:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11945