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
release: v2.4.1 — CreateTopControls picker bulletproof
PurpleDoubleD4e87cb8211e5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0e7437a5..cdddcda0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,26 @@All notable changes to Locally Uncensored are documented here.+## [2.4.1] - 2026-04-24++### Fixed+- **CreateTopControls: picker dropdown hardened against any non-array list value** — reported on Discord by @phantomderp on the `#bug-reports` channel: "the web ui crashes when clicking on the model list at the top in the create tab". His workaround was to patch `activeList?.map(...)` in the source, which stopped the crash but "the list doesn't work anymore" because the `.length` branch above still evaluates on undefined. We already did the straightforward fix in v2.3.9 / v2.4.0 (added `imageModelList` / `videoModelList` to `createStore` as runtime-only state, populated by `useCreate.fetchModels`), but there's still a pathological path where the field arrives as something other than an array: stale persisted state from a very old install, Zustand rehydration racing the first render of `CreateTopControls`, a corrupted localStorage entry from an external tool, or simply an old .exe that predates aa31bab. The read site now passes the list through `Array.isArray(rawList) ? rawList : []`, so undefined / null / object / string / number / anything weird all render as the empty-state card instead of taking the app down.++### Tests+- Test suite 2216 → 2226 (+7 regression tests in `createStore.test.ts` — new "activeList fallback contract (mirrors CreateTopControls)" describe block covers undefined / null / object-with-wrong-shape / string / real-populated-array cases, plus a `.length && .map never throw on the fallback` guard).++### Verification+- `vitest`: 2226 / 2226 green+- `tsc --noEmit`: clean+- Bundled JS contains the fix (grep-confirmed `Array.isArray(h)?h:[]` in the minified `index-*.js`)+- Dev-preview E2E: injected undefined / null / `{}` / `"corrupted"` / `42` / populated-array into the store and clicked the picker — zero errors across all six scenarios+- Installed-binary E2E, happy-path: Ollama + ComfyUI running with 3 image + 3 video models — picker shows all 6 models, no crash in either mode+- Installed-binary E2E, true fresh-user simulation: Ollama folder renamed, ComfyUI folder renamed, LU AppData wiped — picker shows "Start ComfyUI to load models" empty-state, no crash in either mode; Chat / Create / Compare / Benchmark / Models / Settings all load cleanly from fresh install++### Notes+- Drop-in upgrade from v2.4.0. No breaking changes, no localStorage migration. Existing users auto-update on next launch.+- Single-file behavior fix + tests — no new features, no dependency bumps. If you were already on v2.4.0 with working model lists, you won't see a behavior change.+## [2.4.0] - 2026-04-23### Fixeddiff --git a/README.md b/README.mdindex 9aa661b5..c13bc7ef 100644--- a/README.md+++ b/README.md@@ -35,82 +35,25 @@ No cloud. No data collection. No API keys. Auto-detects 12 local backends. Your----## v2.3.9 — Current Release+## v2.4.1 — Current Release-**UX safety net: Create view no longer crashes when no image or video models are installed. Small docs refresh.**+**Reliability hotfix: bulletproof the Create model picker against any pathological store state.**-Drop-in patch on top of v2.3.8.+Drop-in patch on top of v2.4.0. One focused fix — no new features, no dependency bumps.### What's fixed-- **Create view: clean empty-state instead of a crash when no models are installed** — if you opened Create before downloading any ComfyUI model, the Create tab could go from unresponsive to a hard shutdown ("program disappears and a duplicate reopens"). Surfaced on Discord by @figuringitallout on a fresh Windows install. Root causes, both fixed: (1) `classifyModel()` was called with stale persisted model names that no longer existed on disk, (2) the main content area kept rendering `OutputDisplay` / `PromptInput` / `ParamPanel` against an empty model list. Create now detects this state and renders a calm empty-state card with a primary **Go to Model Manager** CTA and a **Refresh list** secondary action. Mode switcher stays available. Stale persisted image/video model names are proactively cleared by `useCreate.fetchModels` when ComfyUI reports 0 models in that category.-- **App always starts in the Chat tab on boot, not Code** — `codexStore` used to persist `chatMode` between sessions, so users who happened to end their last session in Codex / Claude Code would re-open the app inside an empty coding panel instead of the Chat homepage. Newcomers in particular landed in Code without any visible conversations and thought the app was broken. Fixed by excluding `chatMode` from the persisted slice — default `'lu'` (Chat) is used on every fresh boot; pick Code or Remote from the sidebar each session when you want them.-- **Header-level Create toggle + dropdown no longer crash on click** — the Lichtschalter and model picker in the app header (when you're on Create) used to crash with `TypeError: activeList is undefined` / `setComfyRunning is not a function`. Reported on Discord by @diimmortalis with a clean console-log dump. Four store fields (`imageModelList`, `videoModelList`, `comfyRunning`, `setComfyRunning`) that the component expected were never actually in the store — now they are, and they're populated by the same `useCreate.fetchModels` / `checkConnection` path the main Create view uses.-- **Backend Selector modal no longer reopens every 5-10 seconds** — users with multiple local backends (Ollama + LM Studio, Ollama + vLLM, etc) reported on Discord that the "N local backends detected" modal kept re-appearing no matter how often they dismissed it. Fix: a persistent `hideBackendSelector` flag in `providerStore`, a pre-checked "Don't show this again" tickbox in the modal, and a permanent pointer to **Settings → Providers** (clickable — it navigates you there) so users know where to manage providers going forward.-- **`classifyModel(name)` is null-safe** — defensive guard returns `unknown` if called with `null`, `undefined`, or non-string, so any path that reaches the classifier with a stale or missing model name degrades gracefully.-- **CONTRIBUTING.md dev workflow documented** — `npm run tauri:dev` / `npm run tauri:build` / `npm run dev` are now spelled out with the trade-off between them. Reported in Discord by @k-wilkinson (sourceodin) — thanks.+- **CreateTopControls picker dropdown hardened against any non-array list value** — reported on Discord in `#bug-reports` by @phantomderp: the web UI crashes when clicking the model picker at the top of the Create tab. We'd already added the expected store fields + setters in v2.3.9/v2.4.0 (`imageModelList`, `videoModelList`, `comfyRunning`, `setComfyRunning`), but if the field ever arrives as anything other than an array — stale persisted state from a very old install, Zustand rehydration racing the first render, a corrupted localStorage entry, or an old .exe that predates aa31bab — the `.length` / `.map()` calls would still kill the app on picker-open. Read site now passes the list through `Array.isArray(rawList) ? rawList : []`, so undefined / null / object / string / number all render as the empty-state card instead of crashing.### Stability-- 2202 / 2202 Vitest tests green-- `cargo check` clean+- 2226 / 2226 Vitest tests green (+7 new pathological-state regression tests in `createStore.test.ts`)- `tsc --noEmit` clean-- No breaking changes, no localStorage migration. Existing users see zero behavior change unless they previously hit the Create-with-no-models crash path.+- Bundled JS contains the fix (grep-confirmed in the minified bundle)+- Dev-preview E2E: injected six pathological types into the store (`undefined`, `null`, `{}`, `"corrupted"`, `42`, populated array), clicked the picker each time — zero errors+- Installed-binary E2E, happy path: Ollama + ComfyUI + 3 image + 3 video models — picker opens with all six, no crash either mode+- Installed-binary E2E, true fresh-user: Ollama folder renamed, ComfyUI folder renamed, LU AppData wiped — picker shows "Start ComfyUI to load models" empty-state, no crash either mode; all six tabs (Chat / Create / Compare / Benchmark / Models / Settings) load cleanly+- No breaking changes, no localStorage migration — upgrade in place-## v2.3.8 — Previous Release--**Internal plumbing + UX polish. Drop-in patch on top of v2.3.7.**--No new headline features this release — internal stability work so future feature releases have a cleaner foundation.--### What's in this build-- **Built-in tool executors now thread the active chat-id through to the Rust backend** — `agent-context.ts` was designed for per-chat workspace isolation but the frontend executors (`fs_read`/`fs_write`/`fs_list`/`fs_search`/`shell_execute`/`execute_code`) never actually passed the id through, so relative paths silently landed in a shared fallback folder. Fixed end-to-end.-- **More robust tool-call JSON extraction** — the old greedy `\{[^}]*\}` regex failed on any nested brace or string value containing `{` (e.g. Python f-strings `f'Hello, {name}!'`). Replaced with a locate-header-then-balance scanner that respects string escapes. Fixes models that emit tool calls as JSON in `content` when the emitted code uses f-strings or dict literals.-- **Cleaner chat bubbles across models that emit tool calls in content** — new `stripRanges()` helper uses the balanced-brace positions the extractor already computes to remove the exact tool-call JSON substrings instead of a greedy regex that missed edge cases. No more stacked raw-JSON bubbles.-- **Concrete arg-validator error hints** — retry message now lists the exact required fields with types + the keys the model actually sent, so small models self-correct on the next iteration instead of repeating the same malformed call.-- **Family grouping in the model dropdown** (QWEN / GEMMA / LLAMA / HERMES / PHI / DOLPHIN / MISTRAL / DEEPSEEK / …) with reactive refresh when any provider's enabled state changes.-- **Development-only diagnostic code removed from the release binary** — devtools flag off for production, no file-writing loggers.--### Stability-- 2202 / 2202 Vitest tests green-- `cargo check` clean-- `tsc --noEmit` clean-- Drop-in upgrade from v2.3.7, no breaking changes, no localStorage migration--### Known work in progress-Codex (the coding-agent tab) is under active development. Several improvements landed in this release but the feature is still evolving — do not yet treat Codex as production-finished. Chat, Create, Agent Mode, and Remote remain stable.--### What's still in v2.3.8 from v2.3.7-v2.3.7's remote Ollama + `OLLAMA_HOST` env var support, v2.3.6's configurable ComfyUI host, LM Studio / OpenAI-compat CORS fix, and ComfyUI port persistence all remain in place.--### Remote Access + Mobile Web App-- **Access your AI from your phone** — Dispatch via LAN or Cloudflare Tunnel (Internet)-- **Full mobile web app** — Hamburger drawer, chat list, Codex mode, file attach, thinking toggle, Plugins (Caveman + Personas)-- **Mobile Agent Mode** — 13 tools with Thought/Action/Observation cards-- **Security hardened** — 6-digit passcodes, rate limiting, JWT auth, permissions enforced, CSP headers--### Codex Coding Agent — Major Upgrade-- **Live streaming** between tool calls — see tokens as they generate-- **Continue capability** — tool-call history persisted, model remembers previous actions-- **AUTONOMY CONTRACT** — model completes ALL steps without premature stopping-- **Fallback answer** — never shows empty bubble after tool calls--### Agent Mode — 13-Phase Rewrite-- **Parallel tool execution** with side-effect grouping-- **Budget system** — max 50 tool calls / 25 iterations per task-- **Sub-agent delegation** — `delegate_task` spawns isolated sub-agents-- **MCP integration** — external tools via ToolRegistry-- **Filesystem awareness** — agent uses file_list/system_info before acting--### New Models + Image Gen-- **Qwen 3.6** (day-0) — 35B MoE, vision + agentic coding + thinking. One-click download-- **ERNIE-Image** (Baidu) — Turbo (8 steps) + Base (50 steps). Plug & play, no custom nodes-- **Image-to-Image** — Upload source, adjust denoise, transform with any model-- **75+ downloadable models** — all URLs verified--### UI/UX-- **AE-style text header** — clean typography for better discoverability-- **Plugins dropdown** — Caveman Mode + Personas in one menu-- **Thinking mode** — tri-state, auto-retry, universal tag stripper-- **2166 tests** — comprehensive smoke tests covering the entire app+For older releases, see [CHANGELOG.md](CHANGELOG.md).---diff --git a/docs/index.html b/docs/index.htmlindex 074aaacd..4b4c80e5 100644--- a/docs/index.html+++ b/docs/index.html@@ -33,7 +33,7 @@<link rel="icon" href="https://locallyuncensored.com/favicon.png"><link rel="apple-touch-icon" href="https://locallyuncensored.com/favicon.png"><script type="application/ld+json">-{"@context":"https://schema.org","@type":"SoftwareApplication","name":"Locally Uncensored","alternateName":["LU","Locally Uncensored Desktop App"],"applicationCategory":"DeveloperApplication","applicationSubCategory":"Artificial Intelligence","operatingSystem":"Windows 10, Windows 11, Linux","description":"Open-source desktop app for running AI locally. Chat with 20+ providers, generate images and video via ComfyUI, and code with a built-in AI agent — all on your own hardware. Auto-detects 12 local backends. No cloud, no telemetry.","url":"https://locallyuncensored.com/","downloadUrl":"https://github.com/PurpleDoubleD/locally-uncensored/releases/latest","softwareVersion":"2.4.0","license":"https://www.gnu.org/licenses/agpl-3.0.html","author":{"@type":"Person","name":"PurpleDoubleD","url":"https://github.com/PurpleDoubleD"},"offers":{"@type":"Offer","price":"0","priceCurrency":"USD","availability":"https://schema.org/InStock"},"featureList":["Plug & Play Setup with 12 Local Backend Auto-Detection (Ollama, LM Studio, vLLM, KoboldCpp, Jan, llama.cpp, LocalAI, GPT4All, TabbyAPI, Aphrodite, SGLang, TGI)","20+ Provider Presets (local + cloud)","Qwen 3.6 Day-0 Support (35B MoE, Vision, Agentic Coding, 256K context)","GPT-OSS Compatible (120B, 20B via Ollama)","GLM-4.7 Flash Integration","DeepSeek R1 and DeepSeek V3 Support","Llama 4 and Llama 3.3 Ready","Gemma 4 E4B and 27B (Native Vision)","Mistral Small 3 and Phi 4 Support","Qwen 3 Coder and Qwen 2.5 Coder","Abliterated Model Variants","Codex Coding Agent with Live Streaming and Apply-Patch","Claude Code CLI Integration","Agent Mode with 14 Tools, Parallel Execution, MCP, Sub-Agent Delegation","Remote Access from Phone via LAN or Cloudflare Tunnel (6-digit Passcode, QR Setup)","Mobile Web App (Chat, Codex, Tools, Plugins)","Image Generation via ComfyUI (FLUX 2 Klein, FLUX.1, Juggernaut XL, Z-Image Turbo, ERNIE-Image, SDXL, SD 3.5)","Video Generation (Wan 2.1, Wan 2.2, HunyuanVideo 1.5, LTX 2.3, FramePack F1, AnimateDiff, CogVideoX)","Image-to-Image with Denoise Control","Image-to-Video (FramePack F1, CogVideoX, SVD)","Granular Permission System (7 Tool Categories)","File Upload with Vision Support","Thinking Mode with Universal Tag Stripping","A/B Model Compare","Local Benchmark","Memory System and Document RAG","Voice (STT / TTS)","Auto-Update over Signed NSIS Channel","75+ One-Click Model Downloads","Hardware-Aware Model Recommendations","100% Offline and Private (No Telemetry)","AGPL-3.0 Open Source"],"screenshot":"https://raw.githubusercontent.com/PurpleDoubleD/locally-uncensored/master/docs/social-preview.png","softwareRequirements":"Any OpenAI-compatible local backend (Ollama, LM Studio, vLLM, KoboldCpp, etc.) or cloud API key","memoryRequirements":"8 GB RAM minimum; 8-16 GB VRAM for image/video generation","storageRequirements":"6 GB for default model"}+{"@context":"https://schema.org","@type":"SoftwareApplication","name":"Locally Uncensored","alternateName":["LU","Locally Uncensored Desktop App"],"applicationCategory":"DeveloperApplication","applicationSubCategory":"Artificial Intelligence","operatingSystem":"Windows 10, Windows 11, Linux","description":"Open-source desktop app for running AI locally. Chat with 20+ providers, generate images and video via ComfyUI, and code with a built-in AI agent — all on your own hardware. Auto-detects 12 local backends. No cloud, no telemetry.","url":"https://locallyuncensored.com/","downloadUrl":"https://github.com/PurpleDoubleD/locally-uncensored/releases/latest","softwareVersion":"2.4.1","license":"https://www.gnu.org/licenses/agpl-3.0.html","author":{"@type":"Person","name":"PurpleDoubleD","url":"https://github.com/PurpleDoubleD"},"offers":{"@type":"Offer","price":"0","priceCurrency":"USD","availability":"https://schema.org/InStock"},"featureList":["Plug & Play Setup with 12 Local Backend Auto-Detection (Ollama, LM Studio, vLLM, KoboldCpp, Jan, llama.cpp, LocalAI, GPT4All, TabbyAPI, Aphrodite, SGLang, TGI)","20+ Provider Presets (local + cloud)","Qwen 3.6 Day-0 Support (35B MoE, Vision, Agentic Coding, 256K context)","GPT-OSS Compatible (120B, 20B via Ollama)","GLM-4.7 Flash Integration","DeepSeek R1 and DeepSeek V3 Support","Llama 4 and Llama 3.3 Ready","Gemma 4 E4B and 27B (Native Vision)","Mistral Small 3 and Phi 4 Support","Qwen 3 Coder and Qwen 2.5 Coder","Abliterated Model Variants","Codex Coding Agent with Live Streaming and Apply-Patch","Claude Code CLI Integration","Agent Mode with 14 Tools, Parallel Execution, MCP, Sub-Agent Delegation","Remote Access from Phone via LAN or Cloudflare Tunnel (6-digit Passcode, QR Setup)","Mobile Web App (Chat, Codex, Tools, Plugins)","Image Generation via ComfyUI (FLUX 2 Klein, FLUX.1, Juggernaut XL, Z-Image Turbo, ERNIE-Image, SDXL, SD 3.5)","Video Generation (Wan 2.1, Wan 2.2, HunyuanVideo 1.5, LTX 2.3, FramePack F1, AnimateDiff, CogVideoX)","Image-to-Image with Denoise Control","Image-to-Video (FramePack F1, CogVideoX, SVD)","Granular Permission System (7 Tool Categories)","File Upload with Vision Support","Thinking Mode with Universal Tag Stripping","A/B Model Compare","Local Benchmark","Memory System and Document RAG","Voice (STT / TTS)","Auto-Update over Signed NSIS Channel","75+ One-Click Model Downloads","Hardware-Aware Model Recommendations","100% Offline and Private (No Telemetry)","AGPL-3.0 Open Source"],"screenshot":"https://raw.githubusercontent.com/PurpleDoubleD/locally-uncensored/master/docs/social-preview.png","softwareRequirements":"Any OpenAI-compatible local backend (Ollama, LM Studio, vLLM, KoboldCpp, etc.) or cloud API key","memoryRequirements":"8 GB RAM minimum; 8-16 GB VRAM for image/video generation","storageRequirements":"6 GB for default model"}</script><script type="application/ld+json">{"@context":"https://schema.org","@type":"Organization","name":"PurpleDoubleD","url":"https://github.com/PurpleDoubleD","logo":"https://locallyuncensored.com/logos/LU-monogram-bw-transparent.png","sameAs":["https://github.com/PurpleDoubleD","https://github.com/PurpleDoubleD/locally-uncensored","https://reddit.com/user/GroundbreakingMall54","https://locallyuncensored.com"]}@@ -827,7 +827,7 @@ footer a:hover{color:var(--fg)}<!-- Top meta strip --><div class="mast-strip">- <span class="numero">v 2.4.0</span>+ <span class="numero">v 2.4.1</span><span class="sep">·</span><span>AGPL-3.0</span><span class="sep">·</span>@@ -868,10 +868,10 @@ footer a:hover{color:var(--fg)}<div class="container"><div class="dl-card"><div class="dl-info">- <h3>Locally Uncensored <em>— 2.4.0</em></h3>+ <h3>Locally Uncensored <em>— 2.4.1</em></h3><p>WINDOWS · ~7 MB installer · AGPL-3.0</p></div>- <a class="dl-btn" href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.4.0/Locally.Uncensored_2.4.0_x64-setup.exe" download>+ <a class="dl-btn" href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.4.1/Locally.Uncensored_2.4.1_x64-setup.exe" download><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>Download .exe</a>@@ -1168,10 +1168,10 @@ footer a:hover{color:var(--fg)}<div class="narrow"><div class="dl-card"><div class="dl-info">- <h3>Locally Uncensored <em>— 2.4.0</em></h3>+ <h3>Locally Uncensored <em>— 2.4.1</em></h3><p>WINDOWS · ~7 MB installer · AGPL-3.0</p></div>- <a class="dl-btn" href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.4.0/Locally.Uncensored_2.4.0_x64-setup.exe" download>+ <a class="dl-btn" href="https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v2.4.1/Locally.Uncensored_2.4.1_x64-setup.exe" download><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>Download .exe</a>diff --git a/docs/llms.txt b/docs/llms.txtindex 907f0a38..686994ba 100644--- a/docs/llms.txt+++ b/docs/llms.txt@@ -6,7 +6,7 @@ Locally Uncensored is a free, open-source (AGPL-3.0) desktop application that co## Key Facts- Name: Locally Uncensored-- Current Version: v2.4.0 (April 23, 2026)+- Current Version: v2.4.1 (April 24, 2026)- Type: Desktop AI Application- License: AGPL-3.0 (free and open source)- Platforms: Windows 10/11, Linux (deb, rpm, AppImage)diff --git a/package.json b/package.jsonindex b1bb16e8..cf654846 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "locally-uncensored",- "version": "2.4.0",+ "version": "2.4.1","private": false,"description": "Generate anything — text, images, video. Locally. Uncensored.","license": "AGPL-3.0",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 9597a2ef..d916b492 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "locally-uncensored"-version = "2.4.0"+version = "2.4.1"description = "Private, local AI chat & image/video generation"authors = ["purpledoubled"]edition = "2021"diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex f4def254..cb3471b5 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -1,7 +1,7 @@{"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json","productName": "Locally Uncensored",- "version": "2.4.0",+ "version": "2.4.1","identifier": "com.purpledoubled.locally-uncensored","build": {"beforeBuildCommand": "npm run build",diff --git a/src/components/create/CreateTopControls.tsx b/src/components/create/CreateTopControls.tsxindex fd60f5a9..2d0db6c2 100644--- a/src/components/create/CreateTopControls.tsx+++ b/src/components/create/CreateTopControls.tsx@@ -66,7 +66,15 @@ export function CreateTopControls() {}}, [])- const activeList = mode === 'image' ? imageModelList : videoModelList+ // Bulletproof: reported on Discord by @phantomderp (2026-04-24) and+ // @diimmortalis (2026-04-22) — opening the picker crashes the app when+ // the list field is not an array. Can happen with stale persisted state+ // from a very old LU install, Zustand rehydration racing the first render,+ // a corrupted localStorage entry, or an old .exe that predates aa31bab.+ // `Array.isArray` catches undefined / null / object / string — anything+ // weird — and hands the render a safe empty array.+ const rawList = mode === 'image' ? imageModelList : videoModelList+ const activeList = Array.isArray(rawList) ? rawList : []const activeModel = mode === 'image' ? imageModel : videoModelconst onPickModel = (name: string) => {if (mode === 'image') {diff --git a/src/stores/__tests__/createStore.test.ts b/src/stores/__tests__/createStore.test.tsindex 6ebe24ef..0e214d9e 100644--- a/src/stores/__tests__/createStore.test.ts+++ b/src/stores/__tests__/createStore.test.ts@@ -113,6 +113,110 @@ describe('createStore', () => {expect(state.gallery).toEqual([])expect(state.promptHistory).toEqual([])})++ // Regression: CreateTopControls (header dropdown) reads these fields+ // directly. If they're undefined, `activeList.length` / `.map()` crash+ // the whole app. Reported on Discord by @diimmortalis (v2.3.9) and+ // @phantomderp (v2.4.0). Defensive `?? []` lives in CreateTopControls,+ // but the store itself must also hand out safe defaults.+ it('initializes imageModelList, videoModelList, comfyRunning', () => {+ // Force a clean construction so we bypass the INITIAL_STATE merge that+ // beforeEach does (INITIAL_STATE intentionally omits these to prove the+ // setter/getter contract without leaning on the initial-state defaults).+ useCreateStore.setState({+ imageModelList: [],+ videoModelList: [],+ comfyRunning: false,+ })+ const state = useCreateStore.getState()+ expect(Array.isArray(state.imageModelList)).toBe(true)+ expect(Array.isArray(state.videoModelList)).toBe(true)+ expect(state.imageModelList).toEqual([])+ expect(state.videoModelList).toEqual([])+ expect(state.comfyRunning).toBe(false)+ })++ it('setImageModelList / setVideoModelList replace the lists', () => {+ const imgs = [+ { name: 'flux-schnell.safetensors', type: 'flux' as const },+ { name: 'sdxl-base.safetensors', type: 'sdxl' as const },+ ]+ const vids = [{ name: 'wan-2.1.safetensors', type: 'wan' as const }]+ useCreateStore.getState().setImageModelList(imgs)+ useCreateStore.getState().setVideoModelList(vids)+ expect(useCreateStore.getState().imageModelList).toEqual(imgs)+ expect(useCreateStore.getState().videoModelList).toEqual(vids)+ })++ it('setComfyRunning toggles the flag', () => {+ useCreateStore.getState().setComfyRunning(true)+ expect(useCreateStore.getState().comfyRunning).toBe(true)+ useCreateStore.getState().setComfyRunning(false)+ expect(useCreateStore.getState().comfyRunning).toBe(false)+ })++ // Pathological-state regression: reproduce @phantomderp's crash from+ // multiple angles. The defensive `Array.isArray` guard in+ // CreateTopControls is the real fix, but the store APIs must keep+ // returning *something* when setState is called with garbage. These+ // tests document the contract: the store does not throw, and its+ // CONSUMERS (which this mirrors) can always fall back to [].+ describe('activeList fallback contract (mirrors CreateTopControls)', () => {+ const computeActiveList = (mode: string, iml: unknown, vml: unknown) => {+ const raw = mode === 'image' ? iml : vml+ return Array.isArray(raw) ? raw : []+ }++ it('falls back to [] when imageModelList is undefined', () => {+ useCreateStore.setState({ imageModelList: undefined as any, mode: 'image' })+ const s = useCreateStore.getState()+ expect(computeActiveList(s.mode, s.imageModelList, s.videoModelList)).toEqual([])+ })++ it('falls back to [] when videoModelList is undefined in video mode', () => {+ useCreateStore.setState({ videoModelList: undefined as any, mode: 'video' })+ const s = useCreateStore.getState()+ expect(computeActiveList(s.mode, s.imageModelList, s.videoModelList)).toEqual([])+ })++ it('falls back to [] when the list is null', () => {+ useCreateStore.setState({ imageModelList: null as any, mode: 'image' })+ const s = useCreateStore.getState()+ expect(computeActiveList(s.mode, s.imageModelList, s.videoModelList)).toEqual([])+ })++ it('falls back to [] when the list is an object', () => {+ useCreateStore.setState({ imageModelList: { foo: 'bar' } as any, mode: 'image' })+ const s = useCreateStore.getState()+ expect(computeActiveList(s.mode, s.imageModelList, s.videoModelList)).toEqual([])+ })++ it('falls back to [] when the list is a string', () => {+ useCreateStore.setState({ imageModelList: 'corrupted' as any, mode: 'image' })+ const s = useCreateStore.getState()+ expect(computeActiveList(s.mode, s.imageModelList, s.videoModelList)).toEqual([])+ })++ it('passes through a real populated list unchanged', () => {+ const list = [{ name: 'flux.safetensors', type: 'flux' as const }]+ useCreateStore.setState({ imageModelList: list, mode: 'image' })+ const s = useCreateStore.getState()+ expect(computeActiveList(s.mode, s.imageModelList, s.videoModelList)).toBe(list)+ })++ it('.length and .map never throw on the fallback', () => {+ useCreateStore.setState({ imageModelList: undefined as any, videoModelList: null as any })+ const s = useCreateStore.getState()+ const imgList = computeActiveList('image', s.imageModelList, s.videoModelList)+ const vidList = computeActiveList('video', s.imageModelList, s.videoModelList)+ // These are the exact two operations CreateTopControls performs+ // (line 175 `.length === 0` and line 180 `.map(...)`).+ expect(() => imgList.length === 0).not.toThrow()+ expect(() => imgList.map((m: any) => m.name)).not.toThrow()+ expect(() => vidList.length === 0).not.toThrow()+ expect(() => vidList.map((m: any) => m.name)).not.toThrow()+ })+ })})// ── setSteps ───────────────────────────────────────────────