[PR #5258] Favorites now stay visible when filtering models. #11312

Closed
opened 2026-02-16 18:16:07 -05:00 by yindo · 0 comments
Owner

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

State: closed
Merged: No


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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5258 **State:** closed **Merged:** No --- ## 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: ```typescript 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): ```typescript 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 <a href="https://opencode.ai/s/sAPpmsac"><img width="200" alt="New%20session%20-%202025-12-08T20%3A37%3A21.096Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI1LTEyLTA4VDIwOjM3OjIxLjA5Nlo=.png?model=opencode/claude-haiku-4-5&version=1.0.134&id=sAPpmsac" /></a> [opencode session](https://opencode.ai/s/sAPpmsac)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/20042058373)
yindo added the pull-request label 2026-02-16 18:16:07 -05:00
yindo closed this issue 2026-02-16 18:16:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11312