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
fix(settings): Model Storage sagt, wie der Ordner-Scan ausgegangen ist
purple2383f0257e01
diff --git a/src/api/__tests__/custom-model-folder.test.ts b/src/api/__tests__/custom-model-folder.test.tsindex 89e11071..b46714bc 100644--- a/src/api/__tests__/custom-model-folder.test.ts+++ b/src/api/__tests__/custom-model-folder.test.ts@@ -147,6 +147,39 @@ describe('the panel is told how the scan fared, not only what it found', () => {expect(lastCustomScanDir()).toBeNull()})+ // A13: the row is found by PATH, not by position. Read off an index, the+ // panel reports the app folder's verdict about the user's folder the day the+ // order changes, and Windows writes the same folder in more than one way.+ it('finds the row for the folder that was asked about, whatever its position', async () => {+ setFolder(WINDOWS_FOLDER)+ backendCall.mockResolvedValue({+ dir: '/app/models',+ dirs: [+ { path: 'g:/ai/models\\', status: 'unreachable' },+ { path: '/app/models', status: 'ok' },+ ],+ models: [],+ })+ await listBundledModels()+ expect(lastCustomScanDir()?.status).toBe('unreachable')+ })++ // Negative control: a verdict about SOME other folder is not a verdict about+ // this one, and silence beats a wrong accusation.+ it('reports nothing when the answer does not mention the folder at all', async () => {+ setFolder(WINDOWS_FOLDER)+ backendCall.mockResolvedValue({+ dir: '/app/models',+ dirs: [+ { path: '/app/models', status: 'ok' },+ { path: 'D:\\somewhere\\else', status: 'truncated' },+ ],+ models: [],+ })+ await listBundledModels()+ expect(lastCustomScanDir()).toBeNull()+ })+// Negative control: with no folder of his own there is no second row, so the// panel has nothing to report either.it('has no custom row when no folder is set', async () => {diff --git a/src/api/engine.ts b/src/api/engine.tsindex aa2e5216..28f6a3c8 100644--- a/src/api/engine.ts+++ b/src/api/engine.ts@@ -274,10 +274,25 @@ export function lastScanDirs(): ScannedDir[] {return lastDirs}+/** Same folder, written two ways. Windows arrives with backslashes and any+ * case, and `C:\\` and `c:/` are one folder; the trailing separator is noise+ * on every platform. Only ever used to find the row for a folder WE asked to+ * be scanned, so folding case cannot pull in a stranger's folder. */+function samePath(a: string, b: string): boolean {+ const key = (p: string) => String(p ?? '').replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase()+ return key(a) === key(b)+}+/** The user's own folder from the last listing, or null when none was set (or- * when it was the app folder under another name, which Rust folds away). */+ * when it was the app folder under another name, which Rust folds away).+ *+ * Matched by path rather than by position: the app dir is row 0 today, but a+ * row read off an index is a row that silently reports the wrong folder the+ * moment that stops being true. */export function lastCustomScanDir(): ScannedDir | null {- return lastDirs[1] ?? null+ const wanted = customModelDirs()[0]+ if (!wanted) return null+ return lastDirs.find((d) => samePath(d.path, wanted)) ?? null}/** List downloaded GGUFs in the app models dir and in the user's own modeldiff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsxindex dcd324fc..8ecece98 100644--- a/src/components/settings/SettingsPage.tsx+++ b/src/components/settings/SettingsPage.tsx@@ -264,7 +264,7 @@ function WorkflowSection() {// Models tab stayed empty beside a folder full of models. It is read now// (lib/custom-model-dir.ts), and the copy says what it does.-function HfDownloadPathSetting() {+export function HfDownloadPathSetting() {const override = useSettingsStore(s => s.settings.hfDownloadPathOverride)const updateSettings = useSettingsStore(s => s.updateSettings)const [draft, setDraft] = useState(override)@@ -294,6 +294,11 @@ function HfDownloadPathSetting() {return () => { alive = false }}, [override])+ // One line, and only when there is something to say. It also swallows the+ // ComfyUI handoff note below: a folder that cannot be read has one problem,+ // not two, and two amber lines saying the same thing read as two faults.+ const scanNote = modelDirScanNote(scan?.status)+function apply(next: string) {setDraft(next)updateSettings({ hfDownloadPathOverride: next })@@ -339,16 +344,41 @@ function HfDownloadPathSetting() {</button>)}</div>- {override && scan?.status === 'truncated' && (- <div className="text-[0.6rem] leading-relaxed text-amber-600 dark:text-amber-400">- That folder is too large to read to the end, so the list below it is what LU found before it stopped. Point this at the folder that actually holds the models rather than at a whole drive.+ {override && scanNote && (+ <div data-testid="model-dir-scan-note" className="text-[0.6rem] leading-relaxed text-amber-600 dark:text-amber-400">+ {scanNote}</div>)}- {override && comfy !== null && <CustomModelDirNote result={comfy} />}+ {override && comfy !== null && !scanNote && <CustomModelDirNote result={comfy} />}</div>)}+/**+ * What the folder scan found, in one sentence, or nothing at all.+ *+ * A13, Windows counter-check 2026-09-02: `C:\` as the model folder stayed+ * fully operable and said nothing. Rust had the answer the whole time (the+ * walk has a five second deadline and a 20 000 entry budget per folder and+ * reports `truncated` when it runs out), the panel simply never showed it, and+ * a partial list that looks complete is the kind of thing people debug for an+ * hour.+ *+ * `ok` is silence on purpose: a folder that scanned clean needs no line.+ */+export function modelDirScanNote(status: ScannedDir['status'] | null | undefined): string {+ if (status === 'truncated') {+ return 'This folder is too big to scan completely. Only the first files were read; pick a folder that holds just your models.'+ }+ if (status === 'unreachable') {+ return 'This folder cannot be reached right now (drive disconnected or path missing). Models in it are hidden until it is back.'+ }+ if (status === 'unusable') {+ return 'This path is not a folder LU can read.'+ }+ return ''+}+/*** What became of the folder, in one line.*diff --git a/src/components/settings/__tests__/model-dir-scan-note.test.ts b/src/components/settings/__tests__/model-dir-scan-note.test.tsnew file mode 100644index 00000000..a1e089cf--- /dev/null+++ b/src/components/settings/__tests__/model-dir-scan-note.test.ts@@ -0,0 +1,111 @@+/**+ * @vitest-environment jsdom+ *+ * A13, Windows counter-check 2026-09-02, point 5: "mit C:\\ als Ordner bleibt+ * die App zwar bedienbar und die Liste stimmt, aber es erscheint kein Hinweis+ * zu gross".+ *+ * Rust has had the answer the whole time. The GGUF walk carries a five second+ * deadline and a 20 000 entry budget per folder and reports `truncated` when+ * it runs out, plus `unreachable` for a drive that is gone and `unusable` for+ * a path the OS cannot resolve. A partial list that looks complete is the kind+ * of thing people debug for an hour, so the panel says which one it got.+ *+ * Run: npx vitest run src/components/settings/__tests__/model-dir-scan-note.test.ts+ */+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import { createElement } from 'react'+import { render, screen, cleanup, act } from '@testing-library/react'+import type { ScannedDir } from '../../../api/engine'++let scanned: ScannedDir | null = null+vi.mock('../../../api/engine', async () => {+ const actual = await vi.importActual<typeof import('../../../api/engine')>('../../../api/engine')+ return {+ ...actual,+ listBundledModels: vi.fn(async () => []),+ lastCustomScanDir: () => scanned,+ }+})+vi.mock('../../../lib/custom-model-dir', () => ({+ syncCustomModelDir: vi.fn(async () => ({ status: 'ok', folders: ['loras'], yaml: '' })),+}))+vi.mock('../../../api/backend', () => ({+ backendCall: vi.fn(async () => null),+ isTauri: () => true,+ isMacOS: () => false,+ openExternal: vi.fn(),+ secretGet: vi.fn().mockRejectedValue(new Error('no keychain here')),+ secretSet: vi.fn(),+ secretDelete: vi.fn(),+}))++const { HfDownloadPathSetting, modelDirScanNote } = await import('../SettingsPage')+const { useSettingsStore } = await import('../../../stores/settingsStore')++const FOLDER = 'C:\\'++beforeEach(() => {+ scanned = null+ useSettingsStore.getState().updateSettings({ hfDownloadPathOverride: FOLDER })+})+afterEach(() => {+ cleanup()+ useSettingsStore.getState().updateSettings({ hfDownloadPathOverride: '' })+})++async function noteFor(status: ScannedDir['status']) {+ scanned = { path: FOLDER, status }+ render(createElement(HfDownloadPathSetting))+ await act(async () => { await Promise.resolve(); await Promise.resolve(); await Promise.resolve() })+ return screen.queryByTestId('model-dir-scan-note')?.textContent ?? ''+}++describe('the sentence for each verdict', () => {+ it('names the size problem and what to do about it', () => {+ expect(modelDirScanNote('truncated')).toBe(+ 'This folder is too big to scan completely. Only the first files were read; pick a folder that holds just your models.',+ )+ })++ it('says the folder is away, not that it is empty', () => {+ expect(modelDirScanNote('unreachable')).toBe(+ 'This folder cannot be reached right now (drive disconnected or path missing). Models in it are hidden until it is back.',+ )+ })++ it('says a path that is no folder is no folder', () => {+ expect(modelDirScanNote('unusable')).toBe('This path is not a folder LU can read.')+ })++ it('stays silent on a clean scan', () => {+ expect(modelDirScanNote('ok')).toBe('')+ expect(modelDirScanNote(null)).toBe('')+ expect(modelDirScanNote(undefined)).toBe('')+ })+})++describe('Model Storage shows it under the path', () => {+ it('warns about a whole drive instead of pretending the list is complete', async () => {+ expect(await noteFor('truncated')).toContain('too big to scan completely')+ })++ it('explains a disconnected drive', async () => {+ expect(await noteFor('unreachable')).toContain('cannot be reached right now')+ })++ it('explains a path that is not a folder', async () => {+ expect(await noteFor('unusable')).toBe('This path is not a folder LU can read.')+ })++ it('says nothing at all when the scan finished', async () => {+ expect(await noteFor('ok')).toBe('')+ // The ComfyUI handoff line is a different subject and still shows.+ expect(screen.getByText(/passes/)).toBeTruthy()+ })++ it('does not stack two warnings about one broken folder', async () => {+ await noteFor('unreachable')+ expect(screen.queryByText(/Check that the drive is connected/)).toBeNull()+ })+})diff --git a/src/lib/__tests__/custom-model-dir-comfy.test.ts b/src/lib/__tests__/custom-model-dir-comfy.test.tsindex 7d5b8ccb..8294a359 100644--- a/src/lib/__tests__/custom-model-dir-comfy.test.ts+++ b/src/lib/__tests__/custom-model-dir-comfy.test.ts@@ -89,9 +89,12 @@ describe('the Model Storage copy tells the truth', () => {expect(src).toMatch(/run on Apple MLX, not ComfyUI/)})+ // A13: die Zeile haengt jetzt an modelDirScanNote, das alle drei Urteile+ // des Rust-Scans in einen Satz uebersetzt (Wirkung geprueft in+ // components/settings/__tests__/model-dir-scan-note.test.ts).it('says when the folder was too large to read to the end', () => {- expect(src).toMatch(/scan\?\.status === 'truncated'/)- expect(src).toMatch(/too large to read to the end/)+ expect(src).toMatch(/modelDirScanNote\(scan\?\.status\)/)+ expect(src).toMatch(/too big to scan completely/)})it('says why a folder produced nothing instead of going quiet', () => {