opencode
opencode copied to clipboard
Favorites now stay visible when filtering models.
Fix Summary
I've successfully fixed the issue where favorites and recent models were being hidden when filtering! Here's what was changed:
The Problem
In dialog-model.tsx (lines 45 and 78), the code was setting favoriteOptions and recentOptions to empty arrays whenever a search query existed:
const favoriteOptions = !query ? [...] : []
const recentOptions = !query ? [...] : []
This caused favorites and recent models to completely disappear when typing a search.
The Solution
I refactored the code to:
-
Build the full option lists unconditionally - Created
buildFavoriteOptionsandbuildRecentOptionsto build the complete lists regardless of whether a query exists -
Apply fuzzy filtering - When a query exists, use the same
fuzzysortfuzzy matching that's used for other models, filtering the favorite and recent options by their title
The key change (lines 108-114):
const favoriteOptions = query
? fuzzysort.go(query, buildFavoriteOptions, { keys: ["title"] }).map((x) => x.obj)
: buildFavoriteOptions
const recentOptions = query
? fuzzysort.go(query, buildRecentOptions, { keys: ["title"] }).map((x) => x.obj)
: buildRecentOptions
Now when you search for a model:
- ✅ Favorites remain visible and are filtered by the search query
- ✅ Recent models remain visible and are filtered by the search query
- ✅ The filtering uses the same fuzzy matching algorithm as the rest of the UI
- ✅ You can still find and select your favorited models without having to hunt through provider groups
The fix has been validated with TypeScript type checking and compiles successfully.
Closes #5254
opencode session | github run