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.

feat: in-app Ollama + ComfyUI install with progress, configurable port, provider auto-check

PurpleDoubleD8bb298a764c6
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index cb963f5b..f22d3225 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -8,6 +8,17 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+[[package]]
+name = "aes"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures",
+]
+
[[package]]
name = "aho-corasick"
version = "1.1.4"
@@ -47,6 +58,15 @@ version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
+[[package]]
+name = "arbitrary"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1"
+dependencies = [
+ "derive_arbitrary",
+]
+
[[package]]
name = "ashpd"
version = "0.11.1"
@@ -384,6 +404,25 @@ dependencies = [
"serde",
]
+[[package]]
+name = "bzip2"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47"
+dependencies = [
+ "bzip2-sys",
+]
+
+[[package]]
+name = "bzip2-sys"
+version = "0.1.13+1.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14"
+dependencies = [
+ "cc",
+ "pkg-config",
+]
+
[[package]]
name = "cairo-rs"
version = "0.18.5"
@@ -458,6 +497,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1e928d4b69e3077709075a938a05ffbedfa53a84c8f766efbf8220bb1ff60e1"
dependencies = [
"find-msvc-tools",
+ "jobserver",
+ "libc",
"shlex",
]
@@ -506,6 +547,16 @@ dependencies = [
"windows-link 0.2.1",
]
+[[package]]
+name = "cipher"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
+dependencies = [
+ "crypto-common",
+ "inout",
+]
+
[[package]]
name = "combine"
version = "4.6.7"
@@ -525,6 +576,12 @@ dependencies = [
"crossbeam-utils",
]
+[[package]]
+name = "constant_time_eq"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
+
[[package]]
name = "convert_case"
version = "0.4.0"
@@ -600,6 +657,21 @@ dependencies = [
"libc",
]
+[[package]]
+name = "crc"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d"
+dependencies = [
+ "crc-catalog",
+]
+
+[[package]]
+name = "crc-catalog"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
+
[[package]]
name = "crc32fast"
version = "1.5.0"
@@ -737,6 +809,12 @@ dependencies = [
"syn 2.0.117",
]
+[[package]]
+name = "deflate64"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac6b926516df9c60bfa16e107b21086399f8285a44ca9711344b9e553c5146e2"
+
[[package]]
name = "deranged"
version = "0.5.8"
@@ -747,6 +825,17 @@ dependencies = [
"serde_core",
]
+[[package]]
+name = "derive_arbitrary"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.117",
+]
+
[[package]]
name = "derive_more"
version = "0.99.20"
@@ -789,6 +878,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
+ "subtle",
]
[[package]]
@@ -1386,9 +1476,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
+ "js-sys",
"libc",
"r-efi 5.3.0",
"wasip2",
+ "wasm-bindgen",
]
[[package]]
@@ -1616,6 +1708,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+[[package]]
+name = "hmac"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
+dependencies = [
+ "digest",
+]
+
[[package]]
name = "hostname"
version = "0.4.2"
@@ -1960,6 +2061,15 @@ dependencies = [
"cfb",
]
+[[package]]
+name = "inout"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
+dependencies = [
+ "generic-array",
+]
+
[[package]]
name = "ipnet"
version = "2.12.0"
@@ -2068,6 +2178,16 @@ dependencies = [
"syn 2.0.117",
]
+[[package]]
+name = "jobserver"
+version = "0.1.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
+dependencies = [
+ "getrandom 0.3.4",
+ "libc",
+]
+
[[package]]
name = "js-sys"
version = "0.3.92"
@@ -2222,6 +2342,7 @@ dependencies = [
"walkdir",
"whoami",
"windows-sys 0.59.0",
+ "zip",
]
[[package]]
@@ -2239,6 +2360,27 @@ version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
+[[package]]
+name = "lzma-rs"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e"
+dependencies = [
+ "byteorder",
+ "crc",
+]
+
+[[package]]
+name = "lzma-sys"
+version = "0.1.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+]
+
[[package]]
name = "mac"
version = "0.1.1"
@@ -2746,6 +2888,16 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
+[[package]]
+name = "pbkdf2"
+version = "0.12.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
+dependencies = [
+ "digest",
+ "hmac",
+]
+
[[package]]
name = "percent-encoding"
version = "2.3.2"
@@ -3919,6 +4071,17 @@ dependencies = [
"stable_deref_trait",
]
+[[package]]
+name = "sha1"
+version = "0.10.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
[[package]]
name = "sha2"
version = "0.10.9"
@@ -6145,6 +6308,15 @@ dependencies = [
"pkg-config",
]
+[[package]]
+name = "xz2"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2"
+dependencies = [
+ "lzma-sys",
+]
+
[[package]]
name = "yoke"
version = "0.8.1"
@@ -6275,6 +6447,20 @@ name = "zeroize"
version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
+dependencies = [
+ "zeroize_derive",
+]
+
+[[package]]
+name = "zeroize_derive"
+version = "1.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.117",
+]
[[package]]
name = "zerotrie"
@@ -6309,12 +6495,82 @@ dependencies = [
"syn 2.0.117",
]
+[[package]]
+name = "zip"
+version = "2.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fabe6324e908f85a1c52063ce7aa26b68dcb7eb6dbc83a2d148403c9bc3eba50"
+dependencies = [
+ "aes",
+ "arbitrary",
+ "bzip2",
+ "constant_time_eq",
+ "crc32fast",
+ "crossbeam-utils",
+ "deflate64",
+ "displaydoc",
+ "flate2",
+ "getrandom 0.3.4",
+ "hmac",
+ "indexmap 2.13.0",
+ "lzma-rs",
+ "memchr",
+ "pbkdf2",
+ "sha1",
+ "thiserror 2.0.18",
+ "time",
+ "xz2",
+ "zeroize",
+ "zopfli",
+ "zstd",
+]
+
[[package]]
name = "zmij"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
+[[package]]
+name = "zopfli"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249"
+dependencies = [
+ "bumpalo",
+ "crc32fast",
+ "log",
+ "simd-adler32",
+]
+
+[[package]]
+name = "zstd"
+version = "0.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a"
+dependencies = [
+ "zstd-safe",
+]
+
+[[package]]
+name = "zstd-safe"
+version = "7.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d"
+dependencies = [
+ "zstd-sys",
+]
+
+[[package]]
+name = "zstd-sys"
+version = "2.0.16+zstd.1.5.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748"
+dependencies = [
+ "cc",
+ "pkg-config",
+]
+
[[package]]
name = "zvariant"
version = "5.10.0"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index cfd22e01..807043b7 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -15,6 +15,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.12", features = ["stream", "blocking", "json"] }
+zip = "2"
dirs = "6"
regex = "1"
glob = "0.3"
diff --git a/src-tauri/src/commands/install.rs b/src-tauri/src/commands/install.rs
index 72b44373..348977fa 100644
--- a/src-tauri/src/commands/install.rs
+++ b/src-tauri/src/commands/install.rs
@@ -1,13 +1,16 @@
use std::fs;
+use std::io::Read as IoRead;
use std::path::PathBuf;
use std::process::{Command, Stdio};
+use std::sync::{Arc, Mutex};
+use std::time::Instant;
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
use tauri::State;
-use crate::state::AppState;
+use crate::state::{AppState, InstallState};
/// Windows: hide console windows for spawned processes
#[cfg(target_os = "windows")]
@@ -33,10 +36,21 @@ pub fn install_comfyui(
.unwrap_or_else(|| dirs::home_dir().unwrap_or_default().join("ComfyUI"));
let python_bin = state.python_bin.clone();
+ let install_status = state.install_status.clone();
std::thread::spawn(move || {
+ // Helper to update install status + logs
+ let update = |status: &str, msg: &str| {
+ if let Ok(mut s) = install_status.lock() {
+ s.status = status.to_string();
+ s.logs.push(msg.to_string());
+ }
+ };
+
// Step 1: Git clone
println!("[Install] Cloning ComfyUI to {:?}", target_dir);
+ update("downloading", "Step 1/3: Downloading ComfyUI repository...");
+
let mut cmd = Command::new("git");
cmd.args(["clone", "https://github.com/comfyanonymous/ComfyUI.git"])
.arg(&target_dir)
@@ -49,12 +63,13 @@ pub fn install_comfyui(
match clone {
Ok(output) if output.status.success() => {
println!("[Install] Git clone successful");
+ update("installing", "Repository cloned successfully.");
}
Ok(output) => {
let stderr = String::from_utf8_lossy(&output.stderr);
- // Directory might already exist
if stderr.contains("already exists") {
println!("[Install] ComfyUI directory already exists, updating...");
+ update("installing", "ComfyUI already exists, pulling latest...");
let mut pull = Command::new("git");
pull.args(["pull"]).current_dir(&target_dir)
.stdout(Stdio::piped()).stderr(Stdio::piped());
@@ -62,12 +77,16 @@ pub fn install_comfyui(
pull.creation_flags(CREATE_NO_WINDOW);
let _ = pull.output();
} else {
- println!("[Install] Git clone failed: {}", stderr);
+ let err = format!("Git clone failed: {}", stderr);
+ println!("[Install] {}", err);
+ update("error", &err);
return;
}
}
Err(e) => {
- println!("[Install] Git not available: {}", e);
+ let err = format!("Git is not installed or not in PATH: {}", e);
+ println!("[Install] {}", err);
+ update("error", &err);
return;
}
}
@@ -79,7 +98,9 @@ pub fn install_comfyui(
nv.creation_flags(CREATE_NO_WINDOW);
let has_nvidia = nv.output().map(|o| o.status.success()).unwrap_or(false);
- println!("[Install] GPU detected: {}", if has_nvidia { "NVIDIA CUDA" } else { "CPU only" });
+ let gpu_info = if has_nvidia { "NVIDIA GPU detected - installing CUDA PyTorch" } else { "No NVIDIA GPU - installing CPU PyTorch" };
+ println!("[Install] {}", gpu_info);
+ update("installing", &format!("Step 2/3: {} (this may take several minutes)...", gpu_info));
let torch_args = if has_nvidia {
vec!["-m", "pip", "install", "torch", "torchvision", "torchaudio",
@@ -88,15 +109,33 @@ pub fn install_comfyui(
vec!["-m", "pip", "install", "torch", "torchvision", "torchaudio"]
};
- println!("[Install] Installing PyTorch...");
let mut pip = Command::new(&python_bin);
pip.args(&torch_args).stdout(Stdio::piped()).stderr(Stdio::piped());
#[cfg(target_os = "windows")]
pip.creation_flags(CREATE_NO_WINDOW);
- let _ = pip.output();
+ match pip.output() {
+ Ok(output) if output.status.success() => {
+ update("installing", "PyTorch installed successfully.");
+ }
+ Ok(output) => {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ let err = format!("PyTorch installation failed: {}", stderr.chars().take(200).collect::<String>());
+ println!("[Install] {}", err);
+ update("error", &err);
+ return;
+ }
+ Err(e) => {
+ let err = format!("Python not found ({}). Install Python 3.10+ first.", e);
+ println!("[Install] {}", err);
+ update("error", &err);
+ return;
+ }
+ }
// Step 3: Install ComfyUI requirements
println!("[Install] Installing ComfyUI requirements...");
+ update("installing", "Step 3/3: Installing ComfyUI dependencies...");
+
let reqs = target_dir.join("requirements.txt");
if reqs.exists() {
let mut pip_req = Command::new(&python_bin);
@@ -104,10 +143,24 @@ pub fn install_comfyui(
.stdout(Stdio::piped()).stderr(Stdio::piped());
#[cfg(target_os = "windows")]
pip_req.creation_flags(CREATE_NO_WINDOW);
- let _ = pip_req.output();
+ match pip_req.output() {
+ Ok(output) if output.status.success() => {
+ update("installing", "Dependencies installed successfully.");
+ }
+ Ok(output) => {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ println!("[Install] Requirements install warning: {}", &stderr[..stderr.len().min(200)]);
+ // Don't fail — some optional deps may fail but ComfyUI can still work
+ update("installing", "Some dependencies had warnings (non-critical).");
+ }
+ Err(_) => {
+ update("installing", "Could not install some dependencies (non-critical).");
+ }
+ }
}
println!("[Install] ComfyUI installation complete");
+ update("complete", "ComfyUI installed successfully!");
});
Ok(serde_json::json!({"status": "installing"}))
@@ -119,9 +172,211 @@ pub fn install_comfyui_status(state: State<'_, AppState>) -> Result<serde_json::
Ok(serde_json::json!({
"status": install.status,
"logs": install.logs,
+ "download_progress": install.download_progress,
+ "download_total": install.download_total,
+ "download_speed": install.download_speed,
}))
}
+// ── Shared helper: download a file with progress tracking ────────────────────
+
+fn download_file_blocking(
+ url: &str,
+ dest: &PathBuf,
+ install_state: &Arc<Mutex<InstallState>>,
+) -> Result<(), String> {
+ let client = reqwest::blocking::Client::builder()
+ .user_agent("LocallyUncensored/2.3")
+ .redirect(reqwest::redirect::Policy::limited(10))
+ .timeout(std::time::Duration::from_secs(7200))
+ .build()
+ .map_err(|e| format!("HTTP client error: {}", e))?;
+
+ let response = client.get(url).send().map_err(|e| format!("Request failed: {}", e))?;
+
+ if !response.status().is_success() {
+ return Err(format!("HTTP {}", response.status()));
+ }
+
+ let total = response.content_length().unwrap_or(0);
+ if let Ok(mut s) = install_state.lock() {
+ s.download_total = total;
+ s.status = "downloading".to_string();
+ }
+
+ let mut file = fs::File::create(dest).map_err(|e| format!("Create file: {}", e))?;
+ let mut reader = std::io::BufReader::new(response);
+ let mut downloaded: u64 = 0;
+ let start = Instant::now();
+ let mut last_update = Instant::now();
+ let mut buf = [0u8; 65536]; // 64KB chunks
+
+ loop {
+ let n = reader.read(&mut buf).map_err(|e| format!("Read error: {}", e))?;
+ if n == 0 {
+ break;
+ }
+ std::io::Write::write_all(&mut file, &buf[..n]).map_err(|e| format!("Write: {}", e))?;
+ downloaded += n as u64;
+
+ if last_update.elapsed().as_millis() > 500 {
+ let elapsed = start.elapsed().as_secs_f64().max(0.001);
+ let speed = downloaded as f64 / elapsed;
+ if let Ok(mut s) = install_state.lock() {
+ s.download_progress = downloaded;
+ s.download_speed = speed;
+ }
+ last_update = Instant::now();
+ }
+ }
+
+ // Final update
+ if let Ok(mut s) = install_state.lock() {
+ s.download_progress = downloaded;
+ s.download_total = downloaded; // in case Content-Length was missing
+ s.download_speed = 0.0;
+ }
+
+ Ok(())
+}
+
+// ── Ollama Install ──────────────────────────────────────────────────────────
+
+#[tauri::command]
+pub fn install_ollama(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
+ let mut install = state.ollama_install.lock().unwrap();
+ if install.status == "downloading" || install.status == "installing" || install.status == "starting" {
+ return Ok(serde_json::json!({"status": "already_installing"}));
+ }
+
+ install.status = "downloading".to_string();
+ install.logs.clear();
+ install.download_progress = 0;
+ install.download_total = 0;
+ install.download_speed = 0.0;
+ install.logs.push("Downloading Ollama installer...".to_string());
+ drop(install);
+
+ let ollama_state = state.ollama_install.clone();
+
+ std::thread::spawn(move || {
+ let update = |status: &str, msg: &str| {
+ if let Ok(mut s) = ollama_state.lock() {
+ s.status = status.to_string();
+ s.logs.push(msg.to_string());
+ }
+ };
+
+ // Step 1: Download OllamaSetup.exe
+ let temp_dir = std::env::temp_dir();
+ let installer_path = temp_dir.join("OllamaSetup.exe");
+
+ println!("[Ollama] Downloading OllamaSetup.exe...");
+
+ match download_file_blocking(
+ "https://ollama.com/download/OllamaSetup.exe",
+ &installer_path,
+ &ollama_state,
+ ) {
+ Ok(()) => {
+ println!("[Ollama] Download complete");
+ update("installing", "Download complete. Installing Ollama...");
+ }
+ Err(e) => {
+ let err = format!("Download failed: {}", e);
+ println!("[Ollama] {}", err);
+ update("error", &err);
+ return;
+ }
+ }
+
+ // Step 2: Run silent install
+ println!("[Ollama] Running silent installer...");
+ let mut cmd = Command::new(&installer_path);
+ cmd.arg("/S");
+ #[cfg(target_os = "windows")]
+ cmd.creation_flags(CREATE_NO_WINDOW);
+
+ match cmd.output() {
+ Ok(output) if output.status.success() => {
+ println!("[Ollama] Installation successful");
+ update("starting", "Ollama installed. Starting Ollama...");
+ }
+ Ok(output) => {
+ let code = output.status.code().unwrap_or(-1);
+ // NSIS installer returns 0 on success; non-zero might still be OK
+ println!("[Ollama] Installer exited with code {}", code);
+ update("starting", &format!("Installer finished (code {}). Starting Ollama...", code));
+ }
+ Err(e) => {
+ let err = format!("Could not run installer: {}", e);
+ println!("[Ollama] {}", err);
+ update("error", &err);
+ return;
+ }
+ }
+
+ // Cleanup installer
+ let _ = fs::remove_file(&installer_path);
+
+ // Step 3: Start ollama serve
+ println!("[Ollama] Starting ollama serve...");
+ let mut serve = Command::new("ollama");
+ serve.arg("serve").stdout(Stdio::piped()).stderr(Stdio::piped());
+ #[cfg(target_os = "windows")]
+ serve.creation_flags(CREATE_NO_WINDOW);
+
+ // Try to start — may already be running as service
+ let _ = serve.spawn();
+
+ // Step 4: Wait for Ollama to respond (up to 30 seconds)
+ println!("[Ollama] Waiting for Ollama to be ready...");
+ update("starting", "Waiting for Ollama to start...");
+
+ let client = reqwest::blocking::Client::builder()
+ .timeout(std::time::Duration::from_secs(3))
+ .build()
+ .unwrap_or_default();
+
+ let mut ready = false;
+ for i in 0..15 {
+ std::thread::sleep(std::time::Duration::from_secs(2));
+ match client.get("http://localhost:11434/api/tags").send() {
+ Ok(res) if res.status().is_success() => {
+ ready = true;
+ break;
+ }
+ _ => {
+ println!("[Ollama] Not ready yet, attempt {}/15", i + 1);
+ }
+ }
+ }
+
+ if ready {
+ println!("[Ollama] Ready!");
+ update("complete", "Ollama is ready!");
+ } else {
+ update("error", "Ollama installed but not responding. Try restarting the app.");
+ }
+ });
+
+ Ok(serde_json::json!({"status": "downloading"}))
+}
+
+#[tauri::command]
+pub fn install_ollama_status(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
+ let install = state.ollama_install.lock().unwrap();
+ Ok(serde_json::json!({
+ "status": install.status,
+ "logs": install.logs,
+ "download_progress": install.download_progress,
+ "download_total": install.download_total,
+ "download_speed": install.download_speed,
+ }))
+}
+
+// ──────────────────────────────────────────────────────────────────────────────
+
#[allow(non_snake_case)]
#[tauri::command]
pub fn install_custom_node(
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index 716877e5..1e4df2ca 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -188,8 +188,8 @@ pub fn find_comfyui_path() -> Option<String> {
None
}
-fn is_comfyui_running() -> bool {
- reqwest::blocking::get("http://localhost:8188/system_stats")
+fn is_comfyui_running_on_port(port: u16) -> bool {
+ reqwest::blocking::get(format!("http://localhost:{}/system_stats", port))
.map(|r| r.status().is_success())
.unwrap_or(false)
}
@@ -235,7 +235,9 @@ pub fn start_ollama(_state: State<'_, AppState>) -> Result<serde_json::Value, St
#[tauri::command]
pub fn start_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
- if is_comfyui_running() {
+ let port = *state.comfy_port.lock().unwrap();
+
+ if is_comfyui_running_on_port(port) {
return Ok(serde_json::json!({"status": "already_running"}));
}
@@ -256,11 +258,12 @@ pub fn start_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, St
// Validate python binary exists
let python = &state.python_bin;
+ let port_str = port.to_string();
println!("[ComfyUI] Using Python: {}", python);
- println!("[ComfyUI] Starting from: {}", comfy_path);
+ println!("[ComfyUI] Starting from: {} on port {}", comfy_path, port);
let mut cmd = Command::new(python);
- cmd.args(["main.py", "--listen", "127.0.0.1", "--port", "8188", "--enable-cors-header", "*"])
+ cmd.args(["main.py", "--listen", "127.0.0.1", "--port", &port_str, "--enable-cors-header", "*"])
.current_dir(&comfy_path)
.env("TQDM_DISABLE", "1")
.env("PYTHONUNBUFFERED", "1")
@@ -335,7 +338,9 @@ pub fn stop_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, Str
#[tauri::command]
pub async fn comfyui_status(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
- let running = reqwest::get("http://localhost:8188/system_stats")
+ let port = *state.comfy_port.lock().unwrap();
+
+ let running = reqwest::get(format!("http://localhost:{}/system_stats", port))
.await
.map(|r| r.status().is_success())
.unwrap_or(false);
@@ -357,6 +362,7 @@ pub async fn comfyui_status(state: State<'_, AppState>) -> Result<serde_json::Va
"starting": process_alive && !running,
"found": found,
"path": path,
+ "port": port,
"processAlive": process_alive,
}))
}
@@ -404,6 +410,40 @@ pub fn set_comfyui_path(path: String, state: State<'_, AppState>) -> Result<serd
Ok(serde_json::json!({"status": "saved", "path": path}))
}
+#[tauri::command]
+pub fn set_comfyui_port(port: u16, state: State<'_, AppState>) -> Result<serde_json::Value, String> {
+ if port == 0 {
+ return Err("Port must be greater than 0".to_string());
+ }
+
+ {
+ let mut p = state.comfy_port.lock().unwrap();
+ *p = port;
+ }
+
+ // Persist to config file
+ if let Some(config_dir) = dirs::config_dir() {
+ let app_config = config_dir.join("locally-uncensored");
+ let _ = fs::create_dir_all(&app_config);
+ let config_file = app_config.join("config.json");
+
+ let mut config: serde_json::Value = if config_file.exists() {
+ fs::read_to_string(&config_file)
+ .ok()
+ .and_then(|s| serde_json::from_str(&s).ok())
+ .unwrap_or_else(|| serde_json::json!({}))
+ } else {
+ serde_json::json!({})
+ };
+
+ config["comfyui_port"] = serde_json::json!(port);
+ let _ = fs::write(&config_file, serde_json::to_string_pretty(&config).unwrap());
+ }
+
+ println!("[ComfyUI] Port set to {}", port);
+ Ok(serde_json::json!({"status": "saved", "port": port}))
+}
+
/// Auto-start Ollama on app launch (called from setup)
pub fn auto_start_ollama(_state: &AppState) {
// Check if already running
@@ -445,18 +485,21 @@ pub fn auto_start_comfyui(state: &AppState) {
}
}
- if is_comfyui_running() {
- println!("[ComfyUI] Already running on port 8188");
+ let port = *state.comfy_port.lock().unwrap();
+
+ if is_comfyui_running_on_port(port) {
+ println!("[ComfyUI] Already running on port {}", port);
return;
}
match find_comfyui_path() {
Some(path) => {
- println!("[ComfyUI] Auto-starting from: {}", path);
+ let port_str = port.to_string();
+ println!("[ComfyUI] Auto-starting from: {} on port {}", path, port);
*state.comfy_path.lock().unwrap() = Some(path.clone());
let mut cmd = Command::new(&state.python_bin);
- cmd.args(["main.py", "--listen", "127.0.0.1", "--port", "8188", "--enable-cors-header", "*"])
+ cmd.args(["main.py", "--listen", "127.0.0.1", "--port", &port_str, "--enable-cors-header", "*"])
.current_dir(&path)
.env("TQDM_DISABLE", "1")
.env("PYTHONUNBUFFERED", "1")
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index c36cac67..e6c9be6c 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -27,9 +27,12 @@ fn main() {
commands::process::comfyui_status,
commands::process::find_comfyui,
commands::process::set_comfyui_path,
+ commands::process::set_comfyui_port,
// Installation
commands::install::install_comfyui,
commands::install::install_comfyui_status,
+ commands::install::install_ollama,
+ commands::install::install_ollama_status,
commands::install::install_custom_node,
// Whisper STT
commands::whisper::whisper_status,
diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs
index ba67c9dd..d2278556 100644
--- a/src-tauri/src/state.rs
+++ b/src-tauri/src/state.rs
@@ -23,6 +23,9 @@ pub struct DownloadProgress {
pub struct InstallState {
pub status: String,
pub logs: Vec<String>,
+ pub download_progress: u64,
+ pub download_total: u64,
+ pub download_speed: f64,
}
impl Default for InstallState {
@@ -30,6 +33,9 @@ impl Default for InstallState {
Self {
status: "idle".to_string(),
logs: Vec::new(),
+ download_progress: 0,
+ download_total: 0,
+ download_speed: 0.0,
}
}
}
@@ -37,11 +43,13 @@ impl Default for InstallState {
pub struct AppState {
pub comfy_process: Mutex<Option<Child>>,
pub comfy_path: Mutex<Option<String>>,
+ pub comfy_port: Mutex<u16>,
pub whisper: Arc<Mutex<WhisperServer>>,
pub downloads: Arc<Mutex<HashMap<String, DownloadProgress>>>,
pub download_tokens: Arc<Mutex<HashMap<String, CancellationToken>>>,
pub pull_tokens: Arc<Mutex<HashMap<String, CancellationToken>>>,
- pub install_status: Mutex<InstallState>,
+ pub install_status: Arc<Mutex<InstallState>>,
+ pub ollama_install: Arc<Mutex<InstallState>>,
pub searxng_install: Mutex<InstallState>,
pub searxng_available: AtomicBool,
pub python_bin: String,
@@ -55,11 +63,13 @@ impl AppState {
Self {
comfy_process: Mutex::new(None),
comfy_path: Mutex::new(None),
+ comfy_port: Mutex::new(8188),
whisper: Arc::new(Mutex::new(WhisperServer::new())),
downloads: Arc::new(Mutex::new(HashMap::new())),
download_tokens: Arc::new(Mutex::new(HashMap::new())),
pull_tokens: Arc::new(Mutex::new(HashMap::new())),
- install_status: Mutex::new(InstallState::default()),
+ install_status: Arc::new(Mutex::new(InstallState::default())),
+ ollama_install: Arc::new(Mutex::new(InstallState::default())),
searxng_install: Mutex::new(InstallState::default()),
searxng_available: AtomicBool::new(false),
python_bin,
diff --git a/src/api/backend.ts b/src/api/backend.ts
index 19e10791..690344e3 100644
--- a/src/api/backend.ts
+++ b/src/api/backend.ts
@@ -128,6 +128,9 @@ export async function backendCall<T = any>(
set_comfyui_path: { path: "/local-api/set-comfyui-path", method: "POST" },
install_comfyui: { path: "/local-api/install-comfyui", method: "POST" },
install_comfyui_status: { path: "/local-api/install-comfyui" },
+ install_ollama: { path: "/local-api/install-ollama", method: "POST" },
+ install_ollama_status: { path: "/local-api/install-ollama-status" },
+ set_comfyui_port: { path: "/local-api/set-comfyui-port", method: "POST" },
install_custom_node: { path: "/local-api/install-custom-node", method: "POST" },
whisper_status: { path: "/local-api/transcribe-status" },
transcribe: { path: "/local-api/transcribe", method: "POST" },
@@ -207,17 +210,22 @@ export function ollamaUrl(path: string): string {
return `/api${path}`;
}
+/** Configurable ComfyUI port — default 8188, can be changed at runtime */
+let _comfyPort = 8188;
+export function setComfyPort(port: number) { _comfyPort = port; }
+export function getComfyPort(): number { return _comfyPort; }
+
/** Get the base URL for ComfyUI API calls */
export function comfyuiUrl(path: string): string {
if (isTauri()) {
- return `http://localhost:8188${path}`;
+ return `http://localhost:${_comfyPort}${path}`;
}
return `/comfyui${path}`;
}
/** Get the WebSocket URL for ComfyUI */
export function comfyuiWsUrl(): string {
- return "ws://localhost:8188/ws";
+ return `ws://localhost:${_comfyPort}/ws`;
}
/** Download a ComfyUI output file — works in both dev and Tauri mode */
diff --git a/src/api/comfyui-ws.ts b/src/api/comfyui-ws.ts
index 81da8541..54dd6fa7 100644
--- a/src/api/comfyui-ws.ts
+++ b/src/api/comfyui-ws.ts
@@ -8,6 +8,7 @@
*/
import { v4 as uuid } from 'uuid'
+import { comfyuiWsUrl } from './backend'
export type ComfyWSEvent =
| { type: 'status'; data: { queue_remaining: number } }
@@ -66,7 +67,7 @@ class ComfyWSClient {
}, timeoutMs)
try {
- this.ws = new WebSocket(`ws://localhost:8188/ws?clientId=${CLIENT_ID}`)
+ this.ws = new WebSocket(`${comfyuiWsUrl()}?clientId=${CLIENT_ID}`)
this.ws.onopen = () => {
clearTimeout(timer)
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index 01ad4d14..7e3cfc76 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -631,7 +631,7 @@ export async function submitWorkflow(workflow: Record<string, any>, clientId?: s
const payload: Record<string, any> = { prompt: workflow }
if (clientId) payload.client_id = clientId
// Use direct fetch to ComfyUI (bypasses Tauri proxy issues, CORS OK with --enable-cors-header *)
- const url = 'http://localhost:8188/prompt'
+ const url = comfyuiUrl('/prompt')
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -665,13 +665,13 @@ export async function submitWorkflow(workflow: Record<string, any>, clientId?: s
export async function cancelGeneration(): Promise<void> {
try {
- await fetch('http://localhost:8188/interrupt', { method: 'POST' })
+ await fetch(comfyuiUrl('/interrupt'), { method: 'POST' })
} catch { /* best effort */ }
}
export async function freeMemory(): Promise<void> {
try {
- await fetch('http://localhost:8188/free', {
+ await fetch(comfyuiUrl('/free'), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ unload_models: true, free_memory: true }),
@@ -682,7 +682,7 @@ export async function freeMemory(): Promise<void> {
export async function getHistory(promptId: string): Promise<any> {
try {
// Use direct fetch (CORS OK with --enable-cors-header *)
- const res = await fetch(`http://localhost:8188/history/${promptId}`)
+ const res = await fetch(comfyuiUrl(`/history/${promptId}`))
if (!res.ok) return null
const data = await res.json()
return data[promptId] ?? null
diff --git a/src/components/onboarding/Onboarding.tsx b/src/components/onboarding/Onboarding.tsx
index 8c67ee02..e354e9b9 100644
--- a/src/components/onboarding/Onboarding.tsx
+++ b/src/components/onboarding/Onboarding.tsx
@@ -65,8 +65,25 @@ export function Onboarding() {
const [comfyInstallError, setComfyInstallError] = useState('')
const [comfyPathInput, setComfyPathInput] = useState('')
const [comfyReady, setComfyReady] = useState(false)
+ const [comfyDownloadProgress, setComfyDownloadProgress] = useState(0)
+ const [comfyDownloadTotal, setComfyDownloadTotal] = useState(0)
+ const [comfyDownloadSpeed, setComfyDownloadSpeed] = useState(0)
const [systemVRAM, setSystemVRAM] = useState<number | null>(null)
const [modelSubTab, setModelSubTab] = useState<'uncensored' | 'mainstream'>('uncensored')
+ const [installStartTime, setInstallStartTime] = useState<number | null>(null)
+ const [elapsed, setElapsed] = useState(0)
+
+ // Ollama install state
+ const [ollamaInstalling, setOllamaInstalling] = useState(false)
+ const [ollamaStatus, setOllamaStatus] = useState('')
+ const [ollamaProgress, setOllamaProgress] = useState(0)
+ const [ollamaTotal, setOllamaTotal] = useState(0)
+ const [ollamaSpeed, setOllamaSpeed] = useState(0)
+ const [ollamaLogs, setOllamaLogs] = useState<string[]>([])
+ const [ollamaError, setOllamaError] = useState('')
+ const [ollamaReady, setOllamaReady] = useState(false)
+ const [ollamaStartTime, setOllamaStartTime] = useState<number | null>(null)
+ const [ollamaElapsed, setOllamaElapsed] = useState(0)
const isDark = settings.theme === 'dark'
const bgClass = isDark ? 'bg-[#0a0a0a] text-white' : 'bg-white text-gray-900'
@@ -127,6 +144,20 @@ export function Onboarding() {
// Detect system VRAM for model filtering
useEffect(() => { getSystemVRAM().then(v => setSystemVRAM(v)).catch(() => {}) }, [])
+ // Elapsed timer for ComfyUI installation
+ useEffect(() => {
+ if (!installStartTime) return
+ const timer = setInterval(() => setElapsed(Math.floor((Date.now() - installStartTime) / 1000)), 1000)
+ return () => clearInterval(timer)
+ }, [installStartTime])
+
+ // Elapsed timer for Ollama installation
+ useEffect(() => {
+ if (!ollamaStartTime) return
+ const timer = setInterval(() => setOllamaElapsed(Math.floor((Date.now() - ollamaStartTime) / 1000)), 1000)
+ return () => clearInterval(timer)
+ }, [ollamaStartTime])
+
// Auto-detect ComfyUI when entering the comfyui step
useEffect(() => {
if (step === 'comfyui' && !comfyFound && !comfyDetecting) {
@@ -325,44 +356,156 @@ export function Onboarding() {
</div>
</>
) : (
- /* ── No backends found — show all options ─────── */
+ /* ── No backends found — install Ollama in-app ─────── */
<>
<h2 className="text-base font-semibold">No local backend detected</h2>
<p className={`text-[0.7rem] ${isDark ? 'text-gray-400' : 'text-gray-500'}`}>
- Install any of these local AI backends, then hit Re-Scan. Pick whichever you prefer — they all work.
+ You need a local AI backend to chat. We'll install Ollama for you — it's the easiest to set up.
</p>
- <div className="space-y-1 text-left max-h-[45vh] overflow-y-auto scrollbar-thin pr-1">
- {LOCAL_BACKENDS.map(b => (
- <button
- key={b.id}
- onClick={() => openExternal(b.url)}
- className={`flex items-center gap-2.5 px-2.5 py-2 rounded-lg border transition-all group text-left ${
- isDark
- ? 'border-white/[0.06] hover:border-white/15 hover:bg-white/[0.03]'
- : 'border-gray-200 hover:border-gray-400 hover:bg-gray-50'
- }`}
- >
- <div className={`w-1.5 h-1.5 rounded-full shrink-0 ${isDark ? 'bg-gray-600' : 'bg-gray-300'}`} />
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-1.5">
- <p className="text-[0.7rem] font-medium">{b.name}</p>
- <ExternalLink size={10} className={`opacity-0 group-hover:opacity-100 transition-opacity ${isDark ? 'text-gray-500' : 'text-gray-400'}`} />
+ {/* Ollama ready state */}
+ {ollamaReady && (
+ <div className={`p-3 rounded-lg border ${isDark ? 'bg-green-500/10 border-green-500/20' : 'bg-green-50 border-green-200'}`}>
+ <div className="flex items-center gap-2 justify-center">
+ <Check size={14} className="text-green-400" />
+ <span className="text-[0.7rem] font-medium">Ollama is ready!</span>
+ </div>
+ </div>
+ )}
+
+ {/* Install button — only show when not installing and not ready */}
+ {!ollamaInstalling && !ollamaReady && (
+ <button
+ onClick={async () => {
+ setOllamaInstalling(true)
+ setOllamaError('')
+ setOllamaStartTime(Date.now())
+ setOllamaElapsed(0)
+ try {
+ await backendCall('install_ollama')
+ const poll = setInterval(async () => {
+ try {
+ const s: any = await backendCall('install_ollama_status')
+ setOllamaStatus(s.status || '')
+ setOllamaLogs(s.logs || [])
+ setOllamaProgress(s.download_progress || 0)
+ setOllamaTotal(s.download_total || 0)
+ setOllamaSpeed(s.download_speed || 0)
+ if (s.status === 'complete') {
+ clearInterval(poll)
+ setOllamaInstalling(false)
+ setOllamaReady(true)
+ setOllamaStartTime(null)
+ } else if (s.status === 'error') {
+ clearInterval(poll)
+ setOllamaInstalling(false)
+ setOllamaStartTime(null)
+ const lastLog = s.logs?.[s.logs.length - 1] || 'Installation failed'
+ setOllamaError(lastLog)
+ }
+ } catch { /* keep polling */ }
+ }, 1000)
+ } catch (err) {
+ setOllamaInstalling(false)
+ setOllamaStartTime(null)
+ setOllamaError(err instanceof Error ? err.message : 'Installation failed')
+ }
+ }}
+ className={`w-full flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg text-[0.7rem] font-medium transition-all ${
+ isDark ? 'bg-white text-black hover:bg-gray-200' : 'bg-gray-900 text-white hover:bg-gray-800'
+ }`}
+ >
+ <Download size={14} /> Install Ollama
+ </button>
+ )}
+
+ {/* Install progress */}
+ {ollamaInstalling && (
+ <div className={`p-3 rounded-lg border ${cardClass} text-left`}>
+ <div className="flex items-center justify-between mb-2">
+ <div className="flex items-center gap-2">
+ <Loader2 size={14} className="animate-spin text-blue-400" />
+ <span className="text-[0.7rem] font-medium">
+ {ollamaStatus === 'downloading' ? 'Downloading Ollama...' :
+ ollamaStatus === 'installing' ? 'Installing Ollama...' :
+ ollamaStatus === 'starting' ? 'Starting Ollama...' :
+ 'Setting up Ollama...'}
+ </span>
+ </div>
+ <span className={`text-[0.55rem] font-mono ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
+ {Math.floor(ollamaElapsed / 60)}:{String(ollamaElapsed % 60).padStart(2, '0')}
+ </span>
+ </div>
+ {/* Download progress bar */}
+ {ollamaStatus === 'downloading' && ollamaTotal > 0 && (
+ <div className="space-y-1">
+ <ProgressBar progress={(ollamaProgress / ollamaTotal) * 100} />
+ <div className="flex justify-between">
+ <span className={`text-[0.55rem] ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
+ {formatBytes(ollamaProgress)} / {formatBytes(ollamaTotal)}
+ </span>
+ <span className={`text-[0.55rem] ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
+ {ollamaSpeed > 0 ? `${formatBytes(ollamaSpeed)}/s` : ''}
+ </span>
</div>
- <p className={`text-[0.55rem] ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>{b.description}</p>
</div>
- <span className={`text-[0.5rem] font-mono shrink-0 ${isDark ? 'text-gray-600' : 'text-gray-300'}`}>:{b.port}</span>
- </button>
- ))}
- </div>
+ )}
+ {/* Log lines */}
+ <div className={`text-[0.55rem] font-mono mt-1 max-h-16 overflow-y-auto space-y-0.5 ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
+ {ollamaLogs.slice(-4).map((log, i) => (
+ <p key={i}>{log}</p>
+ ))}
+ </div>
+ </div>
+ )}
+
+ {/* Error */}
+ {ollamaError && (
+ <p className="text-[0.65rem] text-red-400">{ollamaError}</p>
+ )}
+
+ {/* Other alternatives collapsed */}
+ {!ollamaInstalling && !ollamaReady && (
+ <details className={`text-left ${isDark ? 'text-gray-400' : 'text-gray-500'}`}>
+ <summary className={`text-[0.6rem] cursor-pointer hover:underline ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
+ Other backends
+ </summary>
+ <div className="space-y-1 mt-2 max-h-[30vh] overflow-y-auto scrollbar-thin pr-1">
+ {LOCAL_BACKENDS.filter(b => b.id !== 'ollama').map(b => (
+ <button
+ key={b.id}
+ onClick={() => openExternal(b.url)}
+ className={`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg border transition-all group text-left ${
+ isDark
+ ? 'border-white/[0.06] hover:border-white/15 hover:bg-white/[0.03]'
+ : 'border-gray-200 hover:border-gray-400 hover:bg-gray-50'
+ }`}
+ >
+ <div className={`w-1.5 h-1.5 rounded-full shrink-0 ${isDark ? 'bg-gray-600' : 'bg-gray-300'}`} />
+ <div className="flex-1 min-w-0">
+ <div className="flex items-center gap-1.5">
+ <p className="text-[0.65rem] font-medium">{b.name}</p>
+ <ExternalLink size={10} className={`opacity-0 group-hover:opacity-100 transition-opacity ${isDark ? 'text-gray-500' : 'text-gray-400'}`} />
+ </div>
+ <p className={`text-[0.5rem] ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>{b.description}</p>
+ </div>
+ </button>
+ ))}
+ </div>
+ </details>
+ )}
<div className="flex items-center justify-center gap-2 pt-1">
- <button onClick={runDetection} className={secondaryBtn}>
- <RefreshCw size={12} /> Re-Scan
- </button>
- <button onClick={() => setStep('comfyui')} className={`${secondaryBtn} opacity-60`}>
- Skip for now <ChevronRight size={12} />
- </button>
+ {!ollamaInstalling && !ollamaReady && (
+ <button onClick={runDetection} className={secondaryBtn}>
+ <RefreshCw size={12} /> Re-Scan
+ </button>
+ )}
+ {(ollamaReady || !ollamaInstalling) && (
+ <button onClick={() => setStep('comfyui')} className={ollamaReady ? primaryBtn : `${secondaryBtn} opacity-60`}>
+ {ollamaReady ? <>Continue <ArrowRight size={14} /></> : <>Skip for now <ChevronRight size={12} /></>}
+ </button>
+ )}
</div>
</>
)}
@@ -411,6 +554,8 @@ export function Onboarding() {
setComfyInstalling(true)
setComfyInstallError('')
setComfyInstallLogs(['Starting ComfyUI installation...'])
+ setInstallStartTime(Date.now())
+ setElapsed(0)
try {
await backendCall('install_comfyui')
// Poll installation status
@@ -418,16 +563,22 @@ export function Onboarding() {
try {
const status: any = await backendCall('install_comfyui_status')
setComfyInstallLogs(status.logs || [])
+ setComfyDownloadProgress(status.download_progress || 0)
+ setComfyDownloadTotal(status.download_total || 0)
+ setComfyDownloadSpeed(status.download_speed || 0)
if (status.status === 'complete' || status.status === 'done') {
clearInterval(poll)
setComfyInstalling(false)
setComfyReady(true)
+ setInstallStartTime(null)
// Auto-start ComfyUI
try { await backendCall('start_comfyui') } catch {}
} else if (status.status === 'error') {
clearInterval(poll)
setComfyInstalling(false)
- setComfyInstallError('Installation failed. Check logs below.')
+ setInstallStartTime(null)
+ const lastLog = status.logs?.[status.logs.length - 1] || 'Installation failed'
+ setComfyInstallError(lastLog)
}
} catch { /* keep polling */ }
}, 2000)
@@ -491,10 +642,29 @@ export function Onboarding() {
{/* Installing progress */}
{comfyInstalling && (
<div className={`p-3 rounded-lg border ${cardClass} text-left`}>
- <div className="flex items-center gap-2 mb-2">
- <Loader2 size={14} className="animate-spin text-purple-400" />
- <span className="text-[0.7rem] font-medium">Installing ComfyUI...</span>
+ <div className="flex items-center justify-between mb-2">
+ <div className="flex items-center gap-2">
+ <Loader2 size={14} className="animate-spin text-purple-400" />
+ <span className="text-[0.7rem] font-medium">Installing ComfyUI...</span>
+ </div>
+ <span className={`text-[0.55rem] font-mono ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
+ {Math.floor(elapsed / 60)}:{String(elapsed % 60).padStart(2, '0')}
+ </span>
</div>
+ {/* Download progress bar (shown during download phase) */}
+ {comfyInstallLogs.some(l => l.includes('Downloading')) && comfyDownloadTotal > 0 && (
+ <div className="space-y-1 mb-2">
+ <ProgressBar progress={comfyDownloadTotal > 0 ? (comfyDownloadProgress / comfyDownloadTotal) * 100 : 0} />
+ <div className="flex justify-between">
+ <span className={`text-[0.55rem] ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
+ {formatBytes(comfyDownloadProgress)} / {formatBytes(comfyDownloadTotal)}
+ </span>
+ <span className={`text-[0.55rem] ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
+ {comfyDownloadSpeed > 0 ? `${formatBytes(comfyDownloadSpeed)}/s` : ''}
+ </span>
+ </div>
+ </div>
+ )}
<div className={`text-[0.55rem] font-mono max-h-24 overflow-y-auto space-y-0.5 ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>
{comfyInstallLogs.slice(-8).map((log, i) => (
<p key={i}>{log}</p>
diff --git a/src/components/settings/ProviderConfig.tsx b/src/components/settings/ProviderConfig.tsx
index 2fff4306..9cff5321 100644
--- a/src/components/settings/ProviderConfig.tsx
+++ b/src/components/settings/ProviderConfig.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react'
+import { useState, useEffect } from 'react'
import { Wifi, WifiOff, Loader2, Eye, EyeOff, ChevronDown, Plus, Power } from 'lucide-react'
import { useProviderStore } from '../../stores/providerStore'
import { useMemoryStore } from '../../stores/memoryStore'
@@ -19,6 +19,23 @@ export function ProviderSettings() {
const autoExtractEnabled = useMemoryStore((s) => s.settings.autoExtractEnabled)
+ // Auto-check connection status for all enabled providers on mount
+ useEffect(() => {
+ const checkAll = async () => {
+ const ids = (Object.keys(providers) as ProviderId[]).filter(id => providers[id].enabled)
+ for (const id of ids) {
+ try {
+ const client = getProvider(id)
+ const ok = await client.checkConnection()
+ setStatuses(prev => ({ ...prev, [id]: ok ? 'connected' : 'failed' }))
+ } catch {
+ setStatuses(prev => ({ ...prev, [id]: 'failed' }))
+ }
+ }
+ }
+ checkAll()
+ }, []) // eslint-disable-line react-hooks/exhaustive-deps
+
// Get all enabled providers
const enabledProviderIds = (Object.keys(providers) as ProviderId[]).filter(id => providers[id].enabled)
@@ -111,7 +128,11 @@ export function ProviderSettings() {
className="flex-1 flex items-center justify-between min-w-0"
>
<div className="flex items-center gap-2 min-w-0">
- <span className="w-1.5 h-1.5 rounded-full bg-green-500 shrink-0" />
+ <span className={`w-1.5 h-1.5 rounded-full shrink-0 ${
+ status === 'connected' ? 'bg-green-500' :
+ status === 'failed' ? 'bg-red-500' :
+ 'bg-gray-500'
+ }`} />
<span className="text-[0.65rem] text-gray-300 font-medium truncate">{preset?.name || config.name}</span>
{config.isLocal && <span className="text-[0.5rem] px-1 py-0.5 rounded bg-green-500/10 text-green-400 shrink-0">LOCAL</span>}
{!config.isLocal && <span className="text-[0.5rem] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 shrink-0">CLOUD</span>}
diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsx
index 874d4ba8..a0394d44 100644
--- a/src/components/settings/SettingsPage.tsx
+++ b/src/components/settings/SettingsPage.tsx
@@ -102,8 +102,13 @@ function WorkflowSection() {
// ── ComfyUI Settings ────────────────────────────────────────────
function ComfyUISettings() {
- const [status, setStatus] = useState<{ running: boolean; found: boolean; path?: string; starting?: boolean } | null>(null)
+ const [status, setStatus] = useState<{ running: boolean; found: boolean; path?: string; port?: number; starting?: boolean } | null>(null)
const [loading, setLoading] = useState(true)
+ const [customPath, setCustomPath] = useState('')
+ const [pathError, setPathError] = useState('')
+ const [pathSuccess, setPathSuccess] = useState(false)
+ const [customPort, setCustomPort] = useState('')
+ const [portSuccess, setPortSuccess] = useState(false)
useEffect(() => {
let cancelled = false
@@ -136,6 +141,21 @@ function ComfyUISettings() {
} catch {}
}
+ const handleSetPath = async () => {
+ if (!customPath.trim()) return
+ setPathError('')
+ setPathSuccess(false)
+ try {
+ const { backendCall } = await import('../../api/backend')
+ await backendCall('set_comfyui_path', { path: customPath.trim() })
+ setPathSuccess(true)
+ setStatus(prev => prev ? { ...prev, found: true, path: customPath.trim() } : { running: false, found: true, path: customPath.trim() })
+ setTimeout(() => setPathSuccess(false), 3000)
+ } catch (err) {
+ setPathError(err instanceof Error ? err.message : 'Invalid path — main.py not found')
+ }
+ }
+
if (loading) {
return <div className="flex items-center gap-2 text-[0.65rem] text-gray-500"><Loader2 size={12} className="animate-spin" /> Checking...</div>
}
@@ -153,13 +173,60 @@ function ComfyUISettings() {
</div>
</div>
- {/* Path */}
- {status?.path && (
- <div className="flex items-center justify-between">
- <span className="text-[0.7rem] text-gray-700 dark:text-gray-400">Path</span>
- <span className="text-[0.55rem] font-mono text-gray-500 truncate max-w-48" title={status.path}>{status.path}</span>
+ {/* Path - editable */}
+ <div className="space-y-1">
+ <span className="text-[0.7rem] text-gray-700 dark:text-gray-400">Path</span>
+ <div className="flex gap-1.5">
+ <input
+ type="text"
+ value={customPath || status?.path || ''}
+ onChange={e => { setCustomPath(e.target.value); setPathError(''); setPathSuccess(false) }}
+ placeholder="C:\ComfyUI"
+ className="flex-1 px-2 py-1 rounded-lg border text-[0.6rem] font-mono bg-transparent border-white/10 text-gray-300 focus:outline-none focus:border-white/25"
+ />
+ <button
+ onClick={handleSetPath}
+ disabled={!customPath.trim() || customPath.trim() === status?.path}
+ className="px-2 py-1 rounded text-[0.6rem] bg-purple-500/10 text-purple-400 hover:bg-purple-500/20 transition-colors disabled:opacity-30"
+ >
+ Connect
+ </button>
+ </div>
+ {pathError && <p className="text-[0.55rem] text-red-400">{pathError}</p>}
+ {pathSuccess && <p className="text-[0.55rem] text-green-400">Path set successfully</p>}
+ </div>
+
+ {/* Port - editable */}
+ <div className="space-y-1">
+ <span className="text-[0.7rem] text-gray-700 dark:text-gray-400">Port</span>
+ <div className="flex gap-1.5">
+ <input
+ type="number"
+ value={customPort || status?.port || 8188}
+ onChange={e => { setCustomPort(e.target.value); setPortSuccess(false) }}
+ placeholder="8188"
+ className="w-24 px-2 py-1 rounded-lg border text-[0.6rem] font-mono bg-transparent border-white/10 text-gray-300 focus:outline-none focus:border-white/25"
+ />
+ <button
+ onClick={async () => {
+ const port = parseInt(customPort)
+ if (!port || port < 1 || port > 65535) return
+ try {
+ const { backendCall, setComfyPort } = await import('../../api/backend')
+ await backendCall('set_comfyui_port', { port })
+ setComfyPort(port)
+ setPortSuccess(true)
+ setTimeout(() => setPortSuccess(false), 3000)
+ } catch {}
+ }}
+ disabled={!customPort || parseInt(customPort) === (status?.port || 8188)}
+ className="px-2 py-1 rounded text-[0.6rem] bg-purple-500/10 text-purple-400 hover:bg-purple-500/20 transition-colors disabled:opacity-30"
+ >
+ Set
+ </button>
</div>
- )}
+ {portSuccess && <p className="text-[0.55rem] text-green-400">Port saved. Restart ComfyUI to apply.</p>}
+ </div>
{/* Controls */}
<div className="flex items-center gap-1.5">