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): Installed kommt von der Platte, und die Kachel ist keine Sackgasse

purple20e3c70a36b8
diff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsx
index f7f16b70..3e10913e 100644
--- a/src/components/models/DiscoverModels.tsx
+++ b/src/components/models/DiscoverModels.tsx
@@ -23,8 +23,10 @@ import { useModelStore } from '../../stores/modelStore'
import { useWorkflowStore } from '../../stores/workflowStore'
import { getProviderIdFromModel } from '../../api/providers'
import { startBundledEngine } from '../../api/engine'
+import { diagnoseBuiltinEngine } from '../../api/builtin-ensure'
import { BUILTIN_BACKEND_ID } from '../../lib/onboarding-backend'
-import { matchesLocalGgufInstalled, type InstalledModelLike } from '../../lib/lmstudio-match'
+import type { InstalledModelLike } from '../../lib/lmstudio-match'
+import { findInstalledForDiscoverModel } from '../../lib/discover-installed'
import { resolveTextDownloadTarget } from '../../lib/text-download-target'
import { hfUrlToOllamaRef, hfUrlToLmStudioSubdir, parseHfUrl, extractGgufQuant, isShardedOrIncompatibleGguf } from '../../lib/hf-to-provider'
import { GlassCard } from '../ui/GlassCard'
@@ -88,7 +90,7 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
// backends and a bare name for Ollama.
const activeChatModel = useModelStore(s => s.activeModel)
const [hfModelPath, setHfModelPath] = useState<string | null>(null)
- const { pullModel, models: installedModels, fetchModels } = useModels()
+ const { pullModel, models: installedModels, fetchModels, setActiveModel } = useModels()
// Refresh installed-model list on mount + when category switches to text
// so the Discover grid reflects what Ollama / LM Studio actually have on
@@ -191,51 +193,46 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
// Text-model installed check.
//
- // Before v2.4.8 this only consulted the in-memory `downloads` store, so the
- // INSTALLED badge disappeared the moment the user restarted the app — which
- // is exactly what leonsk29 reported (GH #43). The store has no knowledge of
- // what Ollama / LM Studio actually have on disk, only of downloads that
- // happened in the current session.
- //
- // Fix: also match against the provider model list (which Ollama/LM Studio
- // populate from disk). For HF GGUFs the in-app download goes through
- // `ollama pull hf.co/<repo>:<quant>`, so the same canonical reference is
- // what we look up in the installed-list. Session downloads remain a valid
- // signal as the fastest-path (no fetchModels round-trip needed).
- const isModelFullyInstalled = (model: DiscoverModel) => {
- if (model.filename && downloads[model.filename]?.status === 'complete') return true
-
- const installedOllamaTags = installedModels
- .filter(m => m.provider === 'ollama')
- .map(m => (m.model || m.name || '').toLowerCase())
-
- if (model.ollamaModel) {
- const tag = model.ollamaModel.toLowerCase()
- if (installedOllamaTags.includes(tag)) return true
- // Ollama appends `:latest` to bare model names — accept either form
- if (!tag.includes(':') && installedOllamaTags.includes(`${tag}:latest`)) return true
- }
-
- if (model.filename && model.downloadUrl) {
- const ref = hfUrlToOllamaRef(model.downloadUrl, model.filename)?.toLowerCase()
- if (ref && installedOllamaTags.includes(ref)) return true
- }
-
- // Bug Y/b v2.5.0 — Aldrich Ironhart Discord. Pre-v2.5.0 isModelFullyInstalled
- // only checked Ollama tags. After a restart, GGUFs that LU itself wrote
- // to LM Studio's scan dir would never light up the INSTALLED badge,
- // because LM Studio surfaces them by file basename in the openai-compat
- // listing rather than by an Ollama-style hf.co tag. Match by filename
- // (case-insensitive, with/without trailing `.gguf`).
- // Match against LM Studio's installed models too (not just Ollama tags).
- // The matcher (lib/lmstudio-match.ts, unit-tested) handles both the older
- // full-basename id form AND LM Studio's modern quant-less publisher/short
- // key (e.g. "qwen/qwen2.5-vl-7b" vs "Qwen2.5-VL-7B-Instruct-Q4_K_M.gguf").
- if (model.filename && matchesLocalGgufInstalled(model.filename, installedModels as unknown as InstalledModelLike[])) {
- return true
+ // Lives in lib/discover-installed.ts since 2.6.8, unit-tested, because the
+ // rule it encodes is the whole of GH #118: installed is a question about the
+ // DISK. The session download store, the Ollama store and, since the same
+ // ticket, the built-in engine's own directory scan are all filesystem
+ // evidence. Whether the engine answers on its port is a different question
+ // with a different repair, and it must never be able to unsay "this 8 GB
+ // file is on your machine" (Bug #43 was the first version of the same
+ // mistake, nayffy's restart the second).
+ const installedEntryFor = (model: DiscoverModel) =>
+ findInstalledForDiscoverModel(model, downloads, installedModels as unknown as InstalledModelLike[])
+
+ const isModelFullyInstalled = (model: DiscoverModel) => installedEntryFor(model) !== null
+
+ /** Can the Use button do anything for this row: is the local model behind it
+ * known by its picker id. A download that finished in this session is on the
+ * disk but carries no id until the next model refresh, so it stays a badge. */
+ const canUseInstalled = (model: DiscoverModel) => !!installedEntryFor(model)?.name
+
+ /**
+ * GH #118: "the Get button doesn't do anything as the files are still
+ * downloaded". With the badge right, the state the user landed in was an
+ * inert Installed pill beside an engine that was not running, and the Models
+ * page offered no way on. This is that way on: pick the model, and start the
+ * engine if it is down.
+ *
+ * The repair runs BEFORE the pick, because diagnoseBuiltinEngine starts the
+ * engine on exactly this model when it is dead, and the pick then swaps only
+ * when something else is loaded. The other order would start twice.
+ */
+ const handleUseInstalled = async (model: DiscoverModel) => {
+ const name = installedEntryFor(model)?.name
+ if (!name) return
+ setInstallError(null)
+ try {
+ const diagnosis = await diagnoseBuiltinEngine({ repair: true, preferModel: name })
+ if (!diagnosis.ok && diagnosis.reason) setInstallError(diagnosis.reason)
+ } catch (e) {
+ log.warn('[DiscoverModels] built-in engine repair failed', { err: e })
}
-
- return false
+ setActiveModel(name)
}
const [installingBundle, setInstallingBundle] = useState<string | null>(null)
@@ -660,6 +657,8 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
isInstalled={isModelFullyInstalled}
dlState={getModelDownloadState}
onDownload={handleTextDownload}
+ onUse={handleUseInstalled}
+ canUse={canUseInstalled}
onInfo={setInfoModel}
onOpenUrl={(u) => openExternal(u)}
highlight={highlight}
@@ -922,6 +921,8 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
isInstalled={isModelFullyInstalled}
dlState={getModelDownloadState}
onDownload={handleTextDownload}
+ onUse={handleUseInstalled}
+ canUse={canUseInstalled}
onInfo={setInfoModel}
onOpenUrl={(u) => openExternal(u)}
/>
diff --git a/src/components/models/ModelTiles.tsx b/src/components/models/ModelTiles.tsx
index a1f193a9..2cdbf013 100644
--- a/src/components/models/ModelTiles.tsx
+++ b/src/components/models/ModelTiles.tsx
@@ -11,6 +11,7 @@ import {
import type { DiscoverModel, DownloadProgress, ModelBundle } from '../../api/discover'
import { formatBytes } from '../../lib/formatters'
import { bundleVramNeedGb } from '../../lib/hardware'
+import { modelTileAction } from '../../lib/model-tile-action'
// ─── Hardware fit ───────────────────────────────────────────────────
@@ -152,10 +153,17 @@ export interface ModelTileProps {
onDownload: (m: DiscoverModel) => void
onInfo: (m: DiscoverModel) => void
onOpenUrl: (url: string) => void
+ /** Load an already installed model into the chat. GH #118: without this the
+ * Installed state is an inert pill, which is the dead end the ticket
+ * describes. Absent = the old badge, for surfaces that cannot activate. */
+ onUse?: (m: DiscoverModel) => void
+ /** Can `onUse` do anything for THIS row, i.e. is the local model behind it
+ * known by name. */
+ canUse?: (m: DiscoverModel) => boolean
highlight?: boolean
}
-export function ModelTile({ variants, vramGb, isInstalled, dlState, onDownload, onInfo, onOpenUrl, highlight }: ModelTileProps) {
+export function ModelTile({ variants, vramGb, isInstalled, dlState, onDownload, onInfo, onOpenUrl, onUse, canUse, highlight }: ModelTileProps) {
const [pickerOpen, setPickerOpen] = useState(false)
const [chosen, setChosen] = useState<string | null>(null)
const pickerRef = useRef<HTMLDivElement>(null)
@@ -168,6 +176,14 @@ export function ModelTile({ variants, vramGb, isInstalled, dlState, onDownload,
const installed = isInstalled(sel) || dl?.status === 'complete'
const externalOnly = sel.canPull === false
const fit = computeFit(sel.sizeGB, vramGb)
+ // One rule for what the button does, so no state can end up without one
+ // (lib/model-tile-action.ts).
+ const action = modelTileAction({
+ externalOnly,
+ installed,
+ downloading,
+ loadable: !!onUse && (canUse ? canUse(sel) : true),
+ })
useEffect(() => {
if (!pickerOpen) return
@@ -246,7 +262,7 @@ export function ModelTile({ variants, vramGb, isInstalled, dlState, onDownload,
{sel.pulls && <span className="text-[0.55rem] text-gray-400 dark:text-gray-500 ml-auto mr-1">{sel.pulls}</span>}
<div className={`flex items-center gap-1 shrink-0 ${sel.pulls ? '' : 'ml-auto'}`}>
- {externalOnly ? (
+ {action === 'view' ? (
sel.url ? (
<button
onClick={() => onOpenUrl(sel.url!)}
@@ -256,11 +272,20 @@ export function ModelTile({ variants, vramGb, isInstalled, dlState, onDownload,
<ExternalLink size={11} /> View
</button>
) : null
- ) : installed ? (
+ ) : action === 'use' ? (
+ <button
+ onClick={() => onUse!(sel)}
+ className="flex items-center gap-1 px-2 py-1 rounded-md bg-gray-100 dark:bg-white/[0.06] hover:bg-gray-200 dark:hover:bg-white/10 text-gray-700 dark:text-gray-200 text-[0.62rem] font-medium transition-colors"
+ title="Installed. Load it in the chat and start the engine if it is not running."
+ aria-label={`Use ${sel.name}`}
+ >
+ <Check size={11} className="text-emerald-500/80" /> Use
+ </button>
+ ) : action === 'installed' ? (
<span className="flex items-center gap-1 px-2 py-1 rounded-md bg-gray-100 dark:bg-white/[0.06] text-gray-600 dark:text-gray-300 text-[0.62rem] font-medium">
<Check size={11} className="text-emerald-500/80" /> Installed
</span>
- ) : downloading ? (
+ ) : action === 'downloading' ? (
<span className="flex items-center gap-1.5 px-2 py-1 text-[0.62rem] text-gray-500 dark:text-gray-400">
<Loader2 size={11} className="animate-spin" /> Downloading…
</span>
diff --git a/src/lib/__tests__/discover-installed.test.ts b/src/lib/__tests__/discover-installed.test.ts
new file mode 100644
index 00000000..1734a2b5
--- /dev/null
+++ b/src/lib/__tests__/discover-installed.test.ts
@@ -0,0 +1,108 @@
+/**
+ * GH #118 (nayffy, 2026-08-27, fresh Windows 11 install, v2.6.6): "Uncensored
+ * chat models download and state installed... If i close and reopen LU, it
+ * changed from 'Installed' to 'Get', but the 'Get' button doesn't do anything
+ * as the files are still downloaded." In the same report the built-in engine
+ * answered ERR_CONNECTION_REFUSED on 127.0.0.1:8127.
+ *
+ * The rule these tests hold down: the badge is a question about the DISK. An
+ * engine that is not answering is a reason to start it, never a reason to tell
+ * a user that their multi-gigabyte file is gone.
+ *
+ * Run: npx vitest run src/lib/__tests__/discover-installed.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import {
+ findInstalledForDiscoverModel,
+ isDiscoverModelInstalled,
+ type DownloadStatuses,
+} from '../discover-installed'
+import type { InstalledModelLike } from '../lmstudio-match'
+
+const CYDONIA = {
+ filename: 'Cydonia-24B-v4.1-Q4_K_M.gguf',
+ downloadUrl:
+ 'https://huggingface.co/TheDrummer/Cydonia-24B-v4.1-GGUF/resolve/main/Cydonia-24B-v4.1-Q4_K_M.gguf',
+}
+
+/** What `list_bundled_models` produced for that file, mapped by
+ * `bundledToAIModels`. A Rust directory scan, no engine involved. */
+const ON_DISK: InstalledModelLike[] = [
+ {
+ provider: 'openai',
+ providerName: 'Built-in Engine',
+ name: 'openai::Cydonia-24B-v4.1-Q4_K_M',
+ model: 'Cydonia-24B-v4.1-Q4_K_M',
+ },
+]
+
+const NO_DOWNLOADS: DownloadStatuses = {}
+
+describe('the restart from #118', () => {
+ it('stays Installed with the engine down, because the file is on the disk', () => {
+ // This list is exactly what the app has after a restart: the disk scan, and
+ // nothing else. No session downloads, no engine, no /v1/models.
+ expect(isDiscoverModelInstalled(CYDONIA, NO_DOWNLOADS, ON_DISK)).toBe(true)
+ })
+
+ it('hands back the picker id, so the tile has something to do', () => {
+ // The second half of the ticket: the badge was right and the button was
+ // still dead. A row that knows WHICH model it is can load it.
+ expect(findInstalledForDiscoverModel(CYDONIA, NO_DOWNLOADS, ON_DISK)?.name).toBe(
+ 'openai::Cydonia-24B-v4.1-Q4_K_M',
+ )
+ })
+
+ // Negative control: without disk evidence the badge must NOT light, or every
+ // row in the catalogue would claim to be installed.
+ it('says Get when nothing on the disk matches', () => {
+ expect(isDiscoverModelInstalled(CYDONIA, NO_DOWNLOADS, [])).toBe(false)
+ expect(findInstalledForDiscoverModel(CYDONIA, NO_DOWNLOADS, [])).toBeNull()
+ })
+
+ // Negative control on the matcher's precision: a different quant of the same
+ // model is a different file, and claiming it is installed would send the user
+ // to a chat that cannot load it.
+ it('does not accept a sibling quant as this row', () => {
+ const otherQuant: InstalledModelLike[] = [
+ {
+ provider: 'openai',
+ providerName: 'Built-in Engine',
+ name: 'openai::Cydonia-24B-v4.1-Q8_0',
+ model: 'Cydonia-24B-v4.1-Q8_0',
+ },
+ ]
+ expect(isDiscoverModelInstalled(CYDONIA, NO_DOWNLOADS, otherQuant)).toBe(false)
+ })
+})
+
+describe('the other disk sources keep working', () => {
+ it('an Ollama tag on disk counts, in both the bare and the :latest form', () => {
+ const ollama: InstalledModelLike[] = [{ provider: 'ollama', model: 'llama3.2:latest' }]
+ expect(isDiscoverModelInstalled({ ollamaModel: 'llama3.2' }, NO_DOWNLOADS, ollama)).toBe(true)
+ expect(
+ findInstalledForDiscoverModel({ ollamaModel: 'llama3.2' }, NO_DOWNLOADS, ollama)?.model,
+ ).toBe('llama3.2:latest')
+ // Negative control: a tag nobody pulled stays Get.
+ expect(isDiscoverModelInstalled({ ollamaModel: 'qwen3' }, NO_DOWNLOADS, ollama)).toBe(false)
+ })
+
+ it('an LM Studio entry on disk counts', () => {
+ const lms: InstalledModelLike[] = [
+ { provider: 'openai', providerName: 'LM Studio', model: 'Cydonia-24B-v4.1-Q4_K_M.gguf' },
+ ]
+ expect(isDiscoverModelInstalled(CYDONIA, NO_DOWNLOADS, lms)).toBe(true)
+ })
+
+ it('a download that finished in this session counts before the next refresh', () => {
+ const downloads: DownloadStatuses = { [CYDONIA.filename]: { status: 'complete' } }
+ expect(isDiscoverModelInstalled(CYDONIA, downloads, [])).toBe(true)
+ // ...but it carries no picker id, so the tile keeps the plain badge rather
+ // than offering to load a model it cannot name.
+ expect(findInstalledForDiscoverModel(CYDONIA, downloads, [])?.name).toBeUndefined()
+ // Negative control: a download still running is not an installed model.
+ expect(
+ isDiscoverModelInstalled(CYDONIA, { [CYDONIA.filename]: { status: 'downloading' } }, []),
+ ).toBe(false)
+ })
+})
diff --git a/src/lib/__tests__/model-tile-action.test.ts b/src/lib/__tests__/model-tile-action.test.ts
new file mode 100644
index 00000000..736a2cf7
--- /dev/null
+++ b/src/lib/__tests__/model-tile-action.test.ts
@@ -0,0 +1,77 @@
+/**
+ * GH #118, the dead-button half: "the 'Get' button doesn't do anything as the
+ * files are still downloaded". Once the badge told the truth again, the state
+ * the reporter was left in was an inert "Installed" pill next to an engine that
+ * was not running, and the Models page had no way on at all.
+ *
+ * Run: npx vitest run src/lib/__tests__/model-tile-action.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { modelTileAction, tileActionIsClickable, type ModelTileActionInput } from '../model-tile-action'
+
+const base: ModelTileActionInput = {
+ externalOnly: false,
+ installed: false,
+ downloading: false,
+ loadable: false,
+}
+
+describe('modelTileAction', () => {
+ it('offers Get for a model that is not on the disk', () => {
+ expect(modelTileAction(base)).toBe('get')
+ })
+
+ it('offers Use for an installed model this surface can load', () => {
+ // The ticket's state: the file is there, the engine is not running, and the
+ // tile now leads somewhere instead of ending in a badge.
+ expect(modelTileAction({ ...base, installed: true, loadable: true })).toBe('use')
+ })
+
+ // Negative control: without a picker id there is nothing to load, so the tile
+ // must not promise an action it cannot perform.
+ it('keeps the plain badge when the row cannot be loaded from here', () => {
+ expect(modelTileAction({ ...base, installed: true, loadable: false })).toBe('installed')
+ })
+
+ it('a download in flight outranks the disk answer', () => {
+ expect(modelTileAction({ ...base, installed: true, loadable: true, downloading: true })).toBe(
+ 'downloading',
+ )
+ })
+
+ it('an external-only row can only ever be viewed', () => {
+ expect(
+ modelTileAction({ externalOnly: true, installed: true, downloading: true, loadable: true }),
+ ).toBe('view')
+ })
+})
+
+describe('a tile is never a dead end', () => {
+ it('every reachable state either acts or is already doing the work', () => {
+ const states: ModelTileActionInput[] = []
+ for (const externalOnly of [false, true]) {
+ for (const installed of [false, true]) {
+ for (const downloading of [false, true]) {
+ for (const loadable of [false, true]) {
+ states.push({ externalOnly, installed, downloading, loadable })
+ }
+ }
+ }
+ }
+ for (const s of states) {
+ const action = modelTileAction(s)
+ if (tileActionIsClickable(action)) continue
+ // The two states that legitimately offer no click: a download that is
+ // already running, and an installed row nothing here can load.
+ expect(action === 'downloading' || (action === 'installed' && !s.loadable)).toBe(true)
+ }
+ })
+
+ it('the state from the ticket is clickable', () => {
+ expect(tileActionIsClickable(modelTileAction({ ...base, installed: true, loadable: true }))).toBe(
+ true,
+ )
+ // Negative control: the pre-2.6.8 shape of that same state was not.
+ expect(tileActionIsClickable('installed')).toBe(false)
+ })
+})
diff --git a/src/lib/discover-installed.ts b/src/lib/discover-installed.ts
new file mode 100644
index 00000000..a7069a44
--- /dev/null
+++ b/src/lib/discover-installed.ts
@@ -0,0 +1,100 @@
+/**
+ * Is a Discover row already on this machine, and if so, which local model is it.
+ *
+ * Pulled out of DiscoverModels.tsx (GH #118) because the answer is the whole
+ * bug. nayffy's fresh Windows 11 install downloaded a chat model, the tile said
+ * Installed, a restart flipped it back to "Get", and the button then did
+ * nothing while the multi-gigabyte file sat on the disk the entire time.
+ *
+ * THE RULE, and the reason this file exists: installed is a question about the
+ * DISK, never about a port. Every input below is filesystem evidence:
+ *
+ * - `downloads`: this session's finished downloads, which are files that were
+ * written. Fastest path, gone after a restart, never the only source.
+ * - `installedModels`: what the model refresh read off the disk. For the
+ * built-in engine that list comes from `list_bundled_models`, a Rust
+ * directory scan that does not talk to the engine at all, and for Ollama and
+ * LM Studio from their own on-disk stores.
+ *
+ * Nothing here may ever consult engine health, a `/v1/models` request or a
+ * provider connection state. An engine that is down is a reason to start it,
+ * never a reason to tell the user their 8 GB file is not there.
+ */
+
+import { hfUrlToOllamaRef } from './hf-to-provider'
+import { findLocalGgufInstalled, type InstalledModelLike } from './lmstudio-match'
+
+/** The Discover-row fields this decision needs. */
+export interface InstalledLookupModel {
+ /** GGUF file name of the row, when it names one. */
+ filename?: string
+ /** Direct download URL, used to derive the canonical Ollama reference. */
+ downloadUrl?: string
+ /** Ollama tag, for rows that are Ollama-native. */
+ ollamaModel?: string
+}
+
+/** The download-store shape this decision needs. */
+export type DownloadStatuses = Record<string, { status?: string } | undefined>
+
+/**
+ * The installed model behind a Discover row, or null.
+ *
+ * The returned entry carries the picker id (`name`), which is what turns the
+ * tile's badge into an action: a row that knows WHICH model it is can load it
+ * into the chat.
+ */
+export function findInstalledForDiscoverModel(
+ model: InstalledLookupModel,
+ downloads: DownloadStatuses,
+ installedModels: InstalledModelLike[],
+): InstalledModelLike | null {
+ const installedOllamaTags = installedModels
+ .filter((m) => m.provider === 'ollama')
+ .map((m) => (m.model || m.name || '').toLowerCase())
+
+ const ollamaEntry = (tag: string): InstalledModelLike | null =>
+ installedModels.find(
+ (m) => m.provider === 'ollama' && (m.model || m.name || '').toLowerCase() === tag,
+ ) ?? null
+
+ if (model.ollamaModel) {
+ const tag = model.ollamaModel.toLowerCase()
+ if (installedOllamaTags.includes(tag)) return ollamaEntry(tag)
+ // Ollama appends `:latest` to bare model names — accept either form
+ if (!tag.includes(':') && installedOllamaTags.includes(`${tag}:latest`)) {
+ return ollamaEntry(`${tag}:latest`)
+ }
+ }
+
+ if (model.filename && model.downloadUrl) {
+ const ref = hfUrlToOllamaRef(model.downloadUrl, model.filename)?.toLowerCase()
+ if (ref && installedOllamaTags.includes(ref)) return ollamaEntry(ref)
+ }
+
+ // LM Studio AND the built-in engine, both read off the disk. The matcher
+ // (lib/lmstudio-match.ts) bridges the id forms: LM Studio's basename ids and
+ // its modern quant-less publisher/short key, and the built-in engine's file
+ // stem.
+ if (model.filename) {
+ const local = findLocalGgufInstalled(model.filename, installedModels)
+ if (local) return local
+ }
+
+ // A download that finished in THIS session is a file on the disk too, and it
+ // is the only evidence that exists before the next model refresh runs. It
+ // comes last because it carries no picker id, so an entry from the disk scan
+ // is always the more useful answer.
+ if (model.filename && downloads[model.filename]?.status === 'complete') return {}
+
+ return null
+}
+
+/** The badge question, unchanged in meaning from the pre-2.6.8 closure. */
+export function isDiscoverModelInstalled(
+ model: InstalledLookupModel,
+ downloads: DownloadStatuses,
+ installedModels: InstalledModelLike[],
+): boolean {
+ return findInstalledForDiscoverModel(model, downloads, installedModels) !== null
+}
diff --git a/src/lib/lmstudio-match.ts b/src/lib/lmstudio-match.ts
index 53d3a94b..9c83e1b3 100644
--- a/src/lib/lmstudio-match.ts
+++ b/src/lib/lmstudio-match.ts
@@ -90,7 +90,7 @@ export function matchesLmStudioInstalled(
filename: string,
installed: InstalledModelLike[],
): boolean {
- return matchesInstalled(filename, installed.filter(isLmStudioEntry))
+ return !!findInstalled(filename, installed.filter(isLmStudioEntry))
}
/**
@@ -109,11 +109,28 @@ export function matchesLocalGgufInstalled(
filename: string,
installed: InstalledModelLike[],
): boolean {
- return matchesInstalled(filename, installed.filter((m) => isLmStudioEntry(m) || isBuiltinEntry(m)))
+ return !!findLocalGgufInstalled(filename, installed)
}
-function matchesInstalled(filename: string, lms: InstalledModelLike[]): boolean {
- if (!filename) return false
+/**
+ * The same question, answering WHICH entry matched instead of just whether one
+ * did.
+ *
+ * GH #118, the dead-button half: a tile that knows a model is installed but not
+ * which installed model it is has nothing to offer beyond a badge. The picker
+ * id lives on the entry, so handing the entry back is what lets the tile load
+ * the model into the chat instead of showing an inert "Installed" pill next to
+ * an engine that is not running.
+ */
+export function findLocalGgufInstalled(
+ filename: string,
+ installed: InstalledModelLike[],
+): InstalledModelLike | null {
+ return findInstalled(filename, installed.filter((m) => isLmStudioEntry(m) || isBuiltinEntry(m)))
+}
+
+function findInstalled(filename: string, lms: InstalledModelLike[]): InstalledModelLike | null {
+ if (!filename) return null
const wantBase = normalBase(filename)
const wantId = modelIdentity(filename)
const wantQuant = extractQuant(filename)
@@ -127,18 +144,18 @@ function matchesInstalled(filename: string, lms: InstalledModelLike[]): boolean
const cBase = c.replace(/\.gguf$/, '').replace(SHARD_TAIL, '')
// (1) exact / path-suffix — full basename ids, already carry the quant
if (cBase === wantBase || cBase.endsWith(`/${wantBase}`) || cBase.endsWith(`\\${wantBase}`)) {
- return true
+ return m
}
// (2) normalised identity + quant agreement
const cId = modelIdentity(c)
if (cId && wantId && cId.length >= 5 && cId === wantId) {
- if (!wantQuant) return true // generic Discover entry (no quant) → match
+ if (!wantQuant) return m // generic Discover entry (no quant) → match
const cQuant = extractQuant(c)
- if (cQuant && cQuant === wantQuant) return true // exact quant present
+ if (cQuant && cQuant === wantQuant) return m // exact quant present
// quant-specific Discover row but candidate quant missing/different →
// do NOT light (avoids quant-sibling false positives).
}
}
}
- return false
+ return null
}
diff --git a/src/lib/model-tile-action.ts b/src/lib/model-tile-action.ts
new file mode 100644
index 00000000..dd942faf
--- /dev/null
+++ b/src/lib/model-tile-action.ts
@@ -0,0 +1,51 @@
+/**
+ * What the one button on a Discover tile does, for every state a tile can be in.
+ *
+ * GH #118 (nayffy, 2026-08-27): "the Get button doesn't do anything as the
+ * files are still downloaded". Two halves. The badge was wrong, which the
+ * filesystem rule in lib/discover-installed.ts fixes, and the right badge was
+ * an inert pill: a text model that IS installed showed "Installed" and offered
+ * nothing, so a user whose engine was not running had no way forward from the
+ * Models page at all. A tile that knows the file is on the disk can load it.
+ *
+ * Pure so the rule "a tile is never a dead end" can be asserted directly.
+ */
+
+export type ModelTileAction =
+ /** No download URL: the row can only be opened on the web. */
+ | 'view'
+ /** A download is in flight. Waiting IS the state, and it shows progress. */
+ | 'downloading'
+ /** On the disk, and this surface can load it into the chat. */
+ | 'use'
+ /** On the disk, and loading it is not this surface's job (image/video). */
+ | 'installed'
+ /** Not on the disk. */
+ | 'get'
+
+export interface ModelTileActionInput {
+ /** Catalogue row without a usable download URL. */
+ externalOnly: boolean
+ /** Filesystem evidence only, never engine reachability. */
+ installed: boolean
+ downloading: boolean
+ /** Does the caller know WHICH local model this row is, so it can be loaded. */
+ loadable: boolean
+}
+
+/**
+ * Order matters: an external row can never be downloaded, a download in flight
+ * outranks everything else, and only then does the disk decide.
+ */
+export function modelTileAction(input: ModelTileActionInput): ModelTileAction {
+ if (input.externalOnly) return 'view'
+ if (input.downloading) return 'downloading'
+ if (input.installed) return input.loadable ? 'use' : 'installed'
+ return 'get'
+}
+
+/** True when the state offers the user something to click. `downloading` is
+ * the one state that legitimately does not: it is already doing the thing. */
+export function tileActionIsClickable(action: ModelTileAction): boolean {
+ return action !== 'downloading' && action !== 'installed'
+}