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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(models): search the Models page by file name too
purpled5904420a285
diff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsxindex 69003260..1fa831bd 100644--- a/src/components/models/DiscoverModels.tsx+++ b/src/components/models/DiscoverModels.tsx@@ -21,6 +21,7 @@ import { kimiK31CatalogEntries } from '../../api/kimi-k3-catalog'import { asOneDownload, downloadSizeGB, gbOf, imagePartFileName, includeImageInputLabel, isImagePartFile } from '../../lib/image-part'import { sortByTier, tierGroup } from '../../lib/render/model-tier'import { bundlesForTabAndSearch } from '../../lib/discover-bundle-search'+import { catalogEntryMatchesSearch } from '../../lib/model-search'import { getTotalRamGb } from '../../lib/hardware'import { vramFit } from '../../lib/vram-fit'import { chatModelBudgetGb, sharedMemoryWording } from '../../lib/shared-memory-wording'@@ -760,10 +761,9 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0, oreturn sizeGB > 20 // highend (open-ended)}- const matchesSearch = (m: DiscoverModel) =>- !search ||- m.name.toLowerCase().includes(search.toLowerCase()) ||- m.description.toLowerCase().includes(search.toLowerCase())+ // Name, description, and the file it downloads (lib/model-search): the+ // model on disk can be found here by its file name too.+ const matchesSearch = (m: DiscoverModel) => !search || catalogEntryMatchesSearch(m, search)// The size filter counts the image part like the tile does: it is loaded// next to the model, so a model that only fits without it does not fit.diff --git a/src/components/models/ModelManager.tsx b/src/components/models/ModelManager.tsxindex 7515309a..3cba85a3 100644--- a/src/components/models/ModelManager.tsx+++ b/src/components/models/ModelManager.tsx@@ -1,5 +1,5 @@import { displayModelName } from '../../api/providers/registry'-import { useState, useEffect, useRef } from 'react'+import { useState, useEffect, useRef, useMemo } from 'react'import { motion } from 'framer-motion'import {MessagesSquare, Images, Clapperboard,@@ -42,7 +42,8 @@ import { counterView } from '../../lib/inventory-counter'import { groupInstalledByProvider, needsBackendSwitchHeading, foldedRowsSentence, LU_ENGINE_GROUP } from '../../lib/lu-engine-rows'import { isBuiltinEngineEntry } from '../../lib/lmstudio-match'import { externalDeleteHint, servesItsOwnFiles } from '../../lib/external-model-hint'-import { installedRowMatchesSearch } from '../../lib/model-search'+import { catalogNamesFor, installedModelMatchesSearch, installedRowMatchesSearch } from '../../lib/model-search'+import { installedCatalogNames } from '../../lib/installed-catalog-names'import { isLoraRow } from '../../lib/lora-rows'import { useBuiltinEngineStatus, engineIsIdle } from '../../hooks/useBuiltinEngineStatus'import { LuEngineSwitchBar } from '../chat/LuEngineSwitchBar'@@ -367,6 +368,9 @@ export function ModelManager() {const loraMatches = (r: LoraRow, q: string) =>installedRowMatchesSearch(r.name, q) || (!!r.label && installedRowMatchesSearch(r.label, q)) || (!!r.note && r.note.toLowerCase().includes(q.trim().toLowerCase()))const filteredModels = models.filter((m: AIModel) => m.type === mode && !isLoraRow(m))+ // An installed file also answers to the catalogue name it was downloaded+ // under ("Gemma 4 12B Abliterated" finds `Huihui-gemma-4-12B-…-Q4_K`).+ const catalogByFile = useMemo(() => installedCatalogNames(), [])const modeMeta = RAIL_ITEMS.find(r => r.key === mode)!/** What the Installed counter and the Installed view are about right now. */const installedCount = showMacLoras@@ -580,7 +584,7 @@ export function ModelManager() {) : ((() => {const shown = searchQuery- ? filteredModels.filter(m => installedRowMatchesSearch(m.name, searchQuery))+ ? filteredModels.filter(m => installedModelMatchesSearch(m.name, catalogNamesFor(m.name, catalogByFile), searchQuery)): filteredModelsreturn (<section className={skin.cls.group}>diff --git a/src/lib/__tests__/models-search-by-file-name.test.ts b/src/lib/__tests__/models-search-by-file-name.test.tsnew file mode 100644index 00000000..2c28291c--- /dev/null+++ b/src/lib/__tests__/models-search-by-file-name.test.ts@@ -0,0 +1,78 @@+// Models search by file name (boromirofgeo, Discord 12.11.2026): the user had+// Gemma 4 12B Abliterated on disk under its uploader's file name and could+// not find it again on the Models page.+//+// Run: npx vitest run src/lib/__tests__/models-search-by-file-name.test.ts+import { describe, expect, it } from 'vitest'+import { getMainstreamTextModels, getUncensoredTextModels } from '../../api/discover'+import {+ catalogEntryMatchesSearch,+ catalogNamesByFile,+ catalogNamesFor,+ installedModelMatchesSearch,+} from '../model-search'+import { bundlesForTabAndSearch } from '../discover-bundle-search'++const catalog = [...getUncensoredTextModels(), ...getMainstreamTextModels()]+const ABLIT = catalog.find((m) => m.name === 'Gemma 4 12B Abliterated')!+const FILE = 'Huihui-gemma-4-12B-it-qat-q4_0-unquantized-abliterated-Q4_K'++describe('Get new: a catalogue entry answers to its file', () => {+ it('the real entry is in the catalogue with that file', () => {+ expect(ABLIT?.filename).toBe(`${FILE}.gguf`)+ })++ it('found by the full file name, with or without .gguf', () => {+ expect(catalogEntryMatchesSearch(ABLIT, FILE)).toBe(true)+ expect(catalogEntryMatchesSearch(ABLIT, `${FILE}.gguf`)).toBe(true)+ })++ it('found by a piece of the file name and by the uploader', () => {+ expect(catalogEntryMatchesSearch(ABLIT, 'huihui')).toBe(true)+ expect(catalogEntryMatchesSearch(ABLIT, 'qat q4_0 unquantized')).toBe(true)+ expect(catalogEntryMatchesSearch(ABLIT, 'huihui-ai/Huihui-gemma-4-12B-it-qat-q4_0-unquantized-abliterated-GGUF')).toBe(true)+ })++ it('found by its image part file', () => {+ expect(catalogEntryMatchesSearch(ABLIT, 'mmproj-model-bf16')).toBe(true)+ })++ it('still found by its name and description, and not by something else', () => {+ expect(catalogEntryMatchesSearch(ABLIT, 'Gemma 4 12B Abliterated')).toBe(true)+ expect(catalogEntryMatchesSearch(ABLIT, 'first solid gemma 4 uncensor')).toBe(true)+ expect(catalogEntryMatchesSearch(ABLIT, 'qwen')).toBe(false)+ })++ it('in the whole catalogue the file name finds exactly that entry', () => {+ const hits = catalog.filter((m) => catalogEntryMatchesSearch(m, FILE))+ expect(hits.map((m) => m.name)).toEqual(['Gemma 4 12B Abliterated'])+ })+})++describe('Installed: a file answers to its catalogue name', () => {+ const byFile = catalogNamesByFile(catalog)++ it('the LU Engine row of that file is found by "Gemma 4 12B Abliterated"', () => {+ const row = `openai::${FILE}`+ expect(catalogNamesFor(row, byFile)).toContain('Gemma 4 12B Abliterated')+ expect(installedModelMatchesSearch(row, catalogNamesFor(row, byFile), 'Gemma 4 12B Abliterated')).toBe(true)+ expect(installedModelMatchesSearch(row, catalogNamesFor(row, byFile), FILE)).toBe(true)+ })++ it('a file the catalogue does not know keeps the old rule', () => {+ const row = 'openai::my-own-finetune-Q5_K_M'+ expect(catalogNamesFor(row, byFile)).toEqual([])+ expect(installedModelMatchesSearch(row, [], 'own finetune')).toBe(true)+ expect(installedModelMatchesSearch(row, [], 'gemma')).toBe(false)+ })+})++describe('Image and video bundles answer to their files', () => {+ it('a bundle is found by one of its file names', () => {+ const bundles = [+ { name: 'Some Video', description: 'video model', files: [{ name: 'x', filename: 'wan2.2_t2v_low_noise_14B_fp8_scaled.safetensors' }] },+ { name: 'Other', description: 'other', files: [{ name: 'y', filename: 'flux1-dev.safetensors' }] },+ ]+ expect(bundlesForTabAndSearch(bundles, 'mainstream', 'wan2.2_t2v_low_noise').map((b) => b.name)).toEqual(['Some Video'])+ })+})diff --git a/src/lib/discover-bundle-search.ts b/src/lib/discover-bundle-search.tsindex cafd778f..1bdf325a 100644--- a/src/lib/discover-bundle-search.ts+++ b/src/lib/discover-bundle-search.ts@@ -9,10 +9,13 @@* catalogue carries reads as "LU does not have it". While a search is typed* it now looks in both tabs; without one the tab decides as before.*/+import { catalogFileNames, installedRowMatchesSearch, type SearchableCatalogEntry } from './model-search'export interface SearchableBundle {name: stringdescription: stringuncensored?: boolean+ /** The files a bundle downloads: found by their names too. */+ files?: SearchableCatalogEntry[]}export function bundlesForTabAndSearch<T extends SearchableBundle>(@@ -22,5 +25,10 @@ export function bundlesForTabAndSearch<T extends SearchableBundle>(): T[] {const q = search.trim().toLowerCase()if (!q) return bundles.filter((b) => (subTab === 'uncensored' ? !!b.uncensored : !b.uncensored))- return bundles.filter((b) => b.name.toLowerCase().includes(q) || b.description.toLowerCase().includes(q))+ return bundles.filter(+ (b) =>+ b.name.toLowerCase().includes(q) ||+ b.description.toLowerCase().includes(q) ||+ (b.files ?? []).some((f) => catalogFileNames(f).some((n) => installedRowMatchesSearch(n, q))),+ )}diff --git a/src/lib/installed-catalog-names.ts b/src/lib/installed-catalog-names.tsnew file mode 100644index 00000000..c66cdd6e--- /dev/null+++ b/src/lib/installed-catalog-names.ts@@ -0,0 +1,22 @@+import * as discover from '../api/discover'+import { catalogNamesByFile } from './model-search'++let cached: Map<string, string[]> | null = null++/**+ * Catalogue names by file stem, for the search over installed rows+ * (lib/model-search). Built once: the text catalogue is static data.+ *+ * The filter is a convenience on top of the row's own name, so a catalogue+ * that cannot be read (a test that stubs the discover module) leaves it+ * with no extra names instead of taking the Models page down.+ */+export function installedCatalogNames(): Map<string, string[]> {+ if (cached) return cached+ try {+ cached = catalogNamesByFile([...discover.getUncensoredTextModels(), ...discover.getMainstreamTextModels()])+ } catch {+ return new Map()+ }+ return cached+}diff --git a/src/lib/model-search.ts b/src/lib/model-search.tsindex 1a8a6f75..2219185d 100644--- a/src/lib/model-search.ts+++ b/src/lib/model-search.ts@@ -23,3 +23,89 @@ export function installedRowMatchesSearch(rowId: string, query: string): booleanconst words = q.split(/\s+/).map(bare).filter(Boolean)return words.length > 0 && words.every((w) => id.includes(w))}++/**+ * Does a catalogue entry answer a search? (boromirofgeo, Discord 12.11.2026)+ *+ * The catalogue names a model the way people say it ("Gemma 4 12B+ * Abliterated"), the disk names it the way the uploader did+ * (`Huihui-gemma-4-12B-it-qat-q4_0-unquantized-abliterated-Q4_K.gguf`). The+ * Models page saw only one side at a time: Get new searched the name and the+ * description, Installed the file. So a model you have on disk could not be+ * found in the catalogue by its file name, and the reverse.+ *+ * Now an entry also answers to its file name, its image part, its+ * Hugging Face repo and its Ollama tag, with the same word rule as the+ * installed rows ("gemma 4 12b q4" finds `gemma-4-12B-it-Q4_K_M`).+ */+export interface SearchableCatalogEntry {+ name: string+ description?: string+ filename?: string+ downloadUrl?: string+ mmprojUrl?: string+ ollamaModel?: string+ url?: string+}++/** `owner/repo` and the file of a Hugging Face resolve link, or nothing. */+function hfPartsOf(url: string | undefined): string[] {+ if (!url) return []+ const m = /huggingface\.co\/([^/]+\/[^/]+)\/(?:resolve|blob)\/[^/]+\/(.+)$/.exec(url)+ return m ? [m[1], decodeURIComponent(m[2])] : []+}++/** Every name a catalogue entry goes by on disk or upstream. */+export function catalogFileNames(entry: SearchableCatalogEntry): string[] {+ const names = [+ entry.filename,+ entry.ollamaModel,+ ...hfPartsOf(entry.downloadUrl),+ ...hfPartsOf(entry.mmprojUrl),+ ].filter((s): s is string => !!s && !!s.trim())+ return [...new Set(names.map((n) => n.replace(/\.(gguf|safetensors|ckpt|pt|pth|bin)$/i, '')))]+}++/** A pasted file name carries its extension; the names compared here do not. */+const withoutExtension = (q: string) => q.replace(/\.(gguf|safetensors|ckpt|pt|pth|bin)$/i, '')++export function catalogEntryMatchesSearch(entry: SearchableCatalogEntry, query: string): boolean {+ const q = withoutExtension(query.trim().toLowerCase())+ if (!q) return true+ if (installedRowMatchesSearch(entry.name, q)) return true+ if (entry.description?.toLowerCase().includes(q)) return true+ return catalogFileNames(entry).some((n) => installedRowMatchesSearch(n, q))+}++/**+ * The installed side of the same question: a row answers to its own id and+ * to the catalogue names of the file it is (`alsoKnownAs`).+ */+export function installedModelMatchesSearch(rowId: string, alsoKnownAs: readonly string[], query: string): boolean {+ query = withoutExtension(query.trim())+ return installedRowMatchesSearch(rowId, query) || alsoKnownAs.some((n) => installedRowMatchesSearch(n, query))+}++/**+ * Catalogue names by file, for the installed rows: lower-cased file stem →+ * the names of the entries that download it.+ */+export function catalogNamesByFile(entries: readonly SearchableCatalogEntry[]): Map<string, string[]> {+ const out = new Map<string, string[]>()+ for (const e of entries) {+ for (const f of catalogFileNames(e)) {+ const key = f.split('/').pop()!.toLowerCase()+ const list = out.get(key) ?? []+ if (!list.includes(e.name)) list.push(e.name)+ out.set(key, list)+ }+ }+ return out+}++/** The catalogue names a row id is known by: its file stem, without a provider prefix. */+export function catalogNamesFor(rowId: string, byFile: ReadonlyMap<string, string[]>): string[] {+ const bareId = rowId.split('::').pop() ?? rowId+ const stem = bareId.split(/[\\/]/).pop()!.replace(/\.(gguf|safetensors|ckpt|pt|pth|bin)$/i, '').toLowerCase()+ return byFile.get(stem) ?? []+}