opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Favorites now stay visible when filtering models.

Open opencode-agent[bot] opened this issue 1 month ago • 0 comments

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:

  1. Build the full option lists unconditionally - Created buildFavoriteOptions and buildRecentOptions to build the complete lists regardless of whether a query exists
  2. Apply fuzzy filtering - When a query exists, use the same fuzzysort fuzzy 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

New%20session%20-%202025-12-08T20%3A37%3A21.096Z opencode session  |  github run

opencode-agent[bot] avatar Dec 08 '25 20:12 opencode-agent[bot]