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: CreateTopControls crash — missing store fields

PurpleDoubleDaa31babee04d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a3e608c7..bf9b21ec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ All notable changes to Locally Uncensored are documented here.
- (2) `src/hooks/useCreate.ts:fetchModels` only cleared the persisted image/video model names when ComfyUI returned a non-empty list. With 0 models, the stale strings stayed alive forever. Now fetchModels explicitly `state.setImageModel('', 'unknown')` + `state.setVideoModel('')` when the corresponding list is empty after the startup-race retries expire.
- (3) `src/components/create/CreateView.tsx` renders a dedicated empty-state card when `connected === true && modelsLoaded && currentModeModels.length === 0`. The card shows `PackageOpen` icon + "No {image|video} models installed" + a **Go to Model Manager** primary button (calls `useUIStore.getState().setView('models')`) + a **Refresh list** secondary action (calls `fetchModels()`). `OutputDisplay` / `PromptInput` / `ParamPanel` / I2V + I2I uploads / preflight banners all suppress during the empty state so no downstream code can hit the old crash path. The Mode switcher (Image / Video) stays so the user can switch sides and get a matching empty-state.
+- **CreateTopControls no longer crashes the Create header toggle + dropdown** — the header-level model picker + ComfyUI Lichtschalter lives at `src/components/create/CreateTopControls.tsx` and used to destructure four fields (`imageModelList`, `videoModelList`, `comfyRunning`, `setComfyRunning`) from `useCreateStore()` that were never added to the store. Clicking the dropdown threw `TypeError: can't access property "length", activeList is undefined`; clicking the Lichtschalter during starting/stopping threw `setComfyRunning is not a function`. Reported on Discord by @diimmortalis (with a precise console-log dump, bless them — Ubuntu 24.04 + `npm run dev`). Fix: the four missing fields are now part of `createStore` as runtime-only (not persisted) state; `useCreate.fetchModels` + `useCreate.checkConnection` mirror their values into the store so the header control always has a live list + the right toggle state.
- **Backend Selector modal no longer spams on repeat** — users with multiple local backends (Ollama + LM Studio, Ollama + vLLM, etc) reported on Discord that the "N local backends detected" modal kept re-appearing every 5-10 seconds, regardless of whether they clicked Skip or Use selected. The pre-existing `sessionStorage` guard wasn't enough in the face of WebView2 reloads (which the backup-restore triad can trigger) or cache evictions. Fix: (1) added a persistent `hideBackendSelector` flag in `providerStore` so the user's opt-out survives reloads; (2) the modal now has a pre-checked "Don't show this again" tickbox; (3) a permanent explanatory line "You can add, remove, or switch backends anytime in **Settings → Providers**" (with the link clickable — it navigates you there); (4) dismissing the modal with the tickbox checked persists the opt-out. Users who want the modal back at some point can uncheck the box before dismissing.
- **LU always starts in the Chat sidebar tab, not Code** — on a fresh install or an NSIS update, the left-sidebar tab (Chat / Code / Remote) could land on Code because `codexStore`'s persist middleware saved `chatMode` between sessions. Newcomers clicking around Code without any conversations got an empty screen. `codexStore` now excludes `chatMode` from `partialize` so the default (`'lu'`) is used on every fresh boot. If a user wants to stay in Codex or Claude Code mid-session, they pick it from the sidebar each time; `workingDirectory` still persists so Codex remembers the last project path.
- Tiny grammar fix in the Create empty-state copy: "Install **an image** model" / "Install **a video** model" (was "Install a image model" in both branches).
diff --git a/README.md b/README.md
index 7351f3ac..9aa661b5 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,7 @@ Drop-in patch on top of v2.3.8.
### 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.
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index e58b67e0..bfdc132a 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -52,6 +52,9 @@ export function useCreate() {
const checkConnection = useCallback(async () => {
const ok = await checkComfyConnection()
setConnected(ok)
+ // Mirror into createStore so the header-level Lichtschalter in
+ // CreateTopControls stays in sync with the deeper useCreate state.
+ useCreateStore.getState().setComfyRunning(ok)
return ok
}, [])
@@ -105,6 +108,14 @@ export function useCreate() {
setSchedulerList(schedulers)
setVideoBackend(vBackend)
+ // Mirror the fetched lists into createStore so the header-level
+ // CreateTopControls dropdown (which does NOT host its own useCreate)
+ // can render without crashing on undefined. Discord-reported by
+ // @diimmortalis (console: `activeList is undefined`).
+ const st = useCreateStore.getState()
+ st.setImageModelList(imgModels)
+ st.setVideoModelList(vidModels)
+
// If ComfyUI is connected but returns 0 models, do NOT set modelsLoaded — keep retrying.
// ComfyUI may still be scanning directories (race condition on startup).
if (imgModels.length === 0 && vidModels.length === 0) {
diff --git a/src/stores/createStore.ts b/src/stores/createStore.ts
index c9ae6ca5..70b997f0 100644
--- a/src/stores/createStore.ts
+++ b/src/stores/createStore.ts
@@ -1,6 +1,6 @@
import { create } from 'zustand'
import { persist } from 'zustand/middleware'
-import type { ModelType } from '../api/comfyui'
+import type { ModelType, ClassifiedModel } from '../api/comfyui'
import { classifyModel } from '../api/comfyui'
import type { PreflightError } from '../api/preflight'
// ModelType includes: flux, flux2, zimage, sdxl, sd15, wan, hunyuan, unknown
@@ -80,6 +80,12 @@ interface CreateState {
preflightWarnings: string[]
gallery: GalleryItem[]
promptHistory: string[]
+ /** Runtime-only (not persisted): populated by useCreate.fetchModels so the
+ * header-level CreateTopControls can render its model dropdown + Lichtschalter
+ * without hosting its own ComfyUI fetching. */
+ imageModelList: ClassifiedModel[]
+ videoModelList: ClassifiedModel[]
+ comfyRunning: boolean
setPreflightStatus: (ready: boolean | null, errors: PreflightError[], warnings: string[]) => void
setMode: (mode: 'image' | 'video') => void
@@ -110,6 +116,9 @@ interface CreateState {
removeFromGallery: (id: string) => void
clearGallery: () => void
addToPromptHistory: (prompt: string) => void
+ setImageModelList: (list: ClassifiedModel[]) => void
+ setVideoModelList: (list: ClassifiedModel[]) => void
+ setComfyRunning: (running: boolean) => void
}
export const useCreateStore = create<CreateState>()(
@@ -147,6 +156,9 @@ export const useCreateStore = create<CreateState>()(
preflightWarnings: [],
gallery: [],
promptHistory: [],
+ imageModelList: [],
+ videoModelList: [],
+ comfyRunning: false,
setPreflightStatus: (ready, errors, warnings) => set({ preflightReady: ready, preflightErrors: errors, preflightWarnings: warnings }),
setMode: (mode) => set((state) => {
@@ -227,6 +239,9 @@ export const useCreateStore = create<CreateState>()(
const filtered = s.promptHistory.filter(p => p !== prompt)
return { promptHistory: [prompt, ...filtered].slice(0, 50) }
}),
+ setImageModelList: (list) => set({ imageModelList: list }),
+ setVideoModelList: (list) => set({ videoModelList: list }),
+ setComfyRunning: (running) => set({ comfyRunning: running }),
}),
{
name: 'create-store',