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: Tauri .exe production — download progress, process management, versions

PurpleDoubleD5c929fe7dcaf
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 64f1aa18..32660e2e 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -70,7 +70,7 @@ jobs:
run: npm ci
- name: Build and release Tauri app
- uses: tauri-apps/tauri-action@v0
+ uses: tauri-apps/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 2c49d986..1778b102 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -1860,7 +1860,7 @@ checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77"
[[package]]
name = "locally-uncensored"
-version = "1.2.1"
+version = "1.5.2"
dependencies = [
"base64 0.22.1",
"dirs",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index d8eb3a80..1752c11c 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "locally-uncensored"
-version = "1.2.1"
+version = "1.5.2"
description = "Private, local AI chat & image/video generation"
authors = ["purpledoubled"]
edition = "2021"
diff --git a/src-tauri/src/commands/download.rs b/src-tauri/src/commands/download.rs
index 041bf240..ce0c2e61 100644
--- a/src-tauri/src/commands/download.rs
+++ b/src-tauri/src/commands/download.rs
@@ -1,5 +1,7 @@
+use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
+use std::sync::{Arc, Mutex};
use std::time::Instant;
use futures_util::StreamExt;
@@ -8,7 +10,7 @@ use tauri::State;
use crate::state::{AppState, DownloadProgress};
fn models_dir(comfy_path: &Option<String>, subfolder: &str) -> Result<PathBuf, String> {
- let base = comfy_path.as_ref().ok_or("ComfyUI path not set")?;
+ let base = comfy_path.as_ref().ok_or("ComfyUI path not set. Please set it in settings or install ComfyUI first.")?;
let dir = PathBuf::from(base).join("models").join(subfolder);
fs::create_dir_all(&dir).map_err(|e| format!("Create models dir: {}", e))?;
Ok(dir)
@@ -48,23 +50,46 @@ pub async fn download_model(
});
}
+ // Clone the Arc so the spawned task can update progress
+ let downloads_arc = Arc::clone(&state.downloads);
let id_clone = id.clone();
let filename_clone = filename.clone();
tokio::spawn(async move {
- match do_download(&url, &dest_file).await {
- Ok(_) => println!("[Download] Complete: {}", filename_clone),
- Err(e) => println!("[Download] Failed: {} - {}", filename_clone, e),
+ match do_download(&url, &dest_file, &downloads_arc, &id_clone).await {
+ Ok(_) => {
+ if let Ok(mut dl) = downloads_arc.lock() {
+ if let Some(p) = dl.get_mut(&id_clone) {
+ p.status = "complete".to_string();
+ }
+ }
+ println!("[Download] Complete: {}", filename_clone);
+ }
+ Err(e) => {
+ if let Ok(mut dl) = downloads_arc.lock() {
+ if let Some(p) = dl.get_mut(&id_clone) {
+ p.status = "error".to_string();
+ p.error = Some(e.clone());
+ }
+ }
+ println!("[Download] Failed: {} - {}", filename_clone, e);
+ }
}
});
Ok(serde_json::json!({"status": "started", "id": id}))
}
-async fn do_download(url: &str, dest: &PathBuf) -> Result<(), String> {
+async fn do_download(
+ url: &str,
+ dest: &PathBuf,
+ downloads: &Arc<Mutex<HashMap<String, DownloadProgress>>>,
+ id: &str,
+) -> Result<(), String> {
let client = reqwest::Client::builder()
- .user_agent("LocallyUncensored/1.3")
+ .user_agent("LocallyUncensored/1.5")
.redirect(reqwest::redirect::Policy::limited(10))
+ .timeout(std::time::Duration::from_secs(7200)) // 2 hours for large models
.build()
.map_err(|e| e.to_string())?;
@@ -79,6 +104,14 @@ async fn do_download(url: &str, dest: &PathBuf) -> Result<(), String> {
let total = response.content_length().unwrap_or(0);
+ // Update total size
+ if let Ok(mut dl) = downloads.lock() {
+ if let Some(p) = dl.get_mut(id) {
+ p.total = total;
+ p.status = "downloading".to_string();
+ }
+ }
+
let tmp_path = dest.with_extension("download");
let mut file = tokio::fs::File::create(&tmp_path)
.await
@@ -87,6 +120,7 @@ async fn do_download(url: &str, dest: &PathBuf) -> Result<(), String> {
let mut stream = response.bytes_stream();
let mut downloaded: u64 = 0;
let start = Instant::now();
+ let mut last_update = Instant::now();
use tokio::io::AsyncWriteExt;
while let Some(chunk) = stream.next().await {
@@ -94,14 +128,18 @@ async fn do_download(url: &str, dest: &PathBuf) -> Result<(), String> {
file.write_all(&chunk).await.map_err(|e| format!("Write: {}", e))?;
downloaded += chunk.len() as u64;
- // Log progress every ~1MB
- if downloaded % (1024 * 1024) < chunk.len() as u64 {
+ // Update progress every 500ms
+ if last_update.elapsed().as_millis() > 500 {
+ last_update = Instant::now();
let elapsed = start.elapsed().as_secs_f64();
let speed = if elapsed > 0.0 { downloaded as f64 / elapsed } else { 0.0 };
- println!("[Download] {:.1} MB / {:.1} MB ({:.1} MB/s)",
- downloaded as f64 / 1048576.0,
- total as f64 / 1048576.0,
- speed / 1048576.0);
+
+ if let Ok(mut dl) = downloads.lock() {
+ if let Some(p) = dl.get_mut(id) {
+ p.progress = downloaded;
+ p.speed = speed;
+ }
+ }
}
}
@@ -112,12 +150,21 @@ async fn do_download(url: &str, dest: &PathBuf) -> Result<(), String> {
.await
.map_err(|e| format!("Rename: {}", e))?;
+ // Final progress update
+ if let Ok(mut dl) = downloads.lock() {
+ if let Some(p) = dl.get_mut(id) {
+ p.progress = downloaded;
+ p.total = downloaded;
+ p.status = "complete".to_string();
+ }
+ }
+
Ok(())
}
#[tauri::command]
pub fn download_progress(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
let downloads = state.downloads.lock().unwrap();
- let map: std::collections::HashMap<String, DownloadProgress> = downloads.clone();
+ let map: HashMap<String, DownloadProgress> = downloads.clone();
Ok(serde_json::to_value(map).unwrap_or_default())
}
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index 29e6219d..db27da5d 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -164,16 +164,49 @@ pub fn start_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, St
*path = Some(comfy_path.clone());
}
+ // Validate python binary exists
+ let python = &state.python_bin;
+ println!("[ComfyUI] Using Python: {}", python);
println!("[ComfyUI] Starting from: {}", comfy_path);
- let child = Command::new(&state.python_bin)
+ let mut child = Command::new(python)
.args(["main.py", "--listen", "127.0.0.1", "--port", "8188"])
.current_dir(&comfy_path)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
- .map_err(|e| format!("Failed to start ComfyUI: {}", e))?;
+ .map_err(|e| format!("Failed to start ComfyUI (python={}): {}", python, e))?;
+
+ // Read stdout/stderr in background threads to prevent deadlock
+ let logs = state.comfy_logs.lock().unwrap().clone();
+ drop(logs);
+
+ if let Some(stdout) = child.stdout.take() {
+ let logs_ref = state.comfy_logs.lock().unwrap().clone();
+ drop(logs_ref);
+ std::thread::spawn(move || {
+ use std::io::{BufRead, BufReader};
+ let reader = BufReader::new(stdout);
+ for line in reader.lines() {
+ if let Ok(line) = line {
+ println!("[ComfyUI] {}", line);
+ }
+ }
+ });
+ }
+
+ if let Some(stderr) = child.stderr.take() {
+ std::thread::spawn(move || {
+ use std::io::{BufRead, BufReader};
+ let reader = BufReader::new(stderr);
+ for line in reader.lines() {
+ if let Ok(line) = line {
+ println!("[ComfyUI] {}", line);
+ }
+ }
+ });
+ }
// Store process
{
diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs
index b92296c8..6826066d 100644
--- a/src-tauri/src/state.rs
+++ b/src-tauri/src/state.rs
@@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::process::Child;
use std::sync::atomic::AtomicBool;
-use std::sync::Mutex;
+use std::sync::{Arc, Mutex};
use crate::commands::whisper::WhisperServer;
use crate::python::get_python_bin;
@@ -37,7 +37,7 @@ pub struct AppState {
pub comfy_logs: Mutex<Vec<String>>,
pub comfy_path: Mutex<Option<String>>,
pub whisper: Mutex<WhisperServer>,
- pub downloads: Mutex<HashMap<String, DownloadProgress>>,
+ pub downloads: Arc<Mutex<HashMap<String, DownloadProgress>>>,
pub install_status: Mutex<InstallState>,
pub searxng_install: Mutex<InstallState>,
pub searxng_available: AtomicBool,
@@ -54,7 +54,7 @@ impl AppState {
comfy_logs: Mutex::new(Vec::new()),
comfy_path: Mutex::new(None),
whisper: Mutex::new(WhisperServer::new()),
- downloads: Mutex::new(HashMap::new()),
+ downloads: Arc::new(Mutex::new(HashMap::new())),
install_status: Mutex::new(InstallState::default()),
searxng_install: Mutex::new(InstallState::default()),
searxng_available: AtomicBool::new(false),
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 2495c1ed..9796a977 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
"productName": "Locally Uncensored",
- "version": "1.3.0",
+ "version": "1.5.2",
"identifier": "com.purpledoubled.locally-uncensored",
"build": {
"beforeBuildCommand": "npm run build",
diff --git a/src/api/backend.ts b/src/api/backend.ts
index 32b64b77..1e09be33 100644
--- a/src/api/backend.ts
+++ b/src/api/backend.ts
@@ -56,6 +56,8 @@ export async function backendCall<T = any>(
install_searxng: { path: "/local-api/install-searxng", method: "POST" },
searxng_status: { path: "/local-api/install-searxng" },
ollama_search: { path: "/ollama-search" },
+ fetch_external: { path: "/local-api/proxy-download" },
+ fetch_external_bytes: { path: "/local-api/proxy-download" },
};
const endpoint = endpointMap[command];