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.

Merge origin/master for LU 2.6 compatibility

Kizerfluidbeac5066c354
diff --cc e2e/cloud-onboarding.spec.ts
index fcd472c8,2d6c0e24..7c66298c
--- a/e2e/cloud-onboarding.spec.ts
+++ b/e2e/cloud-onboarding.spec.ts
@@@ -49,23 -50,4 +50,3 @@@ test('Max account: switch → login �
await expect(cloudSwitch(page)).not.toBeChecked()
await expect(page.getByRole('button', { name: /^Models$/ })).toBeVisible()
})
-
- test('first flip runs the one-time cloud onboarding before switching', async ({ page }) => {
- await boot(page, { cloudOnboardingSeen: false })
-
- await signInViaGate(page)
-
- // Instead of flipping silently, the one-time onboarding appears.
- await expect(page.getByText(/Welcome to LU Cloud/i)).toBeVisible({ timeout: 20_000 })
- await expect(cloudSwitch(page)).not.toBeChecked()
-
- await page.getByRole('button', { name: /Start Cloud mode/i }).click()
- await expect(cloudSwitch(page)).toBeChecked()
--
- // Seen persists: flipping off and on again is silent now.
- await cloudSwitch(page).click()
- await expect(cloudSwitch(page)).not.toBeChecked()
- await cloudSwitch(page).click()
- await expect(cloudSwitch(page)).toBeChecked()
- await expect(page.getByText(/Welcome to LU Cloud/i)).toBeHidden()
- })
diff --cc src/components/create/experimental/__tests__/galleryUrl.test.ts
index 289c01c6,632e3497..c370e3e4
--- a/src/components/create/experimental/__tests__/galleryUrl.test.ts
+++ b/src/components/create/experimental/__tests__/galleryUrl.test.ts
@@@ -1,38 -1,42 +1,73 @@@
--import { describe, it, expect, vi, beforeEach } from 'vitest'
- import { fetchGalleryItemBlob, galleryItemUrl, recoverGalleryUrl, } from '../galleryUrl'
- import { refreshResultUrl, resolveResultUrl } from '../../../../api/cloud/jobs'
- import { useCreateStore, type GalleryItem } from '../../../../stores/createStore'
++import { describe, it, expect, vi, beforeEach } from 'vitest'
++import {
++ fetchGalleryItemBlob,
++ galleryItemUrl,
++ proxiedComfyBlobUrl,
++ recoverGalleryUrl,
++} from '../galleryUrl'
++import {
++ refreshResultUrl,
++ resolveResultUrl,
++} from '../../../../api/cloud/jobs'
++import { backendCall } from '../../../../api/backend'
++import {
++ useCreateStore,
++ type GalleryItem,
++} from '../../../../stores/createStore'
// zustand persist reads window.localStorage at store-module load (node env
--// has no DOM) — same hoisted Map shim as createStore.test.ts.
++// has no DOM) — same hoisted Map shim as createStore.test.ts.
vi.hoisted(() => {
const map = new Map<string, string>()
const ls = {
getItem: (k: string) => (map.has(k) ? map.get(k)! : null),
-- setItem: (k: string, v: string) => { map.set(k, String(v)) },
-- removeItem: (k: string) => { map.delete(k) },
-- clear: () => { map.clear() },
++ setItem: (k: string, v: string) => {
++ map.set(k, String(v))
++ },
++ removeItem: (k: string) => {
++ map.delete(k)
++ },
++ clear: () => {
++ map.clear()
++ },
key: (i: number) => [...map.keys()][i] ?? null,
-- get length() { return map.size },
++ get length() {
++ return map.size
++ },
}
++
;(globalThis as unknown as { localStorage: unknown }).localStorage = ls
-- const g = globalThis as unknown as { window?: Record<string, unknown> }
-- g.window = Object.assign(g.window ?? {}, { localStorage: ls })
++
++ const g = globalThis as unknown as {
++ window?: Record<string, unknown>
++ }
++
++ g.window = Object.assign(g.window ?? {}, {
++ localStorage: ls,
++ })
})
vi.mock('../../../../api/comfyui', () => ({
- getImageUrl: vi.fn((filename: string, subfolder?: string) => `http://127.0.0.1:8188/view?filename=${filename}&subfolder=${subfolder ?? ''}`),
- classifyModel: vi.fn(() => 'unknown'),
+ getImageUrl: vi.fn((
- filename: string,
- subfolder?: string,
- type: string = 'output',
- ) =>
- `http://127.0.0.1:8188/view?filename=${filename}&subfolder=${subfolder ?? ''}&type=${type}`),
++ filename: string,
++ subfolder?: string,
++ type: string = 'output',
++ ) =>
++ `http://127.0.0.1:8188/view?filename=${filename}&subfolder=${subfolder ?? ''}&type=${type}`),
}))
++
vi.mock('../../../../api/cloud/jobs', () => ({
refreshResultUrl: vi.fn(),
resolveResultUrl: vi.fn(),
}))
-// Only backendCall is faked — fetchLocalhostBytes/isTauri keep their real
+
++// Only backendCall is faked — fetchLocalhostBytes/isTauri keep their real
+ // behaviour, which the ComfyUI-path tests below depend on.
+ vi.mock('../../../../api/backend', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../../../../api/backend')>()),
+ backendCall: vi.fn(),
+ }))
+
-import { fetchGalleryItemBlob, recoverGalleryUrl, proxiedComfyBlobUrl } from '../galleryUrl'
-import { refreshResultUrl, resolveResultUrl } from '../../../../api/cloud/jobs'
-import { backendCall } from '../../../../api/backend'
-import { useCreateStore, type GalleryItem } from '../../../../stores/createStore'
-
const baseItem: GalleryItem = {
id: 'g1', filename: 'out.png', subfolder: '', type: 'image', prompt: '',
negativePrompt: '', model: 'm', modelType: 'unknown', seed: 1, steps: 1,
@@@ -40,26 -44,6 +75,26 @@@
batchSize: 1, createdAt: 1,
} as GalleryItem
- describe('galleryItemUrl — ComfyUI file location', () => {
++describe('galleryItemUrl — ComfyUI file location', () => {
+ it('preserves temp outputs from VHS_VideoCombine', () => {
+ const url = galleryItemUrl({
+ ...baseItem,
+ type: 'video',
+ filename: 'AnimateDiff_00002.mp4',
+ comfyType: 'temp',
+ })
+
+ expect(url).toContain('filename=AnimateDiff_00002.mp4')
+ expect(url).toContain('type=temp')
+ })
+
+ it('defaults older gallery entries to output', () => {
+ const url = galleryItemUrl(baseItem)
+
+ expect(url).toContain('type=output')
+ })
+})
+
describe('fetchGalleryItemBlob', () => {
beforeEach(() => {
vi.restoreAllMocks()
@@@ -104,7 -88,7 +139,7 @@@
// Cloud renders are deleted after seven days (the Create banner says so, and
// services/render-worker/src/reaper.ts now does it). A tile whose render is
// gone must settle into an honest state, not retry a dead re-sign forever.
--describe('recoverGalleryUrl — expired cloud renders', () => {
++describe('recoverGalleryUrl — expired cloud renders', () => {
beforeEach(() => {
vi.restoreAllMocks()
useCreateStore.setState({ gallery: [] })
@@@ -144,3 -128,73 +179,73 @@@
expect(useCreateStore.getState().gallery[0].unavailable).toBeUndefined()
})
})
+
+ /**
+ * Local MLX renders (Mac). partialize strips `dataUrl` on persist, so after a
- * restart the tile has only a filename — and galleryItemUrl turns that into a
++ * restart the tile has only a filename — and galleryItemUrl turns that into a
+ * ComfyUI /view URL, which on a Mac can never answer. Every locally generated
+ * image therefore died on the next launch. The file on disk is the way back.
+ */
-describe('recoverGalleryUrl — local MLX renders on disk', () => {
++describe('recoverGalleryUrl — local MLX renders on disk', () => {
+ beforeEach(() => {
+ vi.mocked(backendCall).mockReset()
+ useCreateStore.setState({ gallery: [] })
+ ;(URL as unknown as { createObjectURL: (b: unknown) => string }).createObjectURL = () => 'blob:restored'
+ })
+
+ const flush = () => new Promise((r) => setTimeout(r, 0))
+
+ it('re-reads the file and hands the tile a fresh blob URL', async () => {
+ const item = { ...baseItem, id: 'disk-ok', localPath: '/tmp/mlx-1.png' }
+ useCreateStore.setState({ gallery: [item] })
- // base64 of "PNG" — content is irrelevant, the decode path is what matters.
++ // base64 of "PNG" — content is irrelevant, the decode path is what matters.
+ vi.mocked(backendCall).mockResolvedValueOnce('UE5H' as never)
+
+ recoverGalleryUrl(item)
+ await flush()
+ expect(vi.mocked(backendCall)).toHaveBeenCalledWith('read_media_file', { path: '/tmp/mlx-1.png' })
+ expect(useCreateStore.getState().gallery[0].dataUrl).toBe('blob:restored')
+ expect(useCreateStore.getState().gallery[0].unavailable).toBeUndefined()
+ })
+
+ it('marks the tile unavailable when the file is gone', async () => {
+ const item = { ...baseItem, id: 'disk-gone', localPath: '/tmp/deleted.png' }
+ useCreateStore.setState({ gallery: [item] })
+ vi.mocked(backendCall).mockRejectedValueOnce(new Error('no such file'))
+
+ recoverGalleryUrl(item)
+ await flush()
+ expect(useCreateStore.getState().gallery[0].unavailable).toBe(true)
+ })
+
+ it('reads the file once, not on every remount', async () => {
+ // Tiles call this from onError, which can fire repeatedly.
+ const item = { ...baseItem, id: 'disk-once', localPath: '/tmp/mlx-2.png' }
+ useCreateStore.setState({ gallery: [item] })
+ vi.mocked(backendCall).mockResolvedValue('UE5H' as never)
+
+ recoverGalleryUrl(item)
+ await flush()
+ recoverGalleryUrl(item)
+ await flush()
+ expect(vi.mocked(backendCall).mock.calls.length).toBe(1)
+ })
+
+ it('never asks ComfyUI about a file we own on disk', async () => {
+ // Without this guard the recovery took a pointless round trip to port 8188
- // first — and on a Mac that happens to run ComfyUI for something else, it
++ // first — and on a Mac that happens to run ComfyUI for something else, it
+ // asked the wrong server about a file it never made.
+ const item = { ...baseItem, id: 'disk-noproxy', localPath: '/tmp/mlx-3.png' }
+ expect(await proxiedComfyBlobUrl(item)).toBeNull()
+ })
+
- it('still marks a ComfyUI item unavailable — no localPath, nothing to re-read', async () => {
++ it('still marks a ComfyUI item unavailable — no localPath, nothing to re-read', async () => {
+ const item = { ...baseItem, id: 'comfy-dead' }
+ useCreateStore.setState({ gallery: [item] })
+
+ recoverGalleryUrl(item)
+ await flush()
+ expect(vi.mocked(backendCall)).not.toHaveBeenCalled()
+ expect(useCreateStore.getState().gallery[0].unavailable).toBe(true)
+ })
+ })
diff --cc src/components/create/experimental/galleryUrl.ts
index e0a8e111,7acf15b8..68cf3a09
--- a/src/components/create/experimental/galleryUrl.ts
+++ b/src/components/create/experimental/galleryUrl.ts
@@@ -89,15 -119,13 +125,19 @@@ function guessMime(filename: string): s
* use whenever ComfyUI allows the origin.
*/
export async function proxiedComfyBlobUrl(item: GalleryItem): Promise<string | null> {
- if (!isTauri() || item.jobId || item.remoteUrl || item.dataUrl) return null
+ // `localPath` marks an item whose bytes we own on disk (the MLX lanes). It is
+ // not a ComfyUI output, so asking ComfyUI for its filename can only waste a
+ // round trip — and on a Mac that happens to run ComfyUI for something else,
+ // ask the wrong server about a file it never made.
+ if (!isTauri() || item.jobId || item.remoteUrl || item.dataUrl || item.localPath) return null
try {
- const bytes = await fetchLocalhostBytes(getImageUrl(item.filename, item.subfolder))
+ const bytes = await fetchLocalhostBytes(
+ getImageUrl(
+ item.filename,
+ item.subfolder,
+ item.comfyType ?? 'output',
+ ),
+)
return URL.createObjectURL(new Blob([bytes], { type: guessMime(item.filename) }))
} catch {
return null
diff --cc src/components/layout/AppShell.tsx
index 48d1601a,51ae6995..bdd3573e
--- a/src/components/layout/AppShell.tsx
+++ b/src/components/layout/AppShell.tsx
@@@ -34,10 -34,9 +34,10 @@@ import { CloudExampleModal } from '../c
import { ShortcutsModal } from './ShortcutsModal'
import { CreditsExhaustedModal } from './CreditsExhaustedModal'
import { Titlebar } from './Titlebar'
+import { TagsAndWorkflowsPage } from '../workflows/TagsAndWorkflowsPage'
// The backup triad must never write %APPDATA%/store_backup.json before the
--// restore decision — on a post-NSIS boot the first doBackup would otherwise
++// restore decision — on a post-NSIS boot the first doBackup would otherwise
// snapshot the wiped localStorage over the only good backup. Resolved on every
// exit path of the restore effect (intact-store fast path, restore-then-reload,
// no-backup fallback, browser give-up); module-level so a reload starts fresh.
@@@ -61,13 -60,13 +61,13 @@@ export function AppShell()
// the cloud Create axis and the lu-cloud chat provider in sync.
useCloudAuth()
-- // ── Global Local/Cloud mode (2.5.7) — appMode drives everything ──
++ // ── Global Local/Cloud mode (2.5.7) — appMode drives everything ──
const appMode = settings.appMode
const cloudAvailable = useCloudAuthStore(deriveCloudAvailable)
// Boot-sync the configured ComfyUI host/port into the FE URL builder.
// The backend loads them from config.json at startup, but the only FE
-- // mirror lived in SettingsPage's mount effect — so after an app restart
++ // mirror lived in SettingsPage's mount effect — so after an app restart
// every comfyuiUrl() (gallery media, control plane) pointed at localhost
// until the user happened to open Settings. On a remote-host setup (#82)
// that made the app look dead after every launch. Found live 2026-07-17.
@@@ -78,7 -80,7 +81,7 @@@
const s = await backendCall<{ port?: number; host?: string }>('comfyui_status')
if (typeof s?.port === 'number' && s.port > 0) setComfyPort(s.port)
if (typeof s?.host === 'string' && s.host.trim()) setComfyHost(s.host)
-- } catch { /* backend not up yet — Settings' own mirror still applies later */ }
++ } catch { /* backend not up yet — Settings' own mirror still applies later */ }
})()
}, [])
@@@ -92,14 -94,14 +95,14 @@@
}, [appMode, cloudAvailable])
// Never leave an out-of-mode model active: flipping the switch moves the
-- // chat selection onto the first model of the new mode (cloud ↔ local).
-- // Depends on the model list too — the hosted catalog arrives ASYNC after
++ // chat selection onto the first model of the new mode (cloud ↔ local).
++ // Depends on the model list too — the hosted catalog arrives ASYNC after
// the lu-cloud provider gets enabled, so the reselect must fire again the
// moment those models land.
const allModels = useModelStore((s) => s.models)
useEffect(() => {
const { activeModel, setActiveModel } = useModelStore.getState()
-- // Chat models only — ComfyUI image/video checkpoints share the list but
++ // Chat models only — ComfyUI image/video checkpoints share the list but
// carry no provider field, so a bare provider check would pin a checkpoint
// as the active CHAT model (mirrors the pull auto-activate guard in
// useModels; an unprefixed checkpoint name routes to Ollama and fails).
@@@ -118,7 -120,7 +121,7 @@@
if (fallback) setActiveModel(fallback.name)
}, [appMode, allModels])
-- // Local-hardware views (Models/Benchmark) don't exist in cloud mode — the
++ // Local-hardware views (Models/Benchmark) don't exist in cloud mode — the
// header hides them, this guard covers a view that was already open.
useEffect(() => {
const ui = useUIStore.getState()
@@@ -127,12 -129,12 +130,12 @@@
}
}, [appMode])
-- // ── Cloud = cloud-only: release every LOCAL model backend so nothing sits
++ // ── Cloud = cloud-only: release every LOCAL model backend so nothing sits
// in RAM/VRAM while inference runs in the cloud (David 2026-07-11). Whisper
// STT, the bundled llama.cpp sidecar + embeddings, Ollama-loaded models and
// ComfyUI VRAM are freed by offload_local_models; LM Studio via its own JIT
// unload (`lms unload --all`). Local mode reloads LAZILY on first use
-- // (chat/voice/render) — nothing is pre-warmed. Fires on entering cloud
++ // (chat/voice/render) — nothing is pre-warmed. Fires on entering cloud
// (switch OR launch-in-cloud); local mode is a no-op.
useEffect(() => {
if (!isTauri() || appMode !== 'cloud') return
@@@ -143,13 -145,13 +146,13 @@@
// Push the persisted ComfyUI GPU override to the backend on boot + change
// (rhodium92 AMD, 2026-07-01). The backend resets to "auto" each launch, so
// without this a saved force-cpu / force-gpu wouldn't apply until the user
-- // re-opened Settings. Desktop-only — the web build has no local ComfyUI.
++ // re-opened Settings. Desktop-only — the web build has no local ComfyUI.
useEffect(() => {
if (!isTauri()) return
backendCall('set_comfy_gpu_mode', { mode: settings.comfyGpuMode || 'auto' }).catch(() => {})
}, [settings.comfyGpuMode])
-- // ── Store backup/restore: survive NSIS updates that wipe WebView2 data ──
++ // ── Store backup/restore: survive NSIS updates that wipe WebView2 data ──
const STORE_KEYS = [
'chat-conversations', 'chat-settings', 'chat-models', 'lu-providers',
'create-store', 'locally-uncensored-codex',
@@@ -158,7 -160,7 +161,7 @@@
'locally-uncensored-agent-workflows', 'locally-uncensored-agent',
'locally-uncensored-voice', 'lu-benchmark-store', 'lu-update-checker-v2',
'rag-store', 'workflow-store', 'lu-cloud-catalog',
-- // One-shot notices — back these up so "seen it once" survives an NSIS
++ // One-shot notices — back these up so "seen it once" survives an NSIS
// update that wipes WebView2 localStorage. `lu_cloud_notice` (the Create
// retention line) claimed in its own comment that it survived an update
// and did not, because it was never listed here.
@@@ -167,7 -169,7 +170,7 @@@
'locally-uncensored-agent-goal',
]
const STORE_KEYS_SET = new Set(STORE_KEYS)
-- // These two persist via idbStorage (IndexedDB) since v2.5.0 — the backup
++ // These two persist via idbStorage (IndexedDB) since v2.5.0 — the backup
// snapshot must read them from there; their localStorage copy is deleted by
// the one-time idb migration, so localStorage.getItem returns nothing.
const IDB_STORE_KEYS = new Set(['chat-conversations', 'locally-uncensored-memory'])
@@@ -192,11 -194,11 +195,11 @@@
}
// On startup: if localStorage was wiped, restore from %APPDATA% backup.
-- // Tauri v2 sets the global asynchronously via `withGlobalTauri` — on slow
++ // Tauri v2 sets the global asynchronously via `withGlobalTauri` — on slow
// cold-starts the first render beats it (commit 835ce86, same reason the
// backup triad polls). A bare isTauri() bail here would skip the restore
// permanently and let the triad's first doBackup clobber the backup file
-- // with the freshly-wiped state, so we poll with the same 100 ms × 50 pattern.
++ // with the freshly-wiped state, so we poll with the same 100 ms × 50 pattern.
useEffect(() => {
const runRestore = () => {
const hasStores = STORE_KEYS.some(k => localStorage.getItem(k))
@@@ -218,7 -220,7 +221,7 @@@
const parsed = await restoreMemoryVectorsFrom(rawParsed)
const { exportAllChunks, importAllChunks } = await import('../../lib/ragDB')
const live = await exportAllChunks()
-- // Only import entries the live store is missing — never clobber
++ // Only import entries the live store is missing — never clobber
// newer in-app activity with a stale backup.
const toImport: Record<string, any> = {}
for (const [docId, chunks] of Object.entries(parsed)) {
@@@ -233,7 -235,7 +236,7 @@@
}
} catch { /* best-effort */ }
// Release the triad only after the quiet import read the backup
-- // file — doRagBackup would otherwise overwrite it first.
++ // file — doRagBackup would otherwise overwrite it first.
resolveRestoreDecided()
})()
return
@@@ -253,7 -255,7 +256,7 @@@
let restored = 0
for (const [key, value] of Object.entries(parsed)) {
if (STORE_KEYS_SET.has(key) && typeof value === 'string' && value) {
-- // IDB-backed keys go back to IndexedDB — the chat blob can
++ // IDB-backed keys go back to IndexedDB — the chat blob can
// exceed the ~5 MB localStorage quota (that's why those
// stores moved to IDB), and hydration reads them from there.
// Per-key try/catch: one failing key must not abort the rest.
@@@ -293,7 -295,7 +296,7 @@@
}
} catch {}
-- // 3. No backup available — at least recover onboarding from marker file
++ // 3. No backup available — at least recover onboarding from marker file
if (markerExists) {
updateSettings({ onboardingDone: true })
}
@@@ -313,7 -315,7 +316,7 @@@
clearInterval(waitForTauri)
runRestore()
} else if (tries >= 50) {
-- // 5 s elapsed — probably browser dev session, nothing to restore.
++ // 5 s elapsed — probably browser dev session, nothing to restore.
clearInterval(waitForTauri)
resolveRestoreDecided()
}
@@@ -321,18 -323,18 +324,18 @@@
return () => clearInterval(waitForTauri)
}, [])
-- // Backup stores to %APPDATA% — three-pronged so chat history survives
++ // Backup stores to %APPDATA% — three-pronged so chat history survives
// NSIS updates + abrupt process kills:
-- // 1. 10 s safety-net interval (was 30 s — too slow, users lost chats if
++ // 1. 10 s safety-net interval (was 30 s — too slow, users lost chats if
// they sent a message shortly before an upgrade).
// 2. Debounced event-driven backup: 1 s after every chat/codex/memory
// mutation. Catches "typed + restart within interval window" case.
// 3. beforeunload sync flush on Tauri window close. Fires for graceful
// quits and "X" button; does NOT fire for taskkill / NSIS upgrade
// (why we need 1+2 as well).
-- // No dependency — we want this to run ONCE on mount and not rerun on
++ // No dependency — we want this to run ONCE on mount and not rerun on
// every settings flip. Tauri v2 sets `window.__TAURI__` asynchronously
-- // via `withGlobalTauri` — on slower machines the first render fires
++ // via `withGlobalTauri` — on slower machines the first render fires
// BEFORE the global exists, so we poll for up to 5 s, then arm the triad.
useEffect(() => {
let cleanup: (() => void) | null = null
@@@ -340,7 -342,7 +343,7 @@@
let tries = 0
const setupTriad = async () => {
-- // Never write the first backup before the restore effect decided — a
++ // Never write the first backup before the restore effect decided — a
// post-NSIS boot with wiped storage would otherwise snapshot the empty
// state over the only good store_backup.json.
await restoreDecided
@@@ -349,7 -351,7 +352,7 @@@
let backupInflight = false
// In-memory mirror of the IDB-backed values, refreshed by every doBackup
// run. beforeunload can't await IndexedDB (the page is tearing down), so
-- // the sync flush below reads from this cache instead — at most one
++ // the sync flush below reads from this cache instead — at most one
// debounce-cycle stale, same freshness the old sync handler had.
const idbCache: Record<string, string> = {}
const doBackup = async () => {
@@@ -368,7 -370,7 +371,7 @@@
if (IDB_STORE_KEYS.has(key)) idbCache[key] = val
}
}
-- // Always fire — we want backup even if snapshot is mostly empty, and the
++ // Always fire — we want backup even if snapshot is mostly empty, and the
// sentinel tells the restore-flow this is a valid backup.
localStorage.setItem('lu-restore-complete', '1')
backendCall('backup_stores', { data: JSON.stringify(snapshot) }).catch(() => {})
@@@ -379,7 -381,7 +382,7 @@@
// Separate, debounced backup for RAG IndexedDB chunks (Bug V, kj103x
// 2026-05-23). These are heavy (768-float embedding vectors per chunk,
// sometimes thousands per doc) so we don't bundle them into the chat
-- // snapshot — the chat-store backup must stay fast for the 1 s debounce
++ // snapshot — the chat-store backup must stay fast for the 1 s debounce
// case. RAG backup runs at most once every 30 s and after IndexedDB
// grows, which is the right cadence: chunks change on document upload
// / delete, both rare events compared to chat messages.
@@@ -410,7 -412,7 +413,7 @@@
// Migration: write onboarding marker if missing AND user has already
// onboarded (keeps NSIS-update recovery working). Do NOT rewrite the
-- // marker for users who just hit Settings → "Re-run onboarding" — for
++ // marker for users who just hit Settings → "Re-run onboarding" — for
// them onboardingDone is false, and the missing marker is intentional.
backendCall<boolean>('is_onboarding_done').catch(() => false).then((markerExists) => {
if (!markerExists && useSettingsStore.getState().settings.onboardingDone) {
@@@ -435,7 -437,7 +438,7 @@@
// Synchronous "last write" flush for beforeunload: doBackup awaits
// IndexedDB reads, and an await during page teardown means the trailing
// backup_stores invoke may never fire. Build the snapshot synchronously
-- // from localStorage + the idbCache mirror instead — no await before the
++ // from localStorage + the idbCache mirror instead — no await before the
// invoke, restoring the pre-async guarantee.
const flushSyncBackup = () => {
try {
@@@ -454,7 -456,7 +457,7 @@@
const onBeforeUnload = () => {
// The 5 s / 30 s intervals cover the common case; this is the "last
// write" insurance for changes since the previous interval. Must stay
-- // synchronous — see flushSyncBackup.
++ // synchronous — see flushSyncBackup.
flushSyncBackup()
void doRagBackup()
}
@@@ -475,7 -477,7 +478,7 @@@
clearInterval(waitForTauri)
void setupTriad()
} else if (tries >= 50) {
-- // 50 × 100 ms = 5 s. Give up silently — probably browser dev session.
++ // 50 × 100 ms = 5 s. Give up silently — probably browser dev session.
clearInterval(waitForTauri)
}
}, 100)
@@@ -495,28 -497,28 +498,28 @@@
// into index.html so the very first paint (before any React renders)
// is already dark even on cold-start.
useLayoutEffect(() => {
-- const isDark = settings.theme !== 'light' // unset / undefined → dark
++ const isDark = settings.theme !== 'light' // unset / undefined → dark
document.documentElement.classList.toggle('dark', isDark)
document.documentElement.classList.toggle('light', !isDark)
}, [settings.theme])
-- // ── Issue #31: Ollama host sync (Rust ↔ frontend) ─────────────
++ // ── Issue #31: Ollama host sync (Rust ↔ frontend) ─────────────
// Two async prereqs to serialize against:
// (a) Tauri v2 `__TAURI_INTERNALS__` is set async via `withGlobalTauri`.
-- // (b) Zustand `persist` middleware hydrates `lu-providers` async — if we
++ // (b) Zustand `persist` middleware hydrates `lu-providers` async — if we
// push Rust's value into the store BEFORE hydration finishes,
// hydration replays the stale localStorage baseUrl and clobbers us.
//
// The deliberate order:
-- // 1. Wait for the Tauri global via the same 100ms × 50-tick poll the
++ // 1. Wait for the Tauri global via the same 100ms × 50-tick poll the
// backup triad uses (v2.3.3 commit 835ce86).
// 2. Use zustand's own `onFinishHydration` callback for ordering against
-- // hydration — more reliable than polling `hasHydrated()` because it
++ // hydration — more reliable than polling `hasHydrated()` because it
// fires deterministically AFTER the replay, not whenever we happen
// to check.
// 3. Fetch Rust's resolved base (config.json > OLLAMA_HOST > default)
// and push it into both the providerStore and backend.ts, regardless
-- // of what hydration just wrote — Rust wins at cold start.
++ // of what hydration just wrote — Rust wins at cold start.
// 4. Arm a zustand subscribe listener for future GUI edits so
// `set_ollama_host` keeps Rust's config.json authoritative.
useEffect(() => {
@@@ -558,7 -560,7 +561,7 @@@
useProviderStore.getState().setProviderConfig('ollama', { baseUrl: res.base })
}
}
-- } catch { /* Rust not ready — providerStore wins, subscription handles later edits */ }
++ } catch { /* Rust not ready — providerStore wins, subscription handles later edits */ }
const current = useProviderStore.getState().providers.ollama?.baseUrl
if (!cancelled && current) setOllamaBase(current)
@@@ -582,7 -584,7 +585,7 @@@
clearInterval(waitForTauri)
afterHydration()
} else if (tries >= 50) {
-- // 5 s elapsed — probably browser dev session. Still wire the store
++ // 5 s elapsed — probably browser dev session. Still wire the store
// subscription so user edits reach Rust if Tauri appears later.
clearInterval(waitForTauri)
armSubscription()
@@@ -598,7 -600,7 +601,7 @@@
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
-- // ── Mirror remote mobile chat into the dispatched desktop conversation ──
++ // ── Mirror remote mobile chat into the dispatched desktop conversation ──
useEffect(() => {
if (!isTauri()) return
let unlisten: (() => void) | undefined
@@@ -611,7 -613,7 +614,7 @@@
if (!role || !content) return
const chat = useChatStore.getState()
-- // ── Codex route ──────────────────────────────────────────────
++ // ── Codex route ──────────────────────────────────────────────
// Find or create a Codex desktop conversation keyed by the mobile
// chat_id so successive messages from the same mobile Codex chat
// land in the same desktop conversation. Marked with `mode: 'codex'`
@@@ -644,7 -646,7 +647,7 @@@
return
}
-- // ── Default LU route: dispatched conversation ────────────────
++ // ── Default LU route: dispatched conversation ────────────────
const { dispatchedConversationId } = useRemoteStore.getState()
if (!dispatchedConversationId) return
const conv = chat.conversations.find((c) => c.id === dispatchedConversationId)
@@@ -685,10 -687,10 +688,10 @@@
}
}, [])
-- // Ollama 0.20.7 stale-manifest scan — runs once per session shortly after
++ // Ollama 0.20.7 stale-manifest scan — runs once per session shortly after
// startup. Flags installed models that the server now rejects with "does
// not support chat/completion/generate" (pulled before the registry-side
-- // capabilities refresh). Populates useModelHealthStore → StaleModelsBanner
++ // capabilities refresh). Populates useModelHealthStore → StaleModelsBanner
// surfaces the result as a top-of-app notice with one-click Refresh All.
useEffect(() => {
if (!onboardingDone || !isTauri()) return
@@@ -707,7 -709,7 +710,7 @@@
const stale = results.filter((r) => r.stale).map((r) => r.name)
useModelHealthStore.getState().setStaleModels(stale)
} catch {
-- // Scan is best-effort — silently fall back if Ollama is unreachable.
++ // Scan is best-effort — silently fall back if Ollama is unreachable.
} finally {
useModelHealthStore.getState().setScanning(false)
}
@@@ -725,7 -727,7 +728,7 @@@
detectLocalBackends().then((backends) => {
if (backends.length === 0) return
-- // Auto-adopt the first non-Ollama openai-compat backend we find — but
++ // Auto-adopt the first non-Ollama openai-compat backend we find — but
// NOT when the app-managed built-in engine owns the `openai` slot.
// 2.5.7: that slot now holds the bundled llama-server (managed:true) by
// default. Silently overwriting it here would leave `managed:true`
@@@ -734,8 -736,8 +737,8 @@@
// auto-adopt an external backend when the user has already switched away
// from the built-in engine (slot not managed). When the built-in engine
// is the active default, detected externals stay opt-in via the selector
-- // modal below and Settings → Providers ("use another engine").
-- // (Pre-2.5.7 rationale — Discord #help-chat, djoks.exe 2026-04-21: without
++ // modal below and Settings → Providers ("use another engine").
++ // (Pre-2.5.7 rationale — Discord #help-chat, djoks.exe 2026-04-21: without
// auto-enable, dismissing the selector left LM Studio disabled and its
// models never appeared. Still true for users who left the built-in slot.)
const openaiSlot = useProviderStore.getState().providers.openai
@@@ -753,7 -755,7 +756,7 @@@
// Also auto-(re)enable Ollama when it's detected. The provider defaults
// to enabled=true, but a previous session may have disabled it; here we
// pin the detected baseUrl and bring it back so models show up in the
-- // Settings → AI Backends list and the chat selector.
++ // Settings → AI Backends list and the chat selector.
const detectedOllama = backends.find((b) => b.id === 'ollama')
if (detectedOllama) {
useProviderStore.getState().setProviderConfig('ollama', {
@@@ -763,16 -765,16 +766,16 @@@
})
}
-- // Single backend → we're done (already enabled above, or was Ollama).
++ // Single backend → we're done (already enabled above, or was Ollama).
if (backends.length === 1) return
// User previously opted out of the selector (tickbox "don't show again")
-- // → never re-show. They manage providers via Settings → Providers.
++ // → never re-show. They manage providers via Settings → Providers.
// This is the persistent guard; the sessionStorage check above is just
// the within-session guard.
if (useProviderStore.getState().hideBackendSelector) return
-- // Multiple backends detected → show selection dialog so the user can
++ // Multiple backends detected → show selection dialog so the user can
// change which one is the primary openai-compat provider if they want.
setDetectedBackends(backends)
setShowSelector(true)
@@@ -818,7 -813,7 +821,7 @@@
backends={detectedBackends}
onClose={() => setShowSelector(false)}
/>
-- {/* Cloud gate: login → plan → beta wall, opened by the header switch. */}
++ {/* Cloud gate: login → plan → beta wall, opened by the header switch. */}
<CloudGateModal />
{/* Cloud discovery sheet: opened by the Local-mode teaser surfaces
(locked Create tabs, hosted model rows). */}
diff --cc src/hooks/useModels.ts
index 521d7d7a,a104263e..fda2d30b
--- a/src/hooks/useModels.ts
+++ b/src/hooks/useModels.ts
@@@ -1,7 -1,7 +1,12 @@@
import { useCallback, useEffect, useMemo } from 'react'
import { listModels, pullModel as pullModelApi, pullModelTauri, deleteModel as deleteModelApi } from '../api/ollama'
- import { isTauri } from '../api/backend'
- import { getImageModels as getComfyImageModels, getVideoModels as getComfyVideoModels, checkComfyConnection, } from '../api/comfyui'
+ import { isTauri, isMacOS } from '../api/backend'
-import { getCheckpoints as getComfyCheckpoints, getDiffusionModels as getComfyDiffusionModels, checkComfyConnection, filterPartialFiles } from '../api/comfyui'
++import {
++ getImageModels as getComfyImageModels,
++ getVideoModels as getComfyVideoModels,
++ checkComfyConnection,
++ filterPartialFiles,
++} from '../api/comfyui'
import { parseNDJSONStream } from '../api/stream'
import { useModelStore } from '../stores/modelStore'
import { useProviderStore } from '../stores/providerStore'
@@@ -14,12 -15,11 +20,20 @@@ import
import type { BundledModel } from '../api/engine'
import type { PullProgress, AIModel, ModelCategory, ImageModel, VideoModel, CloudModel } from '../types/models'
-const VIDEO_PATTERNS = [/wan/, /svd/, /animatediff/, /animate/, /video/, /cogvideo/, /ltx/i, /framepack/, /mochi/, /cosmos/, /hunyuan/, /pyramidflow/, /allegro/]
+// Embedding models that should never appear in the chat model dropdown
- const EMBEDDING_PATTERNS = [/embed/, /nomic-embed/, /bge-/, /e5-/, /gte-/, /sentence-/]
++const EMBEDDING_PATTERNS = [
++ /embed/,
++ /nomic-embed/,
++ /bge-/,
++ /e5-/,
++ /gte-/,
++ /sentence-/,
++]
-function isVideoModel(name: string): boolean {
+function isEmbeddingModel(name: string): boolean {
const lower = name.toLowerCase()
- return EMBEDDING_PATTERNS.some((p) => p.test(lower))
- return VIDEO_PATTERNS.some((p) => p.test(lower))
++ return EMBEDDING_PATTERNS.some((pattern) => pattern.test(lower))
++}
}
// Boot-resume for the managed built-in engine (2.5.7): the llama-server
@@@ -41,7 -41,7 +55,7 @@@ async function resumeBuiltinEngines(bun
) {
await activateBuiltinModel(activeModel)
}
-- } catch { /* engine unavailable — non-critical */ }
++ } catch { /* engine unavailable — non-critical */ }
await resumeEmbedServer(bundled)
}
@@@ -55,7 -55,7 +69,7 @@@ async function resumeEmbedServer(bundle
const embedStatus = await bundledEmbedStatus()
if (!embedStatus.running) await startBundledEmbed(embed.path)
}
-- } catch { /* embeddings server unavailable — non-critical */ }
++ } catch { /* embeddings server unavailable — non-critical */ }
}
export function useModels() {
@@@ -65,7 -65,7 +79,7 @@@
pausePull, completePull, dismissPull, setCategoryFilter,
} = useModelStore()
-- // Global Local/Cloud switch: one choke point for every picker — cloud mode
++ // Global Local/Cloud switch: one choke point for every picker — cloud mode
// surfaces only the hosted catalog, local mode hides it. The store keeps
// the full list (no refetch on flip); this is a view, not a mutation.
const appMode = useSettingsStore((s) => s.settings.appMode)
@@@ -83,7 -83,7 +97,7 @@@
useEffect(() => {
const handler = () => { fetchModels().catch(() => {}) }
window.addEventListener('lu-models-refresh', handler)
-- // A finished ComfyUI image/video download fires 'comfyui-model-downloaded' —
++ // A finished ComfyUI image/video download fires 'comfyui-model-downloaded' —
// from the download-store poller on completion AND from installBundleComplete
// after it rescans ComfyUI. useModels must refetch on it too, or a freshly
// downloaded model stays missing from the Installed tab + the chat/create
@@@ -97,7 -97,7 +111,7 @@@
window.removeEventListener('comfyui-model-downloaded', handler)
}
// fetchModels is reassigned below on every render but always wraps the
-- // same setModels — depending on it would just churn listeners.
++ // same setModels — depending on it would just churn listeners.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
@@@ -129,7 -129,7 +143,7 @@@
provider: pm.provider, providerName: pm.providerName,
contextLength: pm.contextLength, supportsTools: pm.supportsTools, supportsVision: pm.supportsVision,
thinkMode: pm.thinkMode,
-- // Friendly server label (LU Cloud) — pickers prefer it over the id.
++ // Friendly server label (LU Cloud) — pickers prefer it over the id.
displayName: pm.name !== pm.id ? pm.name : undefined,
} satisfies CloudModel
})
@@@ -137,7 -137,7 +151,7 @@@
)
for (const result of providerResults) {
if (result.status === 'fulfilled') {
-- // Filter out embedding models (e.g. nomic-embed-text) — not usable for chat
++ // Filter out embedding models (e.g. nomic-embed-text) — not usable for chat
allModels.push(...result.value.filter(m => !isEmbeddingModel(m.name)))
}
}
@@@ -152,14 -152,14 +166,14 @@@
builtinResumeAttempted = true
void resumeBuiltinEngines(bundledRaw)
}
-- } catch { /* engine command unavailable — non-critical */ }
++ } catch { /* engine command unavailable — non-critical */ }
} else if (!builtinResumeAttempted) {
// Non-builtin chat backend (LM Studio etc.): still resume the bundled
// embeddings server when its GGUF exists, so RAG survives a relaunch.
builtinResumeAttempted = true
try {
void resumeEmbedServer(await listBundledModels())
-- } catch { /* engine command unavailable — non-critical */ }
++ } catch { /* engine command unavailable — non-critical */ }
}
const ollamaEnabled = useProviderStore.getState().providers.ollama.enabled
const hasOllamaModels = allModels.some(m => m.provider === 'ollama')
@@@ -171,77 -171,26 +185,94 @@@
.map(m => ({ ...m, provider: 'ollama' as const, providerName: 'Ollama' })))
} catch { /* Ollama might not be running */ }
}
-- let comfyModels: AIModel[] = []
- const comfyOk = await checkComfyConnection()
- // Hard rule: Mac local media is MLX-only — ComfyUI never auto-starts
- // there (process.rs::auto_start_comfyui), so skip the probe outright
- // instead of a doomed connection check on every model-list refresh.
- const comfyOk = !isMacOS() && (await checkComfyConnection())
- if (comfyOk) {
- try {
- const [checkpoints, diffusionModels] = await Promise.all([getComfyCheckpoints(), getComfyDiffusionModels()])
- const allNames = [...checkpoints, ...diffusionModels]
- const complete = await filterPartialFiles(allNames)
+
- const classifyComfyModel = (name: string): AIModel => {
- if (isVideoModel(name)) return { name, model: name, size: 0, format: 'safetensors', architecture: 'unknown', type: 'video', providerName: 'ComfyUI' } as VideoModel
- return { name, model: name, size: 0, format: 'safetensors', architecture: 'unknown', type: 'image', providerName: 'ComfyUI' } as ImageModel
- }
- comfyModels = allNames.filter(name => complete.has(name)).map(classifyComfyModel)
- } catch { /* continue */ }
- }
- setModels([...allModels, ...comfyModels])
- } catch { /* ignore */ }
++let comfyModels: AIModel[] = []
++
++// macOS local media uses MLX rather than ComfyUI.
++const comfyOk = !isMacOS() && (await checkComfyConnection())
+
+if (comfyOk) {
+ const [imageResult, videoResult] = await Promise.allSettled([
+ getComfyImageModels(),
+ getComfyVideoModels(),
+ ])
+
+ if (imageResult.status === 'rejected') {
+ console.warn(
+ '[useModels] Failed to discover ComfyUI image models:',
+ imageResult.reason,
+ )
+ }
+
+ if (videoResult.status === 'rejected') {
+ console.warn(
+ '[useModels] Failed to discover ComfyUI video models:',
+ videoResult.reason,
+ )
+ }
+
+ const imageModels =
+ imageResult.status === 'fulfilled'
+ ? imageResult.value
+ : []
+
+ const videoModels =
+ videoResult.status === 'fulfilled'
+ ? videoResult.value
+ : []
+
++ // Preserve upstream's protection against incomplete multipart downloads.
++ const completeNames = await filterPartialFiles([
++ ...imageModels.map((model) => model.name),
++ ...videoModels.map((model) => model.name),
++ ])
++
++ const completeImageModels = imageModels.filter((model) =>
++ completeNames.has(model.name),
++ )
++
++ const completeVideoModels = videoModels.filter((model) =>
++ completeNames.has(model.name),
++ )
++
+ console.log('[useModels] ComfyUI models discovered:', {
- images: imageModels.map((model) => model.name),
- videos: videoModels.map((model) => model.name),
++ images: completeImageModels.map((model) => model.name),
++ videos: completeVideoModels.map((model) => model.name),
+ })
+
+ const getFormat = (name: string) =>
+ name.toLowerCase().endsWith('.gguf')
+ ? 'gguf'
+ : 'safetensors'
+
- const comfyImages: ImageModel[] = imageModels.map((model) => ({
++ const comfyImages: ImageModel[] = completeImageModels.map((model) => ({
+ name: model.name,
+ model: model.name,
+ size: 0,
+ format: getFormat(model.name),
+ architecture: model.type,
+ type: 'image',
+ providerName: 'ComfyUI',
+ }))
+
- const comfyVideos: VideoModel[] = videoModels.map((model) => ({
++ const comfyVideos: VideoModel[] = completeVideoModels.map((model) => ({
+ name: model.name,
+ model: model.name,
+ size: 0,
+ format: getFormat(model.name),
+ architecture: model.type,
+ type: 'video',
+ providerName: 'ComfyUI',
+ }))
+
+ comfyModels = [...comfyImages, ...comfyVideos]
+}
+
+setModels([...allModels, ...comfyModels])
+
+ } catch (error) {
+ console.warn('[useModels] Failed to fetch models:', error)
+ }
}, [setModels])
const pullModel = useCallback(
@@@ -261,11 -210,11 +292,11 @@@
try {
await promise
completePull(name)
-- try { await fetchModels() } catch { /* model list refresh failed — non-critical */ }
++ try { await fetchModels() } catch { /* model list refresh failed — non-critical */ }
// Auto-activate the freshly downloaded chat model so the chat actually
// switches to it instead of silently staying on the old default
// (forte_exe 2026-06-14: downloaded models didn't appear selected and
-- // the chat kept reverting). Chat models only — image/video live in the
++ // the chat kept reverting). Chat models only — image/video live in the
// Create view. Matched by exact list name so a mismatch just no-ops.
{
const freshly = useModelStore.getState().models.find((m) => m.name === name)
@@@ -274,7 -223,7 +305,7 @@@
// Auto-dismiss after 5s
setTimeout(() => dismissPull(name), 5000)
} catch (err) {
-- // Bug Z/a v2.5.0 — leonsk29 GH #48. Pre-v2.5.0 this catch was
++ // Bug Z/a v2.5.0 — leonsk29 GH #48. Pre-v2.5.0 this catch was
// silent ("card stays visible"), which combined with the Rust-
// side Ok(()) on stream-ended-without-success made LU flip the
// badge to "Completed" even when Ollama returned a 400 or the
@@@ -345,13 -294,13 +376,13 @@@
}
// Selecting a built-in model must also swap the loaded GGUF: the managed
-- // engine serves one model per process, so activation → swap_bundled_model.
++ // engine serves one model per process, so activation → swap_bundled_model.
// Other providers just set the active model as before.
const activateModel = useCallback((name: string) => {
setActiveModel(name)
const cfg = useProviderStore.getState().providers.openai
if (cfg.enabled && cfg.managed && getProviderIdFromModel(name) === 'openai') {
-- void activateBuiltinModel(name).catch(() => { /* engine unavailable — non-critical */ })
++ void activateBuiltinModel(name).catch(() => { /* engine unavailable — non-critical */ })
}
}, [setActiveModel])