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(header): clear stale-chip when switching to fresh model + CLAUDE.md #97

PurpleDoubleD1a9a218ac147
diff --git a/CLAUDE.md b/CLAUDE.md
index ee82f491..7ebcb09e 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -174,6 +174,10 @@ src-tauri/src/commands/ — Rust commands: install, process, download, prox
95. **UI polish (commit 0a82260)** — Sidebar "Soon" tag now replaces label text (was floating above). Downloads + Light/Dark restored to icons. Header nav text matched to sidebar tabs (`text-[0.6rem]`). Qwen 3.6 download button works via `ollamaModel` → `pullModel()` in `handleTextDownload`.
+96. **Ollama 0.20.7 / 0.21 stale-manifest hotfix (commit ad29b2c, 2026-04-19)** — Users on auto-upgraded Ollama (0.20.6→0.20.7, now 0.21.0) found their pre-existing models rejected: 0.20.x returned HTTP 400 `"<model>" does not support chat/generate/completion`, 0.21 returns HTTP 404 `model '<name>' not found` for the same underlying cause (on-disk manifest missing runtime `capabilities` field). All chats with those models errored out with no clear action path. Fix: (a) `parseOllamaError` tolerates all three forms (400, 404, Rust-proxy fake-500 wrap), plus exported `parseShowNotFound` for scanner disambiguation against `/api/tags`. (b) `checkModelCapability` probes via `/api/show` (fast, ~100 ms, no VRAM) instead of `/api/generate` which triggers a runner load. (c) New `modelHealthStore` (persists stale-list + `lastScanTime`, session-only `dismissed`). (d) `StaleModelsBanner` top-of-app notice with serial "Refresh all"; each re-pull verifies via a second probe before `markFresh`. (e) Header Lichtschalter shows red pulsing state with inline `Refresh` chip, toggle disabled until re-pull succeeds. (f) `AppShell` one-shot scan 3 s after startup (sessionStorage-gated, silent on connection failure). (g) 23 new tests: `ollama-capability-check.test.ts`, `modelHealthStore.test.ts`, `ollama-errors.test.ts` extended for namespaced models + fake-500 wraps. Pre-existing orphan bugs bundled in the same commit: `CodeBlock.isHtmlSnippet` missing export (19 failing tests green), `comfyui.getKnownFileSizes` replaced CommonJS `require('../api/discover')` with dynamic `import('./discover')` (Create view was silently broken in Vite/browser bundle — `require is not defined` swallowed by `useCreate` catch), `model-pipeline.test` flux2 CFG corrected from 3.5 → 1.0 (Z-Image is the 3.5 model; test comment was a copy-paste). Full suite 2144/2144 green, tsc/cargo green. Version stays at 2.3.3 per policy.
+
+97. **Stale-chip state leak fix (follow-up to #96, 2026-04-19)** — E2E test on the installed build surfaced a UX leak: after selecting a stale model (phi4:14b → red Lichtschalter + "stale — refresh?" chip), switching back to a FRESH model (qwen2.5-coder:3b) left both the red toggle and the stale chip visible on the fresh model. Root cause: `Header.tsx` `useEffect` only SET `staleError` when the current model was stale — never cleared it on switch to a fresh model, and never re-pinned the model name when switching between two different stale models. Fix: the effect now (a) clears `staleError` when model goes fresh, (b) re-pins `staleError.model` if the chip was for a different stale model than the current one, (c) clears on `!modelToUse || !isOllamaModel`. All other E2E flows verified on installed build: Ollama chat (qwen2.5-coder answered 2+2=4), Agent Mode (`get_current_time` → "2026-04-19"), Codex multi-step (`file_write` + `shell_execute` + `get_current_time` chain created test-release.txt), Compare/Benchmark/Settings/Model Manager/Create UIs all render, ComfyUI pipeline starts (Z-Image Turbo loaded correctly at 12 steps CFG 3.5).
+
### What's LEFT to finish v2.3.0:
1. **Tauri proxy_localhost investigation** — reqwest in Tauri subprocess can't reach localhost. Direct fetch workaround now also primary path for streaming via #79a. Root cause still unknown. Low priority.
2. **LTX VAEDecode reference** — dynamic-workflow.ts line 263: vaeSourceId incorrectly points to UNETLoader output for LTX strategy. Fix when LTX model is installed for testing.
diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx
index de799bcc..ef7bf960 100644
--- a/src/components/layout/Header.tsx
+++ b/src/components/layout/Header.tsx
@@ -101,9 +101,26 @@ export function Header() {
// When the startup health scan flags this model as stale, pre-populate the
// chip so the user sees it WITHOUT having to click the broken toggle first.
+ // Also clear the chip when the user switches to a fresh model, OR when the
+ // chip was pinned to a DIFFERENT model than the one currently selected
+ // (otherwise the red Lichtschalter and chip from the old stale model
+ // leak onto the new fresh model).
useEffect(() => {
- if (!modelToUse || !isOllamaModel) return
- if (healthStaleModels.includes(modelToUse) && !staleError) {
+ if (!modelToUse || !isOllamaModel) {
+ if (staleError) setStaleError(null)
+ return
+ }
+ const isStale = healthStaleModels.includes(modelToUse)
+ if (isStale && !staleError) {
+ setStaleError({
+ model: modelToUse,
+ message: `Model "${modelToUse}" has a stale manifest. Run "ollama pull ${modelToUse}" to refresh.`,
+ })
+ } else if (!isStale && staleError) {
+ // User switched to a fresh model — drop the stale chip from the previous one.
+ setStaleError(null)
+ } else if (staleError && staleError.model !== modelToUse) {
+ // Stale chip was for a different model; re-pin to the current one (it's stale too).
setStaleError({
model: modelToUse,
message: `Model "${modelToUse}" has a stale manifest. Run "ollama pull ${modelToUse}" to refresh.`,