Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(models): HF search case-insensitive + dropdown drops dead selection

purplee2507b271bf9
diff --git a/src/api/discover.ts b/src/api/discover.ts
index 8c38b1f5..0c0ff071 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -566,7 +566,11 @@ export function deriveQ4FilenameFromRepo(repoName: string): string {
export async function searchHuggingFaceModels(query: string): Promise<DiscoverModel[]> {
try {
- const searchQuery = query.includes('gguf') ? query : `${query} gguf`
+ // Case-insensitive — HF repos almost always end in `-GGUF` (uppercase),
+ // and the previous case-sensitive `includes('gguf')` missed those, so a
+ // user pasting a full repo path like `bartowski/Foo-GGUF` got a search
+ // string mangled to `bartowski/Foo-GGUF gguf` which matched 0 HF rows.
+ const searchQuery = /gguf/i.test(query) ? query : `${query} gguf`
const url = `https://huggingface.co/api/models?search=${encodeURIComponent(searchQuery)}&filter=gguf&sort=downloads&direction=-1&limit=20`
let json: string
diff --git a/src/stores/modelStore.ts b/src/stores/modelStore.ts
index 65f30df5..d8483983 100644
--- a/src/stores/modelStore.ts
+++ b/src/stores/modelStore.ts
@@ -37,10 +37,23 @@ export const useModelStore = create<ModelState>()(
categoryFilter: 'all',
setModels: (models) =>
- set((state) => ({
- models,
- activeModel: state.activeModel || (models.length > 0 ? models[0].name : null),
- })),
+ set((state) => {
+ // Keep the persisted activeModel only if it's actually still
+ // present in the freshly fetched list. Without this validation a
+ // model name persists in the picker after the underlying provider
+ // (e.g. Ollama) was uninstalled or the model was deleted — the
+ // dropdown then shows a dead name and clicking it opens an empty
+ // list. Falls back to the first available model, mirroring the
+ // first-launch behavior so a user is never stuck with no
+ // selection while a model exists.
+ const stillValid = !!state.activeModel && models.some((m) => m.name === state.activeModel)
+ return {
+ models,
+ activeModel: stillValid
+ ? state.activeModel
+ : (models.length > 0 ? models[0].name : null),
+ }
+ }),
setActiveModel: (name) => {
const prev = get().activeModel