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(modelle): der Download schreibt dorthin, wo das laufende ComfyUI nachsieht

purpleb691b6858d75
diff --git a/src-tauri/src/commands/comfy_folders.rs b/src-tauri/src/commands/comfy_folders.rs
new file mode 100644
index 00000000..b35efd8b
--- /dev/null
+++ b/src-tauri/src/commands/comfy_folders.rs
@@ -0,0 +1,371 @@
+//! Where a model lives, asked of the engine that has to find it.
+//!
+//! .__nothing_ (Discord help-chat, 2026-09-02, Windows 11, LU 2.6.7): FramePack
+//! F1 and Wan 2.1 installed through our own Get button and never appeared in
+//! the Create picker. Moving the files into a different ComfyUI folder by hand
+//! fixed it.
+//!
+//! Both halves of that sentence are the bug. LU decided where the file goes on
+//! its own: `<the folder we resolved>/models/<subfolder>`, built from a path we
+//! found by looking for `main.py`. The picker asks something else entirely —
+//! the RUNNING ComfyUI, through its `/object_info` enums. Two answers to one
+//! question, and they only agree while the ComfyUI we found is the ComfyUI that
+//! is running AND that ComfyUI keeps its models where we guessed.
+//!
+//! It does not, more often than we assumed:
+//! * The Comfy-Org desktop app keeps `main.py` in its program folder and the
+//! models under a base directory the user picked at install time, and it
+//! starts the server with `--base-directory`.
+//! * `--base-directory` does the same for anybody starting ComfyUI by hand.
+//! * An `extra_model_paths.yaml` adds roots that are nowhere near `main.py` —
+//! LU writes one itself for the Model Storage folder (see custom_models.rs).
+//! * A second install on the box is the classic one (pnwpdr4519, 2026-07-27).
+//!
+//! In every one of those the download lands in a tree nothing scans, the picker
+//! stays empty, and moving the file into the other ComfyUI folder fixes it.
+//!
+//! ComfyUI answers the question itself, exactly and per folder key:
+//!
+//! GET /internal/folder_paths
+//! {"checkpoints": ["C:\\...\\models\\checkpoints"],
+//! "diffusion_models": ["C:\\...\\models\\unet", "C:\\...\\models\\diffusion_models"],
+//! ...}
+//!
+//! (`folder_names_and_paths[key][0]`, the directory list, in
+//! api_server/routes/internal/internal_routes.py.) That is the single
+//! definition of where a model lives, and it is the one the picker will use,
+//! because it comes from the process that builds the picker's enums.
+//!
+//! Everything here is best effort. A ComfyUI that is not running answers
+//! nothing, and a download must still work then — the caller falls back to the
+//! old rule, which is right whenever there is nothing better to know.
+
+use std::collections::HashMap;
+use std::path::PathBuf;
+use std::sync::Mutex;
+use std::time::{Duration, Instant};
+
+/// How long an answer is trusted before it is asked again. Long enough that a
+/// bundle of five files asks once, short enough that restarting ComfyUI
+/// somewhere else is noticed within a click or two.
+const CACHE_TTL: Duration = Duration::from_secs(30);
+
+/// The engine is either there or it is not; a folder list is not worth a long
+/// wait in front of a download.
+const FETCH_TIMEOUT: Duration = Duration::from_secs(3);
+
+/// Is this an absolute path anywhere, not only on the platform this build runs
+/// on? The answer comes from ComfyUI, so a Windows answer has to read as
+/// absolute in a test on any machine; `is_absolute` alone calls `D:\\models`
+/// relative everywhere but Windows. Whether the path is USABLE is a separate
+/// question, and `folders_of` answers it by refusing to ask a remote engine at
+/// all: those paths are on the other machine.
+fn looks_absolute(raw: &str) -> bool {
+ let p = std::path::Path::new(raw);
+ if p.is_absolute() {
+ return true;
+ }
+ let b = raw.as_bytes();
+ // A UNC share, or a drive letter followed by a separator.
+ raw.starts_with("\\\\")
+ || (b.len() >= 3 && b[0].is_ascii_alphabetic() && b[1] == b':' && (b[2] == b'\\' || b[2] == b'/'))
+}
+
+/// The last segment of a path, splitting on BOTH separators rather than on the
+/// one this build calls a separator. Same reason as `looks_absolute`: the path
+/// comes from ComfyUI and a Windows answer has to be readable in a test on any
+/// machine (`Path::file_name` hands back the whole of `D:\\a\\b` off Windows).
+fn last_segment(p: &std::path::Path) -> String {
+ p.to_string_lossy()
+ .trim_end_matches(['/', '\\'])
+ .rsplit(['/', '\\'])
+ .next()
+ .unwrap_or("")
+ .to_string()
+}
+
+/// The directories the running ComfyUI scans, per `folder_paths` key.
+#[derive(Clone, Debug, Default)]
+pub struct ComfyFolders {
+ dirs: HashMap<String, Vec<PathBuf>>,
+}
+
+impl ComfyFolders {
+ /// Read one `/internal/folder_paths` answer.
+ ///
+ /// Tolerant of the shapes that answer can have: a list of directories per
+ /// key is the documented one, a bare string is accepted because it costs a
+ /// line, and anything else is skipped rather than guessed at. Relative
+ /// entries are dropped: this is used to build an absolute write target, and
+ /// a path relative to ComfyUI's working directory is not one we can join.
+ pub fn parse(value: &serde_json::Value) -> Self {
+ fn keep(raw: &str) -> Option<PathBuf> {
+ if looks_absolute(raw) { Some(PathBuf::from(raw)) } else { None }
+ }
+ let mut dirs: HashMap<String, Vec<PathBuf>> = HashMap::new();
+ let Some(map) = value.as_object() else {
+ return Self::default();
+ };
+ for (key, entry) in map {
+ let mut paths: Vec<PathBuf> = Vec::new();
+ match entry {
+ serde_json::Value::Array(list) => {
+ for item in list {
+ if let Some(p) = item.as_str().and_then(keep) {
+ paths.push(p);
+ }
+ }
+ }
+ serde_json::Value::String(s) => {
+ if let Some(p) = keep(s) {
+ paths.push(p);
+ }
+ }
+ _ => {}
+ }
+ if !paths.is_empty() {
+ dirs.insert(key.to_ascii_lowercase(), paths);
+ }
+ }
+ Self { dirs }
+ }
+
+ pub fn is_empty(&self) -> bool {
+ self.dirs.is_empty()
+ }
+
+ /// Every directory the engine scans, for the delete and the size probe:
+ /// those have to look where the download wrote, or the file is on disk and
+ /// the app can neither measure nor remove it.
+ pub fn all_dirs(&self) -> Vec<PathBuf> {
+ let mut out: Vec<PathBuf> = Vec::new();
+ for list in self.dirs.values() {
+ for p in list {
+ if !out.contains(p) {
+ out.push(p.clone());
+ }
+ }
+ }
+ out
+ }
+
+ /// Where a file of this catalog subfolder belongs, according to the engine.
+ ///
+ /// `None` when the engine does not know the key at all, which is the honest
+ /// answer for a pack folder under `custom_nodes` (ComfyUI has no
+ /// `folder_paths` key for those) and for a ComfyUI too old to serve the
+ /// route. The caller then keeps the old rule.
+ ///
+ /// Which one, when the key has several: the directory whose own name is the
+ /// subfolder we were asked about, and the first one otherwise. ComfyUI lists
+ /// `diffusion_models` as `[models\unet, models\diffusion_models]`, and a
+ /// file the catalog calls a `diffusion_models` file belongs in the folder of
+ /// that name — both are scanned, so this is about keeping the tree the way
+ /// the user (and our own delete) expects it, not about visibility.
+ pub fn dir_for(&self, subfolder: &str) -> Option<PathBuf> {
+ let key = subfolder.trim().to_ascii_lowercase();
+ if key.is_empty() || key.contains('/') || key.contains('\\') {
+ return None;
+ }
+ let paths = self.dirs.get(&key)?;
+ let named = paths.iter().find(|p| last_segment(p).eq_ignore_ascii_case(&key));
+ named.or_else(|| paths.first()).cloned()
+ }
+}
+
+static CACHE: Mutex<Option<(Instant, ComfyFolders)>> = Mutex::new(None);
+
+/// The last answer, without asking again. For the paths that cannot await (the
+/// delete command): a stale answer is still the engine's answer, and the
+/// alternative is the guess this module exists to replace.
+pub fn cached() -> Option<ComfyFolders> {
+ CACHE
+ .lock()
+ .ok()
+ .and_then(|g| g.as_ref().map(|(_, f)| f.clone()))
+}
+
+fn fresh_enough() -> Option<ComfyFolders> {
+ let guard = CACHE.lock().ok()?;
+ let (at, folders) = guard.as_ref()?;
+ if at.elapsed() < CACHE_TTL {
+ Some(folders.clone())
+ } else {
+ None
+ }
+}
+
+fn remember(folders: ComfyFolders) {
+ if let Ok(mut guard) = CACHE.lock() {
+ *guard = Some((Instant::now(), folders));
+ }
+}
+
+/// Drop the cache, so the next question reaches the engine. Called when the
+/// ComfyUI path or port changes under us.
+pub fn forget() {
+ if let Ok(mut guard) = CACHE.lock() {
+ *guard = None;
+ }
+}
+
+/// Is the engine on this machine? Only then are its folder names ours to use.
+fn is_loopback(host: &str) -> bool {
+ let h = host.trim().trim_matches(|c| c == '[' || c == ']').to_ascii_lowercase();
+ h == "localhost"
+ || h == "127.0.0.1"
+ || h == "::1"
+ || h.parse::<std::net::IpAddr>().map(|ip| ip.is_loopback()).unwrap_or(false)
+}
+
+/// Ask the running ComfyUI where its model folders are.
+///
+/// Answers `None` when there is no engine to ask, which is not an error: the
+/// Model Manager downloads models with ComfyUI shut down all the time.
+pub async fn folders_of(host: &str, port: u16) -> Option<ComfyFolders> {
+ if let Some(hit) = fresh_enough() {
+ return Some(hit);
+ }
+ let host = if host.trim().is_empty() { "127.0.0.1" } else { host.trim() };
+ // A ComfyUI on another machine answers with folders on THAT machine, and
+ // the download writes on this one. Nothing to learn here, so the caller
+ // keeps its own rule (which is what a remote setup has always had).
+ if !is_loopback(host) {
+ return None;
+ }
+ let url = format!("http://{}:{}/internal/folder_paths", host, port);
+ let client = reqwest::Client::builder().timeout(FETCH_TIMEOUT).build().ok()?;
+ let body = client.get(&url).send().await.ok()?;
+ if !body.status().is_success() {
+ return None;
+ }
+ let json: serde_json::Value = body.json().await.ok()?;
+ let folders = ComfyFolders::parse(&json);
+ if folders.is_empty() {
+ return None;
+ }
+ remember(folders.clone());
+ Some(folders)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use serde_json::json;
+
+ /// A real answer from a ComfyUI started with `--base-directory`, shortened.
+ /// `main.py` sits in the program folder, the models do not.
+ fn desktop_app_answer() -> serde_json::Value {
+ json!({
+ "checkpoints": ["D:\\Models\\ComfyUI\\models\\checkpoints"],
+ "diffusion_models": [
+ "D:\\Models\\ComfyUI\\models\\unet",
+ "D:\\Models\\ComfyUI\\models\\diffusion_models"
+ ],
+ "vae": ["D:\\Models\\ComfyUI\\models\\vae"],
+ "text_encoders": [
+ "D:\\Models\\ComfyUI\\models\\text_encoders",
+ "D:\\Models\\ComfyUI\\models\\clip"
+ ],
+ "clip_vision": ["D:\\Models\\ComfyUI\\models\\clip_vision"],
+ "audio_encoders": ["D:\\Models\\ComfyUI\\models\\audio_encoders"],
+ "loras": ["D:\\Models\\ComfyUI\\models\\loras"]
+ })
+ }
+
+ /// The two files of the report, and the folder each one belongs in.
+ #[test]
+ fn the_engine_names_the_folder_for_the_two_models_that_went_missing() {
+ let folders = ComfyFolders::parse(&desktop_app_answer());
+ // Wan 2.1 1.3B and FramePack F1 both ship their main file as a
+ // diffusion_models file.
+ assert_eq!(
+ folders.dir_for("diffusion_models"),
+ Some(PathBuf::from("D:\\Models\\ComfyUI\\models\\diffusion_models")),
+ );
+ // FramePack's SigCLIP encoder, the one folder no reader used to know.
+ assert_eq!(
+ folders.dir_for("clip_vision"),
+ Some(PathBuf::from("D:\\Models\\ComfyUI\\models\\clip_vision")),
+ );
+ }
+
+ /// ComfyUI lists `models\unet` first for that key. A file the catalog calls
+ /// a diffusion_models file goes into the folder of that name.
+ #[test]
+ fn the_folder_of_that_name_wins_over_the_first_in_the_list() {
+ let folders = ComfyFolders::parse(&desktop_app_answer());
+ assert_eq!(
+ folders.dir_for("text_encoders"),
+ Some(PathBuf::from("D:\\Models\\ComfyUI\\models\\text_encoders")),
+ );
+ }
+
+ /// ...and when no entry carries that name, the first one is the answer,
+ /// because the engine scans it and we have nothing better.
+ #[test]
+ fn the_first_entry_answers_when_none_is_named_after_the_key() {
+ let folders = ComfyFolders::parse(&json!({
+ "diffusion_models": ["/srv/ai/unet", "/srv/ai/second"]
+ }));
+ assert_eq!(folders.dir_for("diffusion_models"), Some(PathBuf::from("/srv/ai/unet")));
+ }
+
+ #[test]
+ fn a_key_the_engine_does_not_have_is_not_invented() {
+ let folders = ComfyFolders::parse(&desktop_app_answer());
+ assert_eq!(folders.dir_for("upscale_models"), None);
+ // A pack folder under custom_nodes is not a folder_paths key at all.
+ assert_eq!(folders.dir_for("custom_nodes/ComfyUI-AnimateDiff-Evolved/models"), None);
+ assert_eq!(folders.dir_for(""), None);
+ }
+
+ /// An answer we cannot use must read as no answer, never as an empty tree:
+ /// the caller keeps its own rule on `None` and would write into nowhere on
+ /// an empty map.
+ #[test]
+ fn a_useless_answer_is_no_answer() {
+ assert!(ComfyFolders::parse(&json!({})).is_empty());
+ assert!(ComfyFolders::parse(&json!([])).is_empty());
+ assert!(ComfyFolders::parse(&json!("nope")).is_empty());
+ // Relative entries cannot be joined into a write target.
+ assert!(ComfyFolders::parse(&json!({"checkpoints": ["models/checkpoints"]})).is_empty());
+ // A single string is accepted; it costs one line and some forks do it.
+ assert_eq!(
+ ComfyFolders::parse(&json!({"vae": "/srv/ai/vae"})).dir_for("vae"),
+ Some(PathBuf::from("/srv/ai/vae")),
+ );
+ }
+
+ #[test]
+ fn a_windows_answer_reads_as_absolute_on_any_machine() {
+ assert!(looks_absolute("D:\\Models\\ComfyUI\\models\\vae"));
+ assert!(looks_absolute("C:/ComfyUI/models/vae"));
+ assert!(looks_absolute("\\\\nas\\ai\\models\\vae"));
+ assert!(looks_absolute("/srv/ai/models/vae"));
+ assert!(!looks_absolute("models/vae"));
+ assert!(!looks_absolute(""));
+ }
+
+ /// The engine on another machine names folders on that machine. Its answer
+ /// is not a write target here, so it is never asked for one.
+ #[test]
+ fn only_an_engine_on_this_machine_is_asked() {
+ assert!(is_loopback("127.0.0.1"));
+ assert!(is_loopback("localhost"));
+ assert!(is_loopback("::1"));
+ assert!(is_loopback("[::1]"));
+ assert!(!is_loopback("192.168.0.54"));
+ assert!(!is_loopback("comfy.homelab"));
+ }
+
+ /// Every folder the engine named, for the delete and the size probe.
+ #[test]
+ fn all_dirs_lists_every_folder_once() {
+ let folders = ComfyFolders::parse(&desktop_app_answer());
+ let all = folders.all_dirs();
+ assert!(all.contains(&PathBuf::from("D:\\Models\\ComfyUI\\models\\unet")));
+ assert!(all.contains(&PathBuf::from("D:\\Models\\ComfyUI\\models\\clip_vision")));
+ assert_eq!(all.len(), 9, "{all:?}");
+ }
+}
diff --git a/src-tauri/src/commands/download.rs b/src-tauri/src/commands/download.rs
index e9f8f9df..f7ca338a 100644
--- a/src-tauri/src/commands/download.rs
+++ b/src-tauri/src/commands/download.rs
@@ -10,6 +10,7 @@ use sha2::{Digest, Sha256};
use tauri::State;
use tokio_util::sync::CancellationToken;
+use crate::commands::comfy_folders;
use crate::state::{AppState, DownloadProgress};
/// Reduce a download filename to a safe basename — no path separators, no
@@ -101,6 +102,112 @@ mod delete_message_tests {
}
}
+/// The write target, held against the engine that has to find the file.
+///
+/// .__nothing_, Discord help-chat 2026-09-02: FramePack F1 and Wan 2.1 both
+/// downloaded through the Get button and appeared in no picker, and moving the
+/// files into a different ComfyUI folder by hand fixed it. That sentence is
+/// this test: the download went where LU guessed, the picker reads what the
+/// running ComfyUI enumerates, and on his box those were two different trees.
+#[cfg(test)]
+mod model_folder_tests {
+ use super::models_dir_in;
+ use crate::commands::comfy_folders::ComfyFolders;
+ use serde_json::json;
+ use std::path::PathBuf;
+
+ fn scratch(name: &str) -> PathBuf {
+ let dir = std::env::temp_dir()
+ .join("lu-model-folders")
+ .join(format!("{name}-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(&dir).unwrap();
+ dir
+ }
+
+ /// The shape of the report: `main.py` in the program folder, the models
+ /// under the base directory the desktop app starts ComfyUI with.
+ #[test]
+ fn the_download_follows_the_engine_and_not_our_guess() {
+ let root = scratch("base-directory");
+ let program = root.join("Programs").join("ComfyUI").join("resources").join("ComfyUI");
+ let base = root.join("Documents").join("ComfyUI");
+ let engine_dir = base.join("models").join("diffusion_models");
+ let folders = ComfyFolders::parse(&json!({
+ "diffusion_models": [
+ base.join("models").join("unet").to_string_lossy(),
+ engine_dir.to_string_lossy(),
+ ],
+ }));
+
+ let dest = models_dir_in(
+ Some(&folders),
+ &Some(program.to_string_lossy().to_string()),
+ "diffusion_models",
+ )
+ .unwrap();
+
+ // Where FramePackI2V_HY_fp8_e4m3fn.safetensors and
+ // wan2.1_t2v_1.3B_bf16.safetensors have to land to be offered.
+ assert_eq!(dest, engine_dir);
+ assert!(dest.is_dir());
+ // And NOT where the old rule put them, which is the folder he had to
+ // move them out of.
+ assert_ne!(dest, program.join("models").join("diffusion_models"));
+
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ /// No engine to ask (the Model Manager downloads with ComfyUI shut down all
+ /// the time) keeps the rule that has always been there.
+ #[test]
+ fn without_an_answer_the_old_rule_stands() {
+ let root = scratch("no-engine");
+ let dest = models_dir_in(None, &Some(root.to_string_lossy().to_string()), "checkpoints").unwrap();
+ assert_eq!(dest, root.join("models").join("checkpoints"));
+
+ // An engine that answers about other folders says nothing about this
+ // one, and inventing a folder from a key it does not have would be the
+ // same guess in a new place.
+ let folders = ComfyFolders::parse(&json!({"vae": ["/srv/ai/vae"]}));
+ let dest = models_dir_in(Some(&folders), &Some(root.to_string_lossy().to_string()), "checkpoints").unwrap();
+ assert_eq!(dest, root.join("models").join("checkpoints"));
+
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ /// A pack folder is not a ComfyUI folder key. It stays relative to the
+ /// ComfyUI root, where the pack itself is.
+ #[test]
+ fn a_pack_folder_stays_under_the_comfyui_root() {
+ let root = scratch("pack-folder");
+ let folders = ComfyFolders::parse(&json!({
+ "diffusion_models": ["/srv/ai/models/diffusion_models"]
+ }));
+ let dest = models_dir_in(
+ Some(&folders),
+ &Some(root.to_string_lossy().to_string()),
+ "custom_nodes/ComfyUI-AnimateDiff-Evolved/models",
+ )
+ .unwrap();
+ assert_eq!(dest, root.join("custom_nodes/ComfyUI-AnimateDiff-Evolved/models"));
+
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ /// The jail is unchanged, and it runs BEFORE anything the engine said.
+ #[test]
+ fn an_escaping_subfolder_is_still_refused() {
+ let folders = ComfyFolders::parse(&json!({"checkpoints": ["/srv/ai/models/checkpoints"]}));
+ for bad in ["../../etc", "a/../../b", "/abs/path", "C:/x"] {
+ assert!(
+ models_dir_in(Some(&folders), &Some("/tmp/comfy".to_string()), bad).is_err(),
+ "{bad}",
+ );
+ }
+ }
+}
+
#[cfg(test)]
mod civitai_auth_tests {
use super::{download_http_error, http_error_message, is_civitai_host};
@@ -422,14 +529,26 @@ pub fn delete_comfy_model(
}
let base = sanitize_filename(&base);
let models_root = PathBuf::from(&comfy_path).join("models");
+ // Both trees, because the download may have written into either: the
+ // engine's own folders when it was running and could be asked, the classic
+ // guess when it could not (see models_dir_in). A file the app put there is
+ // a file the app has to be able to take away again.
+ let mut roots: Vec<PathBuf> = MODEL_SUBDIRS.iter().map(|d| models_root.join(d)).collect();
+ if let Some(folders) = comfy_folders::cached() {
+ for dir in folders.all_dirs() {
+ if !roots.contains(&dir) {
+ roots.push(dir);
+ }
+ }
+ }
let mut hits: Vec<PathBuf> = Vec::new();
- for d in MODEL_SUBDIRS {
+ for root in &roots {
let cand = if sub.is_empty() {
- models_root.join(d).join(&base)
+ root.join(&base)
} else {
- models_root.join(d).join(&sub).join(&base)
+ root.join(&sub).join(&base)
};
- if cand.is_file() {
+ if cand.is_file() && !hits.contains(&cand) {
hits.push(cand);
}
}
@@ -456,9 +575,33 @@ pub fn delete_comfy_model(
}
}
-fn models_dir(comfy_path: &Option<String>, subfolder: &str) -> Result<PathBuf, String> {
- let base = comfy_path.as_ref().ok_or("ComfyUI path not set. Please set it in settings or install ComfyUI first.")?;
+/// Where a file of `subfolder` goes, and where every other path in this module
+/// looks for it afterwards. THE definition, which is the whole point: the
+/// download, the size probe, the space check and the delete all come through
+/// here, so they cannot end up in different trees.
+///
+/// `folders` is what the RUNNING ComfyUI says about its own model folders
+/// (see commands/comfy_folders.rs). It wins whenever it has an answer, because
+/// the picker is built from that same process: a file written anywhere else is
+/// a file no picker can ever offer (.__nothing_, 2026-09-02 — FramePack F1 and
+/// Wan 2.1 downloaded fine and showed up nowhere until he moved them into the
+/// other ComfyUI folder by hand).
+///
+/// The old rule stays underneath for the two cases where there is nothing
+/// better: ComfyUI is not running (the Model Manager downloads with the engine
+/// shut down all the time), and the pack folders under `custom_nodes`, which
+/// are not a ComfyUI `folder_paths` key at all.
+fn models_dir_in(
+ folders: Option<&comfy_folders::ComfyFolders>,
+ comfy_path: &Option<String>,
+ subfolder: &str,
+) -> Result<PathBuf, String> {
safe_subfolder(subfolder)?;
+ if let Some(dir) = folders.and_then(|f| f.dir_for(subfolder)) {
+ fs::create_dir_all(&dir).map_err(|e| format!("Create models dir: {}", os_error::english(&e)))?;
+ return Ok(dir);
+ }
+ let base = comfy_path.as_ref().ok_or("ComfyUI path not set. Please set it in settings or install ComfyUI first.")?;
// Subfolders starting with "custom_nodes/" are relative to ComfyUI root, not models/
let dir = if subfolder.starts_with("custom_nodes/") || subfolder.starts_with("custom_nodes\\") {
PathBuf::from(base).join(subfolder)
@@ -469,6 +612,19 @@ fn models_dir(comfy_path: &Option<String>, subfolder: &str) -> Result<PathBuf, S
Ok(dir)
}
+/// The engine's answer, asked fresh, for the paths that can await it.
+async fn engine_folders(state: &State<'_, AppState>) -> Option<comfy_folders::ComfyFolders> {
+ let host = state.comfy_host.lock().map(|h| h.clone()).unwrap_or_default();
+ let port = state.comfy_port.lock().map(|p| *p).unwrap_or(0);
+ if port == 0 {
+ return comfy_folders::cached();
+ }
+ match comfy_folders::folders_of(&host, port).await {
+ Some(f) => Some(f),
+ None => comfy_folders::cached(),
+ }
+}
+
#[allow(non_snake_case)]
#[tauri::command]
pub async fn download_model(
@@ -496,7 +652,7 @@ pub async fn download_model(
p.clone()
};
- let dest_dir = models_dir(&comfy_path, &subfolder)?;
+ let dest_dir = models_dir_in(engine_folders(&state).await.as_ref(), &comfy_path, &subfolder)?;
let dest_file = dest_dir.join(sanitize_filename(&filename));
let expected_sha256 = match expectedSha256.as_deref() {
@@ -876,6 +1032,7 @@ pub(crate) fn is_huggingface_host(url: &str) -> bool {
/// A refusal from CivitAI names the field and the way to it. Everything else
/// goes to `http_error_message`: inventing a CivitAI hint for a dead
/// HuggingFace link would send people to the wrong setting.
+
///
/// The CivitAI text carries its status WITHOUT the `(HTTP nnn)` brackets on
/// purpose. That shape is the contract `isPermanentDownloadError` reads in
@@ -1448,7 +1605,7 @@ pub fn check_download_space(
(_, Some(d)) if !d.is_empty() => PathBuf::from(d),
(Some(sub), _) => {
let comfy_path = state.comfy_path.lock().unwrap().clone();
- models_dir(&comfy_path, &sub)?
+ models_dir_in(comfy_folders::cached().as_ref(), &comfy_path, &sub)?
}
_ => return Err("check_download_space needs a subfolder or a destDir".to_string()),
};
@@ -1675,7 +1832,7 @@ pub async fn resume_download(
p.clone()
};
- let dest_dir = models_dir(&comfy_path, &subfolder)?;
+ let dest_dir = models_dir_in(engine_folders(&state).await.as_ref(), &comfy_path, &subfolder)?;
let dest_file = dest_dir.join(&id);
let tmp_path = dest_file.with_extension("download");
@@ -2105,11 +2262,14 @@ pub async fn check_model_sizes(
}
p.clone()
};
+ // The same folders the download wrote into. Asking the old way here would
+ // measure a tree nothing was written to and report every file as missing.
+ let folders = engine_folders(&state).await;
let mut results = Vec::with_capacity(files.len());
for file in &files {
- let dest_dir = match models_dir(&comfy_path, &file.subfolder) {
+ let dest_dir = match models_dir_in(folders.as_ref(), &comfy_path, &file.subfolder) {
Ok(d) => d,
Err(_) => {
results.push(CheckFileResult {
diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs
index 62cacb3e..e01f8284 100644
--- a/src-tauri/src/commands/mod.rs
+++ b/src-tauri/src/commands/mod.rs
@@ -1,6 +1,7 @@
pub mod agent;
pub mod bg_tasks;
pub mod repo_map;
+pub mod comfy_folders;
pub mod comfy_ws;
pub mod custom_models;
pub mod download;
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index 964300d9..8bce59ac 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -2433,6 +2433,8 @@ pub fn set_comfyui_path(path: String, state: State<'_, AppState>) -> Result<serd
let mut p = state.comfy_path.lock().unwrap();
*p = Some(path.clone());
}
+ // A different install answers differently about its model folders.
+ crate::commands::comfy_folders::forget();
// Persist to config file
{
@@ -2498,6 +2500,8 @@ pub fn set_comfyui_host(host: String, state: State<'_, AppState>) -> Result<serd
let mut p = state.comfy_port.lock().unwrap();
*p = port;
}
+ // Another engine, another set of model folders.
+ crate::commands::comfy_folders::forget();
// Persist to config file
{
@@ -2536,6 +2540,7 @@ pub fn set_comfyui_port(port: u16, state: State<'_, AppState>) -> Result<serde_j
let mut p = state.comfy_port.lock().unwrap();
*p = port;
}
+ crate::commands::comfy_folders::forget();
// Persist to config file
{
diff --git a/src/api/__tests__/bundle-install-visible-wait.test.ts b/src/api/__tests__/bundle-install-visible-wait.test.ts
index 3aa9f654..57fdcd7e 100644
--- a/src/api/__tests__/bundle-install-visible-wait.test.ts
+++ b/src/api/__tests__/bundle-install-visible-wait.test.ts
@@ -38,18 +38,14 @@ vi.mock('../backend', () => ({
fetchExternal: vi.fn(),
}))
-vi.mock('../comfyui', () => ({
- getCheckpoints: () => getCheckpoints(),
- getDiffusionModels: async () => [],
- getVAEModels: async () => [],
- getCLIPModels: async () => [],
- getGgufUnetModels: () => getGgufUnetModels(),
- // Sixth loader (2026-08-29): the AnimateDiff pack lists its motion modules
- // itself. No motion module in these fixtures, so it answers empty.
- getAnimateDiffModels: async () => [],
- // Seventh loader (2026-08-29, abnahme counter-check): LoraLoader enumerates
- // the loras folder, so a LoRA is judged like every other file now.
- getLoraModels: async () => [],
+vi.mock('../comfyui', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../comfyui')>()),
+ // What the engine lists, per folder, through the one table every folder is
+ // read back with (COMFY_MODEL_FOLDERS).
+ readComfyFolderLists: async () => ({
+ checkpoints: await getCheckpoints(),
+ diffusion_models: await getGgufUnetModels(),
+ }),
filterPartialFiles: async (names: string[]) => new Set(names),
refreshComfyModels: (...a: unknown[]) => refreshComfyModels(...(a as [number])),
}))
@@ -161,8 +157,10 @@ describe('a file complete on disk waits out the ComfyUI scan before it is called
rec.stop()
expect(rec.seen).toEqual([{ type: 'comfyui-download-exists', filename: VIDEO }])
- // One lookup, no rescan round. This is the common case and it must stay free.
- expect(getCheckpoints).toHaveBeenCalledTimes(1)
+ // No rescan round. This is the common case and it must stay free: the
+ // engine is asked which folders it enumerates and whether it lists this
+ // file, and that is the end of it.
+ expect(getCheckpoints.mock.calls.length).toBeLessThanOrEqual(2)
expect(refreshComfyModels.mock.calls.filter((c) => c[0] === 1)).toHaveLength(0)
})
@@ -302,18 +300,23 @@ describe('a file complete on disk waits out the ComfyUI scan before it is called
expect(getCheckpoints).toHaveBeenCalledTimes(2)
})
- it('a subfolder ComfyUI never enumerates is not judged at all', async () => {
- // Upscale models do not appear in these lists, so waiting on one would be
- // certain failure on a click. (loras left this group on 2026-08-29: the
- // LoRA folder IS enumerated, by LoraLoader, and the abnahme counter-check
- // showed what not asking it costs.)
+ it('a folder THIS engine does not enumerate is not judged at all', async () => {
+ // The question moved with the table (COMFY_MODEL_FOLDERS): it is no longer
+ // "is this folder in a list of folders ComfyUI could enumerate" but "did
+ // the engine in front of us answer about it". The fixture's engine answers
+ // about checkpoints and diffusion_models and nothing else, so an upscale
+ // model gets no verdict here — waiting on one would be certain failure on
+ // a click. (loras left this group on 2026-08-29: the LoRA folder IS
+ // enumerated, by LoraLoader, and the abnahme counter-check showed what not
+ // asking it costs.)
const rec = recordVerdicts()
await installBundleComplete(bundleOf([{ filename: '4x-UltraSharp.pth', subfolder: 'upscale_models' }]))
rec.stop()
expect(rec.seen).toEqual([{ type: 'comfyui-download-exists', filename: '4x-UltraSharp.pth' }])
- expect(getCheckpoints).not.toHaveBeenCalled()
+ // No rescan round and no accusation: an unanswered folder is not a verdict.
+ expect(refreshComfyModels.mock.calls.filter((c) => c[0] === 1)).toHaveLength(0)
})
it('a LoRA IS judged now, so a finished LoRA download gets the same wait as any other file', async () => {
diff --git a/src/api/__tests__/bundles-installed-every-file.test.ts b/src/api/__tests__/bundles-installed-every-file.test.ts
index f647857f..391d195a 100644
--- a/src/api/__tests__/bundles-installed-every-file.test.ts
+++ b/src/api/__tests__/bundles-installed-every-file.test.ts
@@ -40,19 +40,17 @@ vi.mock('../backend', () => ({
fetchExternal: vi.fn(),
}))
-vi.mock('../comfyui', () => ({
- getCheckpoints: async () => [],
- getDiffusionModels: () => diffusionModels(),
- getGgufUnetModels: () => ggufUnets(),
- // Sixth loader (2026-08-29): the AnimateDiff pack lists its motion modules
- // itself. No motion module in these fixtures, so it answers empty.
- getAnimateDiffModels: async () => [],
- getVAEModels: () => vaes(),
- getCLIPModels: () => clips(),
- // Seventh loader (2026-08-29, abnahme counter-check): LoraLoader has always
- // enumerated the loras folder and nothing here ever asked it, so a LoRA was
- // the one installed file no surface could reason about.
- getLoraModels: () => loras(),
+vi.mock('../comfyui', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../comfyui')>()),
+ // What the engine lists, per folder, through the one table every folder is
+ // read back with (COMFY_MODEL_FOLDERS). diffusion_models carries both its
+ // loaders: UNETLoader lists .safetensors and .sft, the GGUF pack the quants.
+ readComfyFolderLists: async () => ({
+ diffusion_models: [...(await diffusionModels()), ...(await ggufUnets())],
+ vae: await vaes(),
+ text_encoders: await clips(),
+ loras: await loras(),
+ }),
filterPartialFiles: async (names: string[]) => new Set(names),
refreshComfyModels: vi.fn(async () => true),
}))
diff --git a/src/api/__tests__/bundles-installed-gguf.test.ts b/src/api/__tests__/bundles-installed-gguf.test.ts
index b70bb9bd..9a877c63 100644
--- a/src/api/__tests__/bundles-installed-gguf.test.ts
+++ b/src/api/__tests__/bundles-installed-gguf.test.ts
@@ -23,19 +23,14 @@ vi.mock('../backend', () => ({
fetchExternal: vi.fn(),
}))
-vi.mock('../comfyui', () => ({
- // The engine lists nothing through the four loaders this check used to ask.
- getCheckpoints: async () => [],
- getDiffusionModels: async () => [],
- getVAEModels: async () => [],
- getCLIPModels: async () => [],
- getGgufUnetModels: () => ggufUnets(),
- // Sixth loader (2026-08-29): the AnimateDiff pack lists its motion modules
- // itself. No motion module in these fixtures, so it answers empty.
- getAnimateDiffModels: async () => [],
- // Seventh loader (2026-08-29, abnahme counter-check): LoraLoader enumerates
- // the loras folder. Nothing in these fixtures is a LoRA, so it answers empty.
- getLoraModels: async () => [],
+vi.mock('../comfyui', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../comfyui')>()),
+ // Every folder the catalog writes into is read back through ONE table now
+ // (COMFY_MODEL_FOLDERS), so a fixture says what the engine lists per folder
+ // rather than faking a loader at a time. Here the engine has nothing but the
+ // quant ComfyUI-GGUF lists: UNETLoader cannot see a .gguf at all, which is
+ // the whole of GH #113's second half.
+ readComfyFolderLists: async () => ({ diffusion_models: await ggufUnets() }),
filterPartialFiles: async (names: string[]) => new Set(names),
}))
diff --git a/src/api/__tests__/get-target-is-a-folder-we-read.test.ts b/src/api/__tests__/get-target-is-a-folder-we-read.test.ts
new file mode 100644
index 00000000..5f733753
--- /dev/null
+++ b/src/api/__tests__/get-target-is-a-folder-we-read.test.ts
@@ -0,0 +1,229 @@
+/**
+ * .__nothing_, Discord help-chat 2026-09-02 (Windows 11 25H2, RTX 5060, LU
+ * 2.6.7, ComfyUI backend): FramePack F1 and Wan 2.1 install through our own Get
+ * button and never appear in the picker. Moving the files into a different
+ * ComfyUI folder by hand fixed it.
+ *
+ * Two questions, and this file answers the second one. Where a file is WRITTEN
+ * is settled in Rust, where the download now asks the running ComfyUI for its
+ * own model folders instead of guessing (src-tauri/src/commands/comfy_folders.rs
+ * and `models_dir_in` in download.rs). What is left over here is the other side
+ * of the same coin: every folder the Get button writes into has to be a folder
+ * the app reads back, or a download lands somewhere nothing looks even when the
+ * tree is right.
+ *
+ * The catalog's write folders and the app's read folders were two hand-written
+ * lists in two files, and they had drifted by two entries:
+ *
+ * clip_vision FramePack F1's 900 MB SigCLIP encoder
+ * audio_encoders the Wav2Vec2 encoder both Talking Character bundles need
+ *
+ * Both are written by our own Get button, and neither was read by anything, so
+ * a file in either could never be confirmed after its download.
+ *
+ * The tree below is a real one in a temp dir, filled with exactly the files the
+ * Get button writes, and the ComfyUI in front of it enumerates that tree the
+ * way the real one does: `supported_pt_extensions` for the stock loaders, the
+ * GGUF pack's own loader for `.gguf`, and `diffusion_models` covering both
+ * `models\unet` and `models\diffusion_models`.
+ *
+ * Run: npx vitest run src/api/__tests__/get-target-is-a-folder-we-read.test.ts
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+import { mkdtempSync, mkdirSync, readdirSync, statSync, openSync, ftruncateSync, closeSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join, dirname } from 'node:path'
+
+const localFetch = vi.fn()
+const backendCall = vi.fn()
+vi.mock('../backend', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../backend')>()),
+ localFetch: (...a: unknown[]) => localFetch(...a),
+ backendCall: (...a: unknown[]) => backendCall(...a),
+ isTauri: () => false,
+ isMacOS: () => false,
+ comfyuiUrl: (path: string) => `http://127.0.0.1:8188${path}`,
+}))
+
+import {
+ COMFY_MODEL_FOLDERS, getVideoModels, getImageModels, getAudioModels,
+ getLipsyncModels, getMotionModels, type ClassifiedModel,
+} from '../comfyui'
+import {
+ getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles,
+ modelsNotVisibleInComfy, type ModelBundle, type DiscoverModel,
+} from '../discover'
+
+/** ComfyUI's `supported_pt_extensions` (folder_paths.py). No `.gguf` — that is
+ * the whole reason the GGUF pack registers a loader of its own. */
+const PT = new Set(['.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft'])
+const extOf = (n: string) => n.slice(n.lastIndexOf('.')).toLowerCase()
+
+/** ComfyUI's folder keys and the directories each one scans, as `folder_paths`
+ * has them. `diffusion_models` really does cover both, which is why a file in
+ * either is offered by UNETLoader. */
+const SCANS: Record<string, string[]> = {
+ checkpoints: ['models/checkpoints'],
+ diffusion_models: ['models/unet', 'models/diffusion_models'],
+ vae: ['models/vae'],
+ text_encoders: ['models/text_encoders', 'models/clip'],
+ clip_vision: ['models/clip_vision'],
+ audio_encoders: ['models/audio_encoders'],
+ loras: ['models/loras'],
+ controlnet: ['models/controlnet'],
+ upscale_models: ['models/upscale_models'],
+ style_models: ['models/style_models'],
+}
+
+function filesIn(root: string, rel: string): string[] {
+ try {
+ return readdirSync(join(root, rel)).filter((f) => statSync(join(root, rel, f)).isFile())
+ } catch { return [] }
+}
+
+const listFor = (root: string, key: string, gguf: boolean) =>
+ (SCANS[key] ?? []).flatMap((d) => filesIn(root, d))
+ .filter((f) => (gguf ? extOf(f) === '.gguf' : PT.has(extOf(f))))
+
+const okJson = (body: unknown) => ({ ok: true, status: 200, json: async () => body })
+const notFound = { ok: false, status: 404, json: async () => ({}) }
+const combo = (node: string, field: string, list: string[]) =>
+ okJson({ [node]: { input: { required: { [field]: [list] } } } })
+
+/** A ComfyUI serving the tree under `root`. */
+function serve(root: string) {
+ localFetch.mockImplementation(async (url: string) => {
+ if (url.includes('CheckpointLoaderSimple')) return combo('CheckpointLoaderSimple', 'ckpt_name', listFor(root, 'checkpoints', false))
+ if (url.includes('UnetLoaderGGUF')) return combo('UnetLoaderGGUF', 'unet_name', listFor(root, 'diffusion_models', true))
+ if (url.includes('UNETLoader')) return combo('UNETLoader', 'unet_name', listFor(root, 'diffusion_models', false))
+ if (url.includes('VAELoader')) return combo('VAELoader', 'vae_name', listFor(root, 'vae', false))
+ if (url.includes('CLIPVisionLoader')) return combo('CLIPVisionLoader', 'clip_name', listFor(root, 'clip_vision', false))
+ if (url.includes('CLIPLoader')) return combo('CLIPLoader', 'clip_name', listFor(root, 'text_encoders', false))
+ if (url.includes('AudioEncoderLoader')) return combo('AudioEncoderLoader', 'audio_encoder_name', listFor(root, 'audio_encoders', false))
+ if (url.includes('LoraLoader')) return combo('LoraLoader', 'lora_name', listFor(root, 'loras', false))
+ if (url.includes('ControlNetLoader')) return combo('ControlNetLoader', 'control_net_name', listFor(root, 'controlnet', false))
+ if (url.includes('UpscaleModelLoader')) return combo('UpscaleModelLoader', 'model_name', listFor(root, 'upscale_models', false))
+ if (url.includes('StyleModelLoader')) return combo('StyleModelLoader', 'style_model_name', listFor(root, 'style_models', false))
+ if (url.includes('ADE_LoadAnimateDiffModel')) {
+ return combo('ADE_LoadAnimateDiffModel', 'model_name', filesIn(root, 'custom_nodes/ComfyUI-AnimateDiff-Evolved/models'))
+ }
+ return notFound
+ })
+ // The disk probe answers about the same tree, so nothing is hidden as a
+ // partial download: every planted file has its announced size.
+ backendCall.mockImplementation(async (
+ _cmd: string,
+ args: { files?: Array<{ subfolder: string; filename: string; expectedBytes: number }> },
+ ) => (args?.files ?? []).map((f) => {
+ const p = join(root, f.subfolder.startsWith('custom_nodes') ? '' : 'models', f.subfolder, f.filename)
+ try {
+ const bytes = statSync(p).size
+ return { filename: f.filename, exists: true, actualBytes: bytes, complete: bytes >= f.expectedBytes * 0.5 }
+ } catch {
+ return { filename: f.filename, exists: false, actualBytes: 0, complete: false }
+ }
+ }))
+}
+
+/** Exactly what the Get button writes: same folder, same name, full size. */
+function runTheGet(files: DiscoverModel[]): string {
+ const root = mkdtempSync(join(tmpdir(), 'lu-comfy-tree-'))
+ for (const f of files) {
+ if (!f.filename || !f.subfolder) continue
+ const rel = f.subfolder.startsWith('custom_nodes') ? f.subfolder : join('models', f.subfolder)
+ const p = join(root, rel, f.filename)
+ mkdirSync(dirname(p), { recursive: true })
+ // Sparse, so a 27 GB bundle costs no bytes and no time.
+ const fd = openSync(p, 'w')
+ ftruncateSync(fd, Math.round((f.sizeGB ?? 0.001) * 1_073_741_824))
+ closeSync(fd)
+ }
+ return root
+}
+
+/** The file that makes a bundle what it is: the one that generates. */
+const MAIN_FOLDERS = new Set(['diffusion_models', 'checkpoints', 'unet'])
+const mainFiles = (b: ModelBundle) => b.files.filter((f) => MAIN_FOLDERS.has(f.subfolder ?? ''))
+
+const LANES: Array<{ lane: string; bundles: () => ModelBundle[]; picker: () => Promise<ClassifiedModel[]> }> = [
+ { lane: 'image', bundles: getImageBundles, picker: getImageModels },
+ { lane: 'video', bundles: getVideoBundles, picker: getVideoModels },
+ { lane: 'audio', bundles: getAudioBundles, picker: getAudioModels },
+ { lane: 'lipsync', bundles: getLipsyncBundles, picker: getLipsyncModels },
+ { lane: 'motion', bundles: getMotionBundles, picker: getMotionModels },
+]
+
+const allBundles = () => LANES.flatMap((l) => l.bundles())
+
+beforeEach(() => { localFetch.mockReset(); backendCall.mockReset() })
+
+describe('every folder the Get button writes into is one the app reads back', () => {
+ it('THE FIX: no bundle in the catalog writes into a folder no reader knows', () => {
+ const read = new Set(COMFY_MODEL_FOLDERS.map((f) => f.subfolder))
+ const unread = new Map<string, string[]>()
+ for (const b of allBundles()) {
+ for (const f of b.files) {
+ if (!f.subfolder || read.has(f.subfolder)) continue
+ unread.set(f.subfolder, [...(unread.get(f.subfolder) ?? []), `${b.name} · ${f.filename}`])
+ }
+ }
+ // Named rather than counted: the message has to say which folder, or the
+ // next person has to go and find it again.
+ expect(Object.fromEntries(unread)).toEqual({})
+ })
+
+ // Negative control: a table that claims a folder ComfyUI does not have would
+ // be the same drift facing the other way — a reader asking a loader that
+ // answers nothing, forever.
+ it('and reads no folder ComfyUI does not have', () => {
+ const known = new Set([...Object.keys(SCANS), 'custom_nodes/ComfyUI-AnimateDiff-Evolved/models'])
+ for (const f of COMFY_MODEL_FOLDERS) {
+ expect(known, f.subfolder).toContain(f.subfolder)
+ }
+ })
+})
+
+describe('what the Get wrote, the picker offers', () => {
+ // The two from the report, by name, because they are the two he could not
+ // see. Both land in diffusion_models and both are offered from there.
+ it('FramePack F1 and Wan 2.1 are in the video picker after their own Get', async () => {
+ for (const name of ['FramePack F1 (Image to Video)', 'Wan 2.1 · 1.3B (Lightweight)']) {
+ const bundle = getVideoBundles().find((b) => b.name === name)!
+ expect(bundle, name).toBeTruthy()
+ serve(runTheGet(bundle.files))
+ const offered = (await getVideoModels()).map((m) => m.name)
+ for (const f of mainFiles(bundle)) expect(offered, `${name} · ${f.filename}`).toContain(f.filename)
+ }
+ })
+
+ // ...and the same question for every other Get target in the catalog, which
+ // is the only way to know the two above were not the only two.
+ it('and so is the main model of every other bundle', async () => {
+ for (const { lane, bundles, picker } of LANES) {
+ for (const b of bundles()) {
+ // The AnimateDiff lane is the one pair that has no main model of its
+ // own: an SD checkpoint (an image model) plus a motion module under
+ // custom_nodes. Its own picker is getAnimateDiffMotionModels.
+ if (b.workflow === 'animatediff') continue
+ serve(runTheGet(b.files))
+ const offered = (await picker()).map((m) => m.name)
+ for (const f of mainFiles(b)) expect(offered, `${lane} · ${b.name} · ${f.filename}`).toContain(f.filename)
+ }
+ }
+ }, 30_000)
+
+ /**
+ * The support files, which is where the drift actually sat. A file the
+ * running ComfyUI lists must never come back from the visibility probe as
+ * missing: that answer stops a bundle counting as installed and, on the
+ * Create card, ends in "ComfyUI still does not list …" over a file it is
+ * listing.
+ */
+ it('and every support file is confirmed, SigCLIP and Wav2Vec2 included', async () => {
+ for (const b of allBundles()) {
+ serve(runTheGet(b.files))
+ const wanted = b.files.filter((f) => f.filename && f.subfolder).map((f) => f.filename!)
+ expect(await modelsNotVisibleInComfy(wanted), b.name).toEqual([])
+ }
+ }, 30_000)
+})
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 9fc9f34d..ff2a8a53 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -177,15 +177,15 @@ export type AddonSource =
/** Where a listed file actually sits, by the enum that listed it. The disk
* probe needs the folder, and the delete command resolves the same set.
*
- * The motion-module folder is spelled out rather than imported: discover.ts
- * owns ANIMATEDIFF_SUBFOLDER and imports back into this module, so a static
- * import here would be a cycle. A unit test pins the two spellings together
- * so the duplicate cannot drift. */
+ * The motion-module folder comes from ANIMATEDIFF_SUBFOLDER below rather than
+ * being spelled out a second time: it used to live in discover.ts, which
+ * imports back into this module, and the duplicate was held together by a unit
+ * test instead of by there being only one of it. */
export function subfolderForSource(source: ClassifiedModel['source']): string {
switch (source) {
case 'checkpoint': return 'checkpoints'
case 'diffusion_model': return 'diffusion_models'
- case 'motion_module': return 'custom_nodes/ComfyUI-AnimateDiff-Evolved/models'
+ case 'motion_module': return ANIMATEDIFF_SUBFOLDER
case 'lora': return 'loras'
case 'vae': return 'vae'
case 'text_encoder': return 'text_encoders'
@@ -707,37 +707,53 @@ export async function getDiffusionModels(): Promise<string[]> {
return fetchNodeOptions('UNETLoader', 'unet_name', { strict: true })
}
-export async function getVAEModels(): Promise<string[]> {
+/**
+ * One optional loader, with "the node is not registered here" told apart from
+ * "the node is registered and lists nothing".
+ *
+ * The difference decides whether a file may be called invisible. A loader that
+ * is simply absent (a ComfyUI older than the node, a distro that ships without
+ * it) has said nothing about the folder, and treating its silence as "ComfyUI
+ * cannot see your file" would send a perfectly installed bundle back to the
+ * download button. `null` is that silence; the folder is then left out of the
+ * lists below and nothing judges a file in it.
+ */
+async function nodeOptionsOrNull(node: string, field: string): Promise<string[] | null> {
try {
- return await fetchNodeOptions('VAELoader', 'vae_name')
+ const res = await localFetch(comfyuiUrl(`/object_info/${node}`), { timeoutMs: COMFY_LIST_TIMEOUT_MS })
+ if (!res.ok) return null
+ const data = await res.json()
+ // ComfyUI answers 200 with `{}` for a class it does not know.
+ if (!data || typeof data !== 'object' || !(node in (data as Record<string, unknown>))) return null
+ return nodeComboOptions(data, node, field)
} catch (err) {
- log.warn('comfyui.fetch_vae_failed', { err })
- return []
+ log.warn('comfyui.fetch_folder_failed', { node, err })
+ return null
}
}
+/** The loader for one folder of COMFY_MODEL_FOLDERS, by subfolder. The node and
+ * field of a folder are spelled ONCE, in that table. */
+async function folderOptions(subfolder: string): Promise<string[] | null> {
+ const entry = COMFY_MODEL_FOLDERS.find((f) => f.subfolder === subfolder)
+ return entry ? entry.read() : null
+}
+
+export async function getVAEModels(): Promise<string[]> {
+ return (await folderOptions('vae')) ?? []
+}
+
export async function getCLIPModels(): Promise<string[]> {
- try {
- return await fetchNodeOptions('CLIPLoader', 'clip_name')
- } catch (err) {
- log.warn('comfyui.fetch_clip_failed', { err })
- return []
- }
+ return (await folderOptions('text_encoders')) ?? []
}
/**
- * F2 (cinemazverev GH#4): list LoRA files ComfyUI knows about. Pulls
- * the same enum LoraLoader's `lora_name` dropdown shows — anything the
- * user dropped into `<comfyui>/models/loras/`. Soft-fails to `[]` when
- * the LoraLoader node isn't registered (custom-node ComfyUI distros).
+ * F2 (cinemazverev GH#4): list LoRA files ComfyUI knows about. Pulls the same
+ * enum LoraLoader's `lora_name` dropdown shows — anything the user dropped into
+ * `<comfyui>/models/loras/`.
*/
export async function getLoraModels(): Promise<string[]> {
- try {
- return await fetchNodeOptions('LoraLoader', 'lora_name')
- } catch (err) {
- log.warn('comfyui.fetch_lora_failed', { err })
- return []
- }
+ return (await folderOptions('loras')) ?? []
}
/** The five folders the R5 re-measure (2026-08-30) found missing entirely.
@@ -746,43 +762,29 @@ export async function getLoraModels(): Promise<string[]> {
* listed all ten at once; the app showed five of them and never mentioned the
* other five. Two real files were invisible with them, an 817 MB CLIP-Vision
* encoder and, once the partial filter below was fixed, a 2.4 GB text
- * encoder. Each of these is a stock ComfyUI loader over a stock folder, and
- * each soft-fails to an empty list, so a distro that lacks one of the nodes
- * costs that folder and nothing around it. */
+ * encoder. */
export async function getCLIPVisionModels(): Promise<string[]> {
- try {
- return await fetchNodeOptions('CLIPVisionLoader', 'clip_name')
- } catch (err) {
- log.warn('comfyui.fetch_clip_vision_failed', { err })
- return []
- }
+ return (await folderOptions('clip_vision')) ?? []
+}
+
+/** The audio encoders the Talking Character lane needs (Wav2Vec2). Our catalog
+ * has written into `models\audio_encoders` since the 2.5.8 lanes and nothing
+ * read it back, so the file could be neither confirmed after its download nor
+ * listed among the things taking up the disk. */
+export async function getAudioEncoderModels(): Promise<string[]> {
+ return (await folderOptions('audio_encoders')) ?? []
}
export async function getControlNetModels(): Promise<string[]> {
- try {
- return await fetchNodeOptions('ControlNetLoader', 'control_net_name')
- } catch (err) {
- log.warn('comfyui.fetch_controlnet_failed', { err })
- return []
- }
+ return (await folderOptions('controlnet')) ?? []
}
export async function getUpscaleModels(): Promise<string[]> {
- try {
- return await fetchNodeOptions('UpscaleModelLoader', 'model_name')
- } catch (err) {
- log.warn('comfyui.fetch_upscale_failed', { err })
- return []
- }
+ return (await folderOptions('upscale_models')) ?? []
}
export async function getStyleModels(): Promise<string[]> {
- try {
- return await fetchNodeOptions('StyleModelLoader', 'style_model_name')
- } catch (err) {
- log.warn('comfyui.fetch_style_models_failed', { err })
- return []
- }
+ return (await folderOptions('style_models')) ?? []
}
/** Embeddings are the one folder no loader node enumerates: ComfyUI serves
@@ -832,12 +834,7 @@ export async function getSchedulers(): Promise<string[]> {
* This is also the node that answers in the newer COMBO schema on a real box,
* so it is the one that used to hand a bare "COMBO" string to callers. */
export async function getAnimateDiffModels(): Promise<string[]> {
- try {
- return await fetchNodeOptions('ADE_LoadAnimateDiffModel', 'model_name')
- } catch (err) {
- log.warn('comfyui.fetch_animatediff_failed', { err })
- return []
- }
+ return (await folderOptions('custom_nodes/ComfyUI-AnimateDiff-Evolved/models')) ?? []
}
// ─── Partial Download Filter ───
@@ -1194,6 +1191,89 @@ const INSTALLED_ADDON_LANES: Array<{ source: AddonSource; read: () => Promise<Cl
export const INSTALLED_ADDON_SUBFOLDERS: string[] =
INSTALLED_ADDON_LANES.map((lane) => subfolderForSource(lane.source))
+/** Where the AnimateDiff-Evolved pack keeps its motion modules. Not under
+ * ComfyUI\models at all, which is exactly why the counter and the Installed
+ * list used to miss a fully installed AnimateDiff bundle while its card said
+ * Installed (counter-check on the Windows box, 2026-08-29). */
+export const ANIMATEDIFF_SUBFOLDER = 'custom_nodes/ComfyUI-AnimateDiff-Evolved/models'
+
+/**
+ * THE table: every folder the Get button writes into, and the loader that
+ * lists it back.
+ *
+ * .__nothing_ (Discord help-chat, 2026-09-02): FramePack F1 and Wan 2.1
+ * installed through the Get button and appeared in no picker. The folder half
+ * of that is fixed where a file is written (src-tauri/.../comfy_folders.rs,
+ * which asks the running ComfyUI instead of guessing). This is the other half:
+ * until now the folders the catalog WRITES to and the folders the app READS
+ * back were two hand-written lists in two files, and they had already drifted.
+ *
+ * Two Get targets were in no reader at all:
+ * * `clip_vision` — FramePack F1's 900 MB SigCLIP encoder.
+ * * `audio_encoders` — the Wav2Vec2 encoder both Talking Character bundles
+ * need, added with the 2.5.8 lanes and never read back anywhere.
+ * A file in either could not be confirmed after its download, and the bundle
+ * card's fallback could never call those bundles installed, because it looked
+ * up a folder nothing had filled.
+ *
+ * The guard against the next drift is a test, not a promise:
+ * `src/api/__tests__/get-target-is-a-folder-we-read.test.ts` walks every file
+ * of every bundle in the catalog and fails on a subfolder that is not in here.
+ */
+export const COMFY_MODEL_FOLDERS: Array<{
+ subfolder: string
+ /** The files ComfyUI lists in that folder, or `null` when the loader that
+ * lists it is not registered in this ComfyUI at all — see
+ * `nodeOptionsOrNull` for why the two are not the same answer. */
+ read: () => Promise<string[] | null>
+}> = [
+ // The two main-model loaders are the strict ones: their absence does not mean
+ // an empty folder, it means ComfyUI is not answering, and every caller here
+ // already treats that as "no verdict about anything".
+ { subfolder: 'checkpoints', read: getCheckpoints },
+ // Two loaders, one folder: UNETLoader enumerates .safetensors and .sft,
+ // ComfyUI-GGUF's own loader the .gguf quants beside them. Our own catalog
+ // ships video models both ways, and the pack being absent is normal.
+ {
+ subfolder: 'diffusion_models',
+ read: async () => {
+ const [unets, ggufs] = await Promise.all([
+ getDiffusionModels(),
+ nodeOptionsOrNull('UnetLoaderGGUF', 'unet_name'),
+ ])
+ return [...unets, ...(ggufs ?? [])]
+ },
+ },
+ { subfolder: 'vae', read: () => nodeOptionsOrNull('VAELoader', 'vae_name') },
+ { subfolder: 'text_encoders', read: () => nodeOptionsOrNull('CLIPLoader', 'clip_name') },
+ { subfolder: 'clip_vision', read: () => nodeOptionsOrNull('CLIPVisionLoader', 'clip_name') },
+ { subfolder: 'audio_encoders', read: () => nodeOptionsOrNull('AudioEncoderLoader', 'audio_encoder_name') },
+ { subfolder: 'loras', read: () => nodeOptionsOrNull('LoraLoader', 'lora_name') },
+ { subfolder: 'controlnet', read: () => nodeOptionsOrNull('ControlNetLoader', 'control_net_name') },
+ { subfolder: 'upscale_models', read: () => nodeOptionsOrNull('UpscaleModelLoader', 'model_name') },
+ { subfolder: 'style_models', read: () => nodeOptionsOrNull('StyleModelLoader', 'style_model_name') },
+ { subfolder: ANIMATEDIFF_SUBFOLDER, read: () => nodeOptionsOrNull('ADE_LoadAnimateDiffModel', 'model_name') },
+]
+
+/** Subfolders whose contents ComfyUI enumerates, which is the same thing as
+ * "folders the visibility check can reason about". The table, as a set. */
+export const ENUM_SUBFOLDERS = new Set(COMFY_MODEL_FOLDERS.map((f) => f.subfolder))
+
+/** What each folder of the table holds right now, by subfolder. One round trip
+ * per folder, asked once and used by every caller that needs more than one.
+ *
+ * A folder whose loader is not registered here is LEFT OUT rather than
+ * reported empty. The keys are therefore also the answer to "which folders can
+ * be judged at all", which is what `judgeableFolders` hands to the callers
+ * that decide whether a file may be called invisible. */
+export async function readComfyFolderLists(): Promise<Record<string, string[]>> {
+ const entries = await Promise.all(
+ COMFY_MODEL_FOLDERS.map(async (f) => [f.subfolder, await f.read()] as const),
+ )
+ return Object.fromEntries(entries.filter((e): e is readonly [string, string[]] => e[1] !== null))
+}
+
+
/** Everything installed in the image lane, for the INVENTORY surfaces: the
* Models rail counter and the Installed tab. The image twin of
* getInstalledVideoModels, and the same bug shape one folder further out.
diff --git a/src/api/discover.ts b/src/api/discover.ts
index ef9360a1..14dd9747 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -1,5 +1,5 @@
import { backendCall, fetchExternal } from "./backend"
-import { getCheckpoints, getDiffusionModels, getVAEModels, getCLIPModels, getGgufUnetModels, getAnimateDiffModels, getLoraModels, filterPartialFiles, refreshComfyModels } from "./comfyui"
+import { readComfyFolderLists, filterPartialFiles, refreshComfyModels } from "./comfyui"
import { clearNodeCache } from "./comfyui-nodes"
import { restartComfyForNewNodes } from "./comfy-restart"
import type { ProviderId } from "./providers/types"
@@ -26,6 +26,11 @@ export {
getAudioBundles, getLipsyncBundles, getMotionBundles,
} from './model-bundles'
+// Welche Ordner der Katalog beschreibt und wer sie zurueckliest, steht als EINE
+// Tabelle neben den Lesern (comfyui.ts). Re-Export, damit bestehende
+// Importpfade unveraendert bleiben.
+export { ANIMATEDIFF_SUBFOLDER, ENUM_SUBFOLDERS } from './comfyui'
+
// Die Fortschrittsform lebt in types/downloads.ts, damit lib/bundle-install.ts
// sie lesen kann, ohne dieses Modul zu importieren. Re-Export, damit bestehende
// Importpfade unverändert bleiben.
@@ -316,42 +321,19 @@ export async function checkBundlesInstalled(bundles: ModelBundle[]): Promise<Rec
// file check_model_sizes confirms is partial before matching.
let comfyLists: Record<string, string[]> | null = null
try {
- // getGgufUnetModels for the same reason the Create probe needs it
- // (b8531b6): UNETLoader only enumerates .safetensors and .sft, and GGUF
- // quants are listed by ComfyUI-GGUF's own loader. Both Unfiltered video
- // bundles are GGUF, so without it this cannot see the one file that makes
- // them what they are, and the fuzzy fallback below can never confirm them.
- // getAnimateDiffModels for the same reason getGgufUnetModels is here: the
- // motion modules of both AnimateDiff bundles live under custom_nodes and
- // none of the four ComfyUI\models loaders can see them. Without it the
- // gate below skipped those files and the card trusted the disk alone,
- // which is how two cards read Installed over a rail counter that knew
- // neither of them.
- // getLoraModels for the same reason, found one round later (abnahme
- // counter-check 2026-08-29): the LoRA folder is enumerated by LoraLoader
- // and nothing here asked it, so a LoRA bundle's card was decided on the
- // disk alone while no counter and no list knew the file existed.
- const [rawCheckpoints, rawDiffModels, rawGgufUnets, rawVaes, rawClips, rawMotion, rawLoras] = await Promise.all([
- getCheckpoints(), getDiffusionModels(), getGgufUnetModels(), getVAEModels(), getCLIPModels(),
- getAnimateDiffModels(), getLoraModels(),
- ])
- const [checkpoints, diffModels, ggufUnets, vaes, clips, motion, loras] = await Promise.all([
- filterPartialFiles(rawCheckpoints).then(s => Array.from(s)),
- filterPartialFiles(rawDiffModels).then(s => Array.from(s)),
- filterPartialFiles(rawGgufUnets).then(s => Array.from(s)),
- filterPartialFiles(rawVaes).then(s => Array.from(s)),
- filterPartialFiles(rawClips).then(s => Array.from(s)),
- filterPartialFiles(rawMotion).then(s => Array.from(s)),
- filterPartialFiles(rawLoras).then(s => Array.from(s)),
- ])
- comfyLists = {
- checkpoints,
- diffusion_models: [...diffModels, ...ggufUnets],
- vae: vaes,
- text_encoders: clips,
- loras,
- [ANIMATEDIFF_SUBFOLDER]: motion,
- }
+ // Every folder of COMFY_MODEL_FOLDERS, keyed by the same subfolder name the
+ // catalog files carry, so the fallback further down can look a file up by
+ // the folder it was downloaded into. The list this used to name by hand had
+ // grown one loader at a time, each time after a bundle card said Installed
+ // over a picker that had nothing: the GGUF quants (b8531b6), the motion
+ // modules under custom_nodes and the LoRA folder (2026-08-29). The table is
+ // what stops the next one.
+ const raw = await readComfyFolderLists()
+ const filtered = await Promise.all(
+ Object.entries(raw).map(async ([subfolder, names]) =>
+ [subfolder, Array.from(await filterPartialFiles(names))] as const),
+ )
+ comfyLists = Object.fromEntries(filtered)
} catch {
comfyLists = null // ComfyUI not reachable · size-check verdicts stand
}
@@ -379,7 +361,10 @@ export async function checkBundlesInstalled(bundles: ModelBundle[]): Promise<Rec
for (const arr of Object.values(comfyLists)) for (const n of arr) visible.add(normalizeModelBase(n))
for (const bundle of bundles) {
if (!result[bundle.name]) continue
- const enumFiles = bundle.files.filter(f => f.filename && f.subfolder && ENUM_SUBFOLDERS.has(f.subfolder))
+ // The folders THIS ComfyUI enumerates, not the folders a ComfyUI could:
+ // a loader that is not installed here has said nothing about its folder,
+ // and its silence must not send a finished bundle back to the button.
+ const enumFiles = bundle.files.filter(f => f.filename && f.subfolder && f.subfolder in comfyLists!)
if (enumFiles.length === 0) continue
const unseen = enumFiles.filter(f => !visible.has(normalizeModelBase(f.filename!)))
if (unseen.length > 0) {
@@ -412,26 +397,6 @@ export async function checkBundlesInstalled(bundles: ModelBundle[]): Promise<Rec
return result
}
-/** Where the AnimateDiff-Evolved pack keeps its motion modules. Not under
- * ComfyUI\models at all, which is exactly why the counter and the Installed
- * list used to miss a fully installed AnimateDiff bundle while its card said
- * Installed (counter-check on the Windows box, 2026-08-29). */
-export const ANIMATEDIFF_SUBFOLDER = 'custom_nodes/ComfyUI-AnimateDiff-Evolved/models'
-
-/** Subfolders whose contents ComfyUI enumerates via object_info — the only
- * ones the visibility check can reason about (upscale models and the GGUF
- * text downloads stay on the pure size check). The AnimateDiff one is
- * enumerated by the pack's own ADE_LoadAnimateDiffModel node, so it belongs
- * here even though it sits under custom_nodes: a motion module the running
- * ComfyUI cannot list is exactly as useless as an invisible checkpoint.
- *
- * loras joined on 2026-08-29, with readComfyModelNames below. LoraLoader has
- * always enumerated that folder; nothing here ever asked it, so a LoRA was
- * the one installed file the app could not reason about anywhere: its card
- * trusted the disk alone, the counter and the list never saw it, and a
- * finished LoRA download was skipped by the visibility wait as unjudgeable. */
-export const ENUM_SUBFOLDERS = new Set(['checkpoints', 'diffusion_models', 'vae', 'text_encoders', 'loras', ANIMATEDIFF_SUBFOLDER])
-
/** Base identity of a model file: basename only (ComfyUI enums can carry
* nested-subdir prefixes), lowercase, extension and common quant suffixes
* stripped. Shared by the installed-detection visibility check and the fuzzy
@@ -446,30 +411,27 @@ export function normalizeModelBase(name: string): string {
*
* ONE reader, because "can ComfyUI see this file" is asked from three places
* and every place that asked its own way ended up asking a different question.
- * UNETLoader enumerates only .safetensors and .sft; every GGUF quant is listed
- * by ComfyUI-GGUF's own loader instead. checkBundlesInstalled was taught that
- * fifth loader in 2.6.6 (6abf570) and the Create probe in 2.6.5 (b8531b6),
- * while the Model Manager's install click kept asking four. Both Unfiltered
- * video bundles are GGUF, so on that path a perfectly listed model came back
- * "not listed" and the user was told LU and ComfyUI use different model
- * folders, which was never true. Nothing here may go back to a subset. */
+ * The loaders it asks are COMFY_MODEL_FOLDERS, the same table the catalog's
+ * write targets are checked against, so a folder can no longer be written into
+ * and then not read back. Every widening this reader has needed was a folder
+ * someone had added to the catalog and to nothing else: the GGUF loader in
+ * 2.6.6 (6abf570) for the Unfiltered video bundles, the LoRA and AnimateDiff
+ * loaders on 2026-08-29, clip_vision and audio_encoders here. */
export async function readComfyModelNames(): Promise<string[]> {
- const lists = await Promise.all([
- getCheckpoints(), getDiffusionModels(), getVAEModels(), getCLIPModels(), getGgufUnetModels(),
- // Seventh loader, added 2026-08-29 after the abnahme counter-check: the
- // LoRA folder. Two installed addon bundles (Pixel Art XL, SDXL VAE) read
- // Installed on their cards while no list and no counter knew them, and
- // the LoRA half of that could not even be judged, because this reader
- // never asked LoraLoader.
- getLoraModels(),
- // Sixth loader, added 2026-08-29 after the counter-check: the AnimateDiff
- // pack enumerates its motion modules itself, from a folder under
- // custom_nodes. Without it a finished AnimateDiff download could never be
- // confirmed, so the download store spent its full budget and then told the
- // user LU and ComfyUI use different model folders, which was not true.
- getAnimateDiffModels(),
- ])
- return lists.flat()
+ return Object.values(await readComfyFolderLists()).flat()
+}
+
+/** The folders this ComfyUI really enumerates right now. ENUM_SUBFOLDERS asks
+ * the same question of the catalog ("could this folder be judged at all");
+ * this one asks the engine in front of us ("can it, here"). A bundle must
+ * never be sent back to the download button over a loader that is simply not
+ * installed on the box. */
+export async function judgeableFolders(): Promise<Set<string>> {
+ try {
+ return new Set(Object.keys(await readComfyFolderLists()))
+ } catch {
+ return new Set()
+ }
}
/** Which of `wanted` the RUNNING ComfyUI does not list yet.
@@ -481,12 +443,6 @@ export async function readComfyModelNames(): Promise<string[]> {
* Voxyl AI's card on 2026-08-13 simply left a model out of the Installed tab
* instead. Two probes would have been two chances to drift.
*
- * getGgufUnetModels belongs here for the same reason getImageModels needs it
- * (comfyui.ts:658): UNETLoader only enumerates .safetensors and .sft, GGUF
- * quants are listed by ComfyUI-GGUF's own loader. The default Talking
- * Character bundle IS a .gguf in diffusion_models, so without it the probe
- * can never succeed for that bundle.
- *
* An engine it cannot reach reports everything as missing: an answer we could
* not get is not a file we have seen. */
export async function modelsNotVisibleInComfy(wanted: string[]): Promise<string[]> {
@@ -752,6 +708,10 @@ export async function installBundleComplete(bundle: ModelBundle): Promise<void>
return left.length === 0
}
+ // Which folders this engine can be asked about at all. Read once for the
+ // whole bundle, and lazily: a bundle whose files are all fresh never needs it.
+ const judgeable = judgeableFolders()
+
// ONE space check for the whole bundle, before the first byte moves.
//
// Every file starts its own transfer and every transfer checked the free
@@ -771,7 +731,7 @@ export async function installBundleComplete(bundle: ModelBundle): Promise<void>
for (const file of bundle.files) {
if (!file.downloadUrl || !file.filename || !file.subfolder) continue
if (installedFiles.has(file.filename)) {
- const visible = ENUM_SUBFOLDERS.has(file.subfolder) ? await comfyCanSee(file.filename) : null
+ const visible = (await judgeable).has(file.subfolder) ? await comfyCanSee(file.filename) : null
// The file is on disk at its full size. That much is certain right now,
// so it is what the card is told, and an engine that has not caught up
// yet is not turned into an accusation the user cannot act on.
diff --git a/src/components/create/experimental/CreateContext.tsx b/src/components/create/experimental/CreateContext.tsx
index 71e5723c..0fef80d4 100644
--- a/src/components/create/experimental/CreateContext.tsx
+++ b/src/components/create/experimental/CreateContext.tsx
@@ -5,7 +5,7 @@ import { useCloudSession } from '../../../hooks/useCloudSession'
import { useCreateStore, type GalleryItem } from '../../../stores/createStore'
import { getLoraModels, getVAEModels, checkComfyConnection, refreshComfyModels, bundleForVideoIntent } from '../../../api/comfyui'
import { getAllNodeInfo, clearNodeCache } from '../../../api/comfyui-nodes'
-import { installCustomNodes, getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles, startModelDownload, getDownloadProgress, modelsNotVisibleInComfy, ENUM_SUBFOLDERS } from '../../../api/discover'
+import { installCustomNodes, getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles, startModelDownload, getDownloadProgress, modelsNotVisibleInComfy, judgeableFolders } from '../../../api/discover'
import { backendCall, isMacOS, isLinux } from '../../../api/backend'
import { asComfyGpuMode, comfyCpuBannerText, type ComfyCpuBannerFacts } from '../../../lib/comfy-cpu-banner'
import { installMlxStack } from '../../../api/mlx-install'
@@ -462,6 +462,7 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
signal,
},
)
+ const judgeable = await judgeableFolders()
onProgress?.('Refreshing the model list…')
const refreshLists = async () => {
await refreshComfyModels().catch(() => false)
@@ -476,7 +477,11 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
// stayed on "Refreshing the model list…" forever (C8, Voxyl AI and Aldrich
// Ironhart 2026-08-13): the install returned happy, and Stage keeps the
// card up until the lists refill.
- const enumFiles = files.filter((f) => ENUM_SUBFOLDERS.has(f.subfolder!))
+ // The folders THIS ComfyUI enumerates. A loader it does not have (the audio
+ // encoder node is younger than the boxes some people run) says nothing
+ // about its folder, and waiting for it to list a file it will never list
+ // ends in a red card blaming the model folder for a missing node.
+ const enumFiles = files.filter((f) => judgeable.has(f.subfolder!))
if (enumFiles.length > 0) {
const wanted = enumFiles.map((f) => f.filename!)
// The probe itself lives in discover.ts, because the Model Manager
diff --git a/src/lib/__tests__/model-visible-wait.test.ts b/src/lib/__tests__/model-visible-wait.test.ts
index 24fb1d68..0c44835d 100644
--- a/src/lib/__tests__/model-visible-wait.test.ts
+++ b/src/lib/__tests__/model-visible-wait.test.ts
@@ -99,6 +99,11 @@ describe('the install path uses it, and says something honest when it runs out',
resolve(dirname(fileURLToPath(import.meta.url)), '../../api/discover.ts'),
'utf8',
)
+ // The loaders themselves live beside the folder table they belong to.
+ const comfyuiSrc = readFileSync(
+ resolve(dirname(fileURLToPath(import.meta.url)), '../../api/comfyui.ts'),
+ 'utf8',
+ )
it('the video bundle is picked by the lane rule, not by index', () => {
// The bug this pins: the installer took getVideoBundles()[0] whatever the
@@ -110,10 +115,13 @@ describe('the install path uses it, and says something honest when it runs out',
expect(src).not.toMatch(/kind === 'video' \? getVideoBundles\(\)/)
})
- it('only the subfolders ComfyUI enumerates are checked', () => {
- // loras and upscale models never show up in these enums, so demanding
- // them would turn every install into a failure.
- expect(src).toMatch(/files\.filter\(\(f\) => ENUM_SUBFOLDERS\.has\(f\.subfolder!\)\)/)
+ it('only the folders THIS engine enumerates are checked', () => {
+ // Demanding a folder the engine in front of us says nothing about turns an
+ // install into a failure over a loader that is simply not there. The list
+ // is asked of the engine now (judgeableFolders) rather than taken from a
+ // set of folders a ComfyUI could have.
+ expect(src).toMatch(/const judgeable = await judgeableFolders\(\)/)
+ expect(src).toMatch(/files\.filter\(\(f\) => judgeable\.has\(f\.subfolder!\)\)/)
})
it('an engine it cannot reach counts as nothing confirmed', () => {
@@ -152,17 +160,16 @@ describe('the install path uses it, and says something honest when it runs out',
//
// B1 (2.6.7): the loader list moved into one reader, readComfyModelNames,
// because the three paths that ask "can ComfyUI see this file" each had
- // their own copy and they drifted. checkBundlesInstalled was taught the
- // GGUF loader in 2.6.6 and this probe was born with it, while the Model
- // Manager's install click kept asking four loaders and told users LU and
- // ComfyUI use different model folders for a GGUF the engine serves fine.
- // The guard pins the reader AND that both callers go through it.
+ // their own copy and they drifted. 3.0.0 took the last step: the loaders
+ // are COMFY_MODEL_FOLDERS in comfyui.ts, the same table the catalog's
+ // download folders are checked against, so a folder cannot be written into
+ // and then not read back (.__nothing_, 2026-09-02).
const reader = discoverSrc.slice(
discoverSrc.indexOf('export async function readComfyModelNames'),
- discoverSrc.indexOf('/** Which of `wanted`'),
+ discoverSrc.indexOf('/** The folders this ComfyUI really enumerates'),
)
- expect(reader).toContain('getGgufUnetModels()')
- expect(discoverSrc).toMatch(/import \{[^}]*getGgufUnetModels[^}]*\} from "\.\/comfyui"/)
+ expect(reader).toContain('readComfyFolderLists()')
+ expect(comfyuiSrc).toContain("nodeOptionsOrNull('UnetLoaderGGUF', 'unet_name')")
const probe = discoverSrc.slice(
discoverSrc.indexOf('export async function modelsNotVisibleInComfy'),
discoverSrc.indexOf('/** #72:'),