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(models): der Scan kommt zurueck, mit Frist, Budget und einem Befund je Ordner
purpleea4aa567a8ff
diff --git a/src-tauri/src/commands/engine.rs b/src-tauri/src/commands/engine.rsindex 5148acf7..5620abbc 100644--- a/src-tauri/src/commands/engine.rs+++ b/src-tauri/src/commands/engine.rs@@ -326,7 +326,7 @@ pub(crate) fn split_shard_stem(stem: &str) -> Option<(&str, u32, u32)> {// this one-root door, so a change to the walk still has to survive them.#[allow(dead_code)]pub(crate) fn scan_gguf_models(dir: &Path) -> Vec<BundledModel> {- scan_gguf_roots(&[ScanRoot { dir, max_depth: MAX_SCAN_DEPTH }])+ scan_gguf_roots(&[ScanRoot { dir, max_depth: MAX_SCAN_DEPTH }]).models}/// One folder the GGUF scan walks, and how deep it may go there.@@ -335,6 +335,83 @@ pub(crate) struct ScanRoot<'a> {pub max_depth: usize,}+/// How one root fared. The Model Storage panel reads this, because "no models"+/// and "I could not finish looking" are different answers and the user is the+/// only one who can act on the difference.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub(crate) enum RootStatus {+ /// Walked to the end, within the budget.+ Ok,+ /// The deadline or the entry budget ran out. What was found is real, the+ /// list is not complete.+ Truncated,+ /// `read_dir` on the root itself failed: gone, unplugged, unreadable.+ Unreachable,+ /// Not a path the OS can resolve on its own: relative, or a shell `~`.+ Unusable,+}++impl RootStatus {+ pub(crate) fn as_str(self) -> &'static str {+ match self {+ RootStatus::Ok => "ok",+ RootStatus::Truncated => "truncated",+ RootStatus::Unreachable => "unreachable",+ RootStatus::Unusable => "unusable",+ }+ }+}++/// What a scan of several roots produced, and how each root fared.+pub(crate) struct ScanOutcome {+ pub models: Vec<BundledModel>,+ /// One entry per root, in the order the roots were given.+ pub statuses: Vec<RootStatus>,+}++/// Wall-clock ceiling for ONE root.+///+/// The walk has no idea what it was pointed at. Four levels below `C:\` or a+/// home directory is tens of thousands of `read_dir` calls, and `fetchModels`+/// awaits this: the Models tab, every picker and onboarding sit and wait for it.+/// A partial answer within a few seconds beats a complete one nobody stayed for,+/// and the panel says the answer is partial.+const SCAN_DEADLINE: Duration = Duration::from_secs(5);++/// Directory entries one root may look at. A second ceiling because a fast+/// local SSD can burn a very long list well inside the deadline, and because a+/// symlink loop is bounded by this and not by the clock.+const SCAN_ENTRY_BUDGET: usize = 20_000;++/// The ceilings for one root, carried down the walk.+struct ScanBudget {+ deadline: Instant,+ entries_left: usize,+ truncated: bool,+}++impl ScanBudget {+ fn new() -> Self {+ Self {+ deadline: Instant::now() + SCAN_DEADLINE,+ entries_left: SCAN_ENTRY_BUDGET,+ truncated: false,+ }+ }++ /// True while there is room for one more entry. Flips `truncated` the first+ /// time there is not, so the caller can say so instead of reporting a short+ /// list as the whole truth.+ fn take(&mut self) -> bool {+ if self.entries_left == 0 || Instant::now() >= self.deadline {+ self.truncated = true;+ return false;+ }+ self.entries_left -= 1;+ true+ }+}+/// The same scan over SEVERAL folders, in priority order.////// GH #122 (zrmdsxa, 2026-08-28): the folder the user names under Model@@ -344,18 +421,30 @@ pub(crate) struct ScanRoot<'a> {/// be loaded at all. The app models dir is root 0 and still wins every name/// collision, so adding a custom folder can never displace what the app/// installed itself.-pub(crate) fn scan_gguf_roots(roots: &[ScanRoot]) -> Vec<BundledModel> {+pub(crate) fn scan_gguf_roots(roots: &[ScanRoot]) -> ScanOutcome {// (root index, model). The index is the first tie-break below, so an// earlier root always wins a duplicate name.let mut ranked: Vec<(usize, BundledModel)> = Vec::new();+ let mut statuses: Vec<RootStatus> = Vec::with_capacity(roots.len());for (rank, root) in roots.iter().enumerate() {+ if !crate::commands::custom_models::is_usable_root(root.dir) {+ statuses.push(RootStatus::Unusable);+ continue;+ }+ // One call answers "is it there and readable" before the walk, so a+ // dead mount costs one timeout instead of one per directory.+ if std::fs::read_dir(root.dir).is_err() {+ statuses.push(RootStatus::Unreachable);+ continue;+ }let mut out = Vec::new();// (dir, base, total) → (part-numbers seen, path of part 1, byte sum).// The directory is part of the key: two unrelated split sets that share// a base name in different subfolders must never merge into one entry.let mut sets: std::collections::HashMap<(PathBuf, String, u32), (Vec<u32>, Option<String>, u64)> =std::collections::HashMap::new();- scan_gguf_dir(root.dir, 0, root.max_depth, &mut out, &mut sets);+ let mut budget = ScanBudget::new();+ scan_gguf_dir(root.dir, 0, root.max_depth, &mut budget, &mut out, &mut sets);for ((_dir, base, total), (mut parts, first_path, size)) in sets {parts.sort_unstable();parts.dedup();@@ -368,6 +457,7 @@ pub(crate) fn scan_gguf_roots(roots: &[ScanRoot]) -> Vec<BundledModel> {});}}+ statuses.push(if budget.truncated { RootStatus::Truncated } else { RootStatus::Ok });ranked.extend(out.into_iter().map(|m| (rank, m)));}// A name is the picker id, so it has to be unique. The earlier root wins,@@ -381,9 +471,9 @@ pub(crate) fn scan_gguf_roots(roots: &[ScanRoot]) -> Vec<BundledModel> {.then(depth(&a.1.path).cmp(&depth(&b.1.path))).then(a.1.path.cmp(&b.1.path))});- let mut out: Vec<BundledModel> = ranked.into_iter().map(|(_, m)| m).collect();- out.dedup_by(|a, b| a.name == b.name);- out+ let mut models: Vec<BundledModel> = ranked.into_iter().map(|(_, m)| m).collect();+ models.dedup_by(|a, b| a.name == b.name);+ ScanOutcome { models, statuses }}/// How far below the app models dir the scan walks. 0 alone was the shipped@@ -408,6 +498,7 @@ fn scan_gguf_dir(dir: &Path,depth: usize,max_depth: usize,+ budget: &mut ScanBudget,out: &mut Vec<BundledModel>,sets: &mut std::collections::HashMap<(PathBuf, String, u32), (Vec<u32>, Option<String>, u64)>,) {@@ -416,10 +507,16 @@ fn scan_gguf_dir(Err(_) => return,};for entry in entries.flatten() {+ // Both ceilings are asked per entry, so a folder the walk should never+ // have been pointed at costs seconds instead of minutes, and a symlink+ // that points back up the tree cannot spin forever.+ if !budget.take() {+ return;+ }let path = entry.path();if path.is_dir() {if depth < max_depth {- scan_gguf_dir(&path, depth + 1, max_depth, out, sets);+ scan_gguf_dir(&path, depth + 1, max_depth, budget, out, sets);}continue;}@@ -453,7 +550,15 @@ fn scan_gguf_dir(if name.is_empty() {continue;}- let size = entry.metadata().map(|m| m.len()).unwrap_or(0);+ // fs::metadata FOLLOWS the link, entry.metadata() does not. A GGUF+ // reached through a symlink otherwise reports the size of the link+ // itself, a hundred-odd bytes, and the HuggingFace cache is built+ // exactly that way: snapshots/<rev>/model.gguf is a link into blobs/.+ // The card would have shown a 14 GB model as 116 bytes.+ let size = std::fs::metadata(&path)+ .or_else(|_| entry.metadata())+ .map(|m| m.len())+ .unwrap_or(0);if let Some((base, part, total)) = split_shard_stem(&name) {let parent = path.parent().map(Path::to_path_buf).unwrap_or_default();let slot = sets@@ -1198,7 +1303,9 @@ fn list_bundled_models_blocking(max_depth: if i == 0 { MAX_SCAN_DEPTH } else { MAX_CUSTOM_SCAN_DEPTH },}).collect();- let models: Vec<serde_json::Value> = scan_gguf_roots(&roots)+ let outcome = scan_gguf_roots(&roots);+ let models: Vec<serde_json::Value> = outcome+ .models.into_iter().map(|m| {let is_loaded = loaded.as_deref() == Some(m.path.as_str());@@ -1216,12 +1323,19 @@ fn list_bundled_models_blocking(})}).collect();+ // Every folder that was asked, app dir first, WITH how it fared. "No+ // models" and "I could not finish looking" are different answers, and the+ // Model Storage panel is where the user can act on the difference.+ let dir_rows: Vec<serde_json::Value> = dirs+ .iter()+ .zip(outcome.statuses.iter())+ .map(|(d, st)| {+ serde_json::json!({ "path": d.to_string_lossy(), "status": st.as_str() })+ })+ .collect();Ok(serde_json::json!({"dir": dir.to_string_lossy(),- // Every folder that was actually walked, app dir first. The Model- // Storage panel says which ones those were instead of leaving the- // user to guess whether his folder was read.- "dirs": dirs.iter().map(|d| d.to_string_lossy().to_string()).collect::<Vec<_>>(),+ "dirs": dir_rows,"models": models,}))}@@ -2152,7 +2266,7 @@ mod tests {std::fs::create_dir_all(&four).unwrap();std::fs::write(four.join("Rocinante-12B-Q6_K.gguf"), b"bb").unwrap();- let models = scan_gguf_roots(&roots(&app, &custom));+ let models = scan_gguf_roots(&roots(&app, &custom)).models;let names: Vec<&str> = models.iter().map(|m| m.name.as_str()).collect();assert_eq!(names, vec!["Cydonia-24B-v4.1-Q4_K_M", "Rocinante-12B-Q6_K"]);// The path is absolute and points into the user's folder, which is@@ -2188,7 +2302,7 @@ mod tests {std::fs::write(nested.join("dup.gguf"), b"a").unwrap();std::fs::write(custom.join("dup.gguf"), b"bb").unwrap();- let models = scan_gguf_roots(&roots(&app, &custom));+ let models = scan_gguf_roots(&roots(&app, &custom)).models;assert_eq!(models.len(), 1, "one id per name");assert!(models[0].path.contains("app-dup"),@@ -2210,7 +2324,7 @@ mod tests {// model and must not be offered.std::fs::write(custom.join("Half-00001-of-00003.gguf"), b"c").unwrap();- let models = scan_gguf_roots(&roots(&app, &custom));+ let models = scan_gguf_roots(&roots(&app, &custom)).models;let names: Vec<&str> = models.iter().map(|m| m.name.as_str()).collect();assert_eq!(names, vec!["Big"]);assert_eq!(models[0].size, 3, "the set weighs both parts");@@ -2243,6 +2357,131 @@ mod tests {);}+ // ── The scan has to come back (S1, S6) ────────────────────────────────++ #[test]+ fn a_root_that_is_gone_or_relative_is_named_and_costs_the_others_nothing() {+ let app = scratch("status-app");+ std::fs::write(app.join("real.gguf"), b"a").unwrap();+ let gone = scratch("status-gone");+ std::fs::remove_dir_all(&gone).unwrap();+ let relative = PathBuf::from("some/relative/models");++ let outcome = scan_gguf_roots(&[+ ScanRoot { dir: &app, max_depth: MAX_SCAN_DEPTH },+ ScanRoot { dir: &gone, max_depth: MAX_CUSTOM_SCAN_DEPTH },+ ScanRoot { dir: &relative, max_depth: MAX_CUSTOM_SCAN_DEPTH },+ ]);+ assert_eq!(+ outcome.statuses,+ vec![RootStatus::Ok, RootStatus::Unreachable, RootStatus::Unusable],+ );+ // The app folder still answered, which is the point: one bad root is+ // not allowed to cost the list.+ assert_eq!(outcome.models.len(), 1);+ assert_eq!(outcome.models[0].name, "real");++ std::fs::remove_dir_all(&app).ok();+ }++ #[test]+ fn a_folder_too_big_for_the_budget_returns_what_it_has_and_says_so() {+ // The entry budget is the ceiling that does not depend on how fast the+ // disk is, so it is the one a test can hold.+ let app = scratch("budget-app");+ let big = scratch("budget-big");+ for i in 0..(SCAN_ENTRY_BUDGET + 50) {+ std::fs::write(big.join(format!("m{i:05}.gguf")), b"a").unwrap();+ }++ let outcome = scan_gguf_roots(&[+ ScanRoot { dir: &app, max_depth: MAX_SCAN_DEPTH },+ ScanRoot { dir: &big, max_depth: MAX_CUSTOM_SCAN_DEPTH },+ ]);+ assert_eq!(outcome.statuses, vec![RootStatus::Ok, RootStatus::Truncated]);+ // What came back is real, there is just not all of it.+ assert!(!outcome.models.is_empty());+ assert!(outcome.models.len() <= SCAN_ENTRY_BUDGET);++ std::fs::remove_dir_all(&app).ok();+ std::fs::remove_dir_all(&big).ok();+ }++ /// Negative control: a folder that fits reports Ok and the complete list.+ /// Without this, "truncated" above could just be the scan's normal answer.+ #[test]+ fn a_folder_inside_the_budget_reports_ok_and_everything_in_it() {+ let app = scratch("budget-small-app");+ let small = scratch("budget-small");+ for i in 0..10 {+ std::fs::write(small.join(format!("m{i}.gguf")), b"a").unwrap();+ }+ let outcome = scan_gguf_roots(&[+ ScanRoot { dir: &app, max_depth: MAX_SCAN_DEPTH },+ ScanRoot { dir: &small, max_depth: MAX_CUSTOM_SCAN_DEPTH },+ ]);+ assert_eq!(outcome.statuses, vec![RootStatus::Ok, RootStatus::Ok]);+ assert_eq!(outcome.models.len(), 10);++ std::fs::remove_dir_all(&app).ok();+ std::fs::remove_dir_all(&small).ok();+ }++ #[cfg(unix)]+ #[test]+ fn a_model_reached_through_a_symlink_reports_the_models_size() {+ // The HuggingFace cache layout: the real bytes sit in blobs/, and+ // snapshots/<rev>/<name>.gguf is a link to them. entry.metadata() does+ // not follow the link and reported the link's own size.+ let app = scratch("symlink-app");+ let custom = scratch("symlink-custom");+ let blobs = custom.join("blobs");+ let snap = custom.join("snapshots").join("abc123");+ std::fs::create_dir_all(&blobs).unwrap();+ std::fs::create_dir_all(&snap).unwrap();+ let real = blobs.join("deadbeef");+ std::fs::write(&real, vec![7u8; 4096]).unwrap();+ std::os::unix::fs::symlink(&real, snap.join("Cydonia-Q4_K_M.gguf")).unwrap();++ let outcome = scan_gguf_roots(&[+ ScanRoot { dir: &app, max_depth: MAX_SCAN_DEPTH },+ ScanRoot { dir: &custom, max_depth: MAX_CUSTOM_SCAN_DEPTH },+ ]);+ let found = outcome+ .models+ .iter()+ .find(|m| m.name == "Cydonia-Q4_K_M")+ .expect("the linked model must be listed");+ assert_eq!(found.size, 4096, "the link's own size is not the model's");++ std::fs::remove_dir_all(&app).ok();+ std::fs::remove_dir_all(&custom).ok();+ }++ /// Negative control for the same walk: a symlink pointing back at its own+ /// parent must not spin. The entry budget is what stops it.+ #[cfg(unix)]+ #[test]+ fn a_symlink_loop_ends_instead_of_running_forever() {+ let app = scratch("loop-app");+ let custom = scratch("loop-custom");+ let inner = custom.join("inner");+ std::fs::create_dir_all(&inner).unwrap();+ std::fs::write(inner.join("real.gguf"), b"abc").unwrap();+ std::os::unix::fs::symlink(&custom, inner.join("back")).unwrap();++ let started = Instant::now();+ let outcome = scan_gguf_roots(&[+ ScanRoot { dir: &app, max_depth: MAX_SCAN_DEPTH },+ ScanRoot { dir: &custom, max_depth: MAX_CUSTOM_SCAN_DEPTH },+ ]);+ assert!(started.elapsed() < SCAN_DEADLINE * 3, "the walk did not come back");+ assert!(outcome.models.iter().any(|m| m.name == "real"));++ std::fs::remove_dir_all(&app).ok();+ std::fs::remove_dir_all(&custom).ok();+ }+/// Negative control: no custom folder set leaves the list exactly as it/// shipped, one root.#[test]diff --git a/src/api/__tests__/custom-model-folder.test.ts b/src/api/__tests__/custom-model-folder.test.tsindex bf58c967..89e11071 100644--- a/src/api/__tests__/custom-model-folder.test.ts+++ b/src/api/__tests__/custom-model-folder.test.ts@@ -23,7 +23,7 @@ vi.mock('../backend', () => ({isMacOS: () => false,}))-import { customModelDirs, listBundledModels, bundledToAIModels } from '../engine'+import { customModelDirs, listBundledModels, bundledToAIModels, lastScanDirs, lastCustomScanDir } from '../engine'import { useSettingsStore } from '../../stores/settingsStore'import { DEFAULT_SETTINGS } from '../../lib/constants'@@ -31,6 +31,14 @@ import { DEFAULT_SETTINGS } from '../../lib/constants'* a space in a folder name. All three were in the issue's screenshots. */const WINDOWS_FOLDER = 'G:\\AI\\Models'+/** What Rust answers for a folder it walked to the end. */+function okDirs() {+ return [+ { path: '/app/models', status: 'ok' },+ { path: WINDOWS_FOLDER, status: 'ok' },+ ]+}+function setFolder(dir: string) {useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS, hfDownloadPathOverride: dir } })}@@ -45,7 +53,7 @@ describe('the folder under Model Storage reaches the scan', () => {setFolder(WINDOWS_FOLDER)expect(customModelDirs()).toEqual([WINDOWS_FOLDER])- backendCall.mockResolvedValue({ dir: '/app/models', dirs: ['/app/models', WINDOWS_FOLDER], models: [] })+ backendCall.mockResolvedValue({ dir: '/app/models', dirs: okDirs(), models: [] })await listBundledModels()expect(backendCall).toHaveBeenCalledWith('list_bundled_models', {@@ -77,7 +85,7 @@ describe('a model found in that folder is an Installed row', () => {setFolder(WINDOWS_FOLDER)backendCall.mockResolvedValue({dir: '/app/models',- dirs: ['/app/models', WINDOWS_FOLDER],+ dirs: okDirs(),models: [{name: 'Cydonia-24B-v4.1-Q4_K_M',@@ -105,7 +113,50 @@ describe('a model found in that folder is an Installed row', () => {// Negative control: an empty folder is an empty list, not an invented row.it('invents nothing when the folder holds no GGUF', async () => {setFolder(WINDOWS_FOLDER)- backendCall.mockResolvedValue({ dir: '/app/models', dirs: ['/app/models', WINDOWS_FOLDER], models: [] })+ backendCall.mockResolvedValue({ dir: '/app/models', dirs: okDirs(), models: [] })expect(bundledToAIModels(await listBundledModels())).toEqual([])})})++describe('the panel is told how the scan fared, not only what it found', () => {+ it('carries the per-folder verdict through', async () => {+ setFolder(WINDOWS_FOLDER)+ backendCall.mockResolvedValue({+ dir: '/app/models',+ dirs: [+ { path: '/app/models', status: 'ok' },+ { path: WINDOWS_FOLDER, status: 'truncated' },+ ],+ models: [{ name: 'partial', path: 'G:\\AI\\Models\\partial.gguf', size: 1, loaded: false }],+ })+ await listBundledModels()+ expect(lastScanDirs()).toHaveLength(2)+ // The user's own folder is the one the panel talks about, never the app's.+ expect(lastCustomScanDir()).toEqual({ path: WINDOWS_FOLDER, status: 'truncated' })+ // And a truncated walk still returns what it did find.+ expect(await listBundledModels()).toHaveLength(1)+ })++ // Negative control: an older backend answers without the field, and the+ // panel must then say nothing rather than accuse the folder.+ it('claims nothing when the backend does not report folders', async () => {+ setFolder(WINDOWS_FOLDER)+ backendCall.mockResolvedValue({ dir: '/app/models', models: [] })+ await listBundledModels()+ expect(lastScanDirs()).toEqual([])+ 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 () => {+ setFolder('')+ backendCall.mockResolvedValue({+ dir: '/app/models',+ dirs: [{ path: '/app/models', status: 'ok' }],+ models: [],+ })+ await listBundledModels()+ expect(lastCustomScanDir()).toBeNull()+ })+})diff --git a/src/api/engine.ts b/src/api/engine.tsindex 8504bb3b..165eb321 100644--- a/src/api/engine.ts+++ b/src/api/engine.ts@@ -217,14 +217,43 @@ export function customModelDirs(): string[] {return dir ? [dir] : []}+/** How one scanned folder fared. `truncated` is a real answer: the walk has a+ * wall-clock deadline and an entry budget per folder, because `fetchModels`+ * awaits it and four levels below a home directory is tens of thousands of+ * directory reads. A partial list within a few seconds beats a complete one+ * nobody waited for, as long as the panel says it is partial. */+export interface ScannedDir {+ path: string+ status: 'ok' | 'truncated' | 'unreachable' | 'unusable'+}++// The folders the LAST listing walked, app dir first. Kept here rather than+// returned, so no call site has to change to ignore it; Model Storage is the+// one surface that asks.+let lastDirs: ScannedDir[] = []++/** What the last `listBundledModels()` walked, and how each folder fared. */+export function lastScanDirs(): ScannedDir[] {+ return lastDirs+}++/** 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). */+export function lastCustomScanDir(): ScannedDir | null {+ return lastDirs[1] ?? null+}+/** List downloaded GGUFs in the app models dir and in the user's own model* folder. Refreshes the name→path map. */export async function listBundledModels(): Promise<BundledModel[]> {- const res = await backendCall<{ dir: string; dirs?: string[]; models: BundledModel[] }>(+ const res = await backendCall<{ dir: string; dirs?: ScannedDir[]; models: BundledModel[] }>('list_bundled_models',{ extraDirs: customModelDirs() },)const models = res?.models ?? []+ // An older backend answers without `dirs`; an empty list then says "nothing+ // known about the folders", which is the truth and renders no line.+ lastDirs = Array.isArray(res?.dirs) ? res.dirs : []pathByName.clear()ctxTrainByName.clear()for (const m of models) {diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsxindex dc4c92a0..07c49414 100644--- a/src/components/settings/SettingsPage.tsx+++ b/src/components/settings/SettingsPage.tsx@@ -64,6 +64,7 @@ import { ArrowUpCircle, KeyRound, RefreshCw } from 'lucide-react'import { CLOUD_BASE } from '../../api/cloud/config'import { formatBytes } from '../../lib/formatters'import { syncCustomModelDir, type CustomModelDirResult } from '../../lib/custom-model-dir'+import { listBundledModels, lastCustomScanDir, type ScannedDir } from '../../api/engine'import { CivitaiApiKeySetting } from './CivitaiApiKeySetting'// ── User profile picture (Appearance) ───────────────────────────@@ -267,8 +268,21 @@ function HfDownloadPathSetting() {const updateSettings = useSettingsStore(s => s.updateSettings)const [draft, setDraft] = useState(override)const [comfy, setComfy] = useState<CustomModelDirResult | null>(null)+ const [scan, setScan] = useState<ScannedDir | null>(null)useEffect(() => { setDraft(override) }, [override])+ // How the GGUF scan itself fared in that folder. A folder too big to finish+ // within the budget returns a real but partial list, and the only person who+ // can do anything about that is the one who chose the folder.+ useEffect(() => {+ let alive = true+ if (!override) { setScan(null); return }+ void listBundledModels()+ .then(() => { if (alive) setScan(lastCustomScanDir()) })+ .catch(() => { if (alive) setScan(null) })+ return () => { alive = false }+ }, [override])+// Both directions of the folder: our own GGUF scan reads it on the next// model refresh, and the ComfyUI-shaped subfolders in it are handed to// ComfyUI. Runs on mount too, so a folder set by an older build reaches@@ -324,6 +338,11 @@ 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.+ </div>+ )}{override && comfy !== null && <CustomModelDirNote result={comfy} />}</div>)diff --git a/src/lib/__tests__/custom-model-dir-comfy.test.ts b/src/lib/__tests__/custom-model-dir-comfy.test.tsindex be647c02..d1dd0ae4 100644--- a/src/lib/__tests__/custom-model-dir-comfy.test.ts+++ b/src/lib/__tests__/custom-model-dir-comfy.test.ts@@ -89,6 +89,11 @@ describe('the Model Storage copy tells the truth', () => {expect(src).toMatch(/run on Apple MLX, not ComfyUI/)})+ 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/)+ })+it('says why a folder produced nothing instead of going quiet', () => {expect(src).toMatch(/result\.status === 'unusable'/)expect(src).toMatch(/result\.status === 'unreachable'/)