The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(rust): six commands froze the window while they waited
Davided1cc49847cb
diff --git a/src-tauri/src/commands/claude_code.rs b/src-tauri/src/commands/claude_code.rsindex 9e9d7eb6..16cd90a5 100644--- a/src-tauri/src/commands/claude_code.rs+++ b/src-tauri/src/commands/claude_code.rs@@ -14,8 +14,17 @@ const CREATE_NO_WINDOW: u32 = 0x08000000;// ── Detect Claude Code CLI ────────────────────────────────────────────────+// ASYNC + spawn_blocking: a SYNCHRONOUS Tauri command runs on the MAIN thread,+// so every millisecond spent here is a frozen window. Same treatment+// `lmstudio_server_status` already got — this one was simply missed.#[tauri::command]-pub fn detect_claude_code() -> Result<serde_json::Value, String> {+pub async fn detect_claude_code() -> Result<serde_json::Value, String> {+ tokio::task::spawn_blocking(detect_claude_code_blocking)+ .await+ .map_err(|e| format!("detect_claude_code task: {e}"))?+}++fn detect_claude_code_blocking() -> Result<serde_json::Value, String> {let mut cmd = Command::new("claude");cmd.args(["--version"]).stdout(Stdio::piped())diff --git a/src-tauri/src/commands/install.rs b/src-tauri/src/commands/install.rsindex 97967621..6ea4ca56 100644--- a/src-tauri/src/commands/install.rs+++ b/src-tauri/src/commands/install.rs@@ -1250,8 +1250,23 @@ fn git_download_url() -> &'static str {}/// Cross-platform git availability check for the Codex view's install banner.+// ASYNC + spawn_blocking: a SYNCHRONOUS Tauri command runs on the MAIN thread,+// so every millisecond spent here is a frozen window. Same treatment+// `lmstudio_server_status` already got — this one was simply missed.#[tauri::command]-pub fn check_git_installed() -> GitStatus {+pub async fn check_git_installed() -> GitStatus {+ tokio::task::spawn_blocking(check_git_installed_blocking)+ .await+ .unwrap_or_else(|e| GitStatus {+ installed: false,+ native: false,+ version: None,+ hint: Some(format!("git probe task failed: {e}")),+ download_url: git_download_url().to_string(),+ })+}++fn check_git_installed_blocking() -> GitStatus {let download_url = git_download_url().to_string();let version = git_version_string();@@ -1985,8 +2000,17 @@ pub fn install_lmstudio_status(state: State<'_, AppState>) -> Result<serde_json:/// Best-effort: spawn `lms server start` so we don't make the user open the/// LM Studio GUI just to flip the Server toggle. Idempotent — quick early-exit/// if the server is already responding.+// ASYNC + spawn_blocking: a SYNCHRONOUS Tauri command runs on the MAIN thread,+// so every millisecond spent here is a frozen window. Same treatment+// `lmstudio_server_status` already got — this one was simply missed.#[tauri::command]-pub fn start_lmstudio_server() -> Result<serde_json::Value, String> {+pub async fn start_lmstudio_server() -> Result<serde_json::Value, String> {+ tokio::task::spawn_blocking(start_lmstudio_server_blocking)+ .await+ .map_err(|e| format!("start_lmstudio_server task: {e}"))?+}++fn start_lmstudio_server_blocking() -> Result<serde_json::Value, String> {if lmstudio_server_running() {return Ok(serde_json::json!({"status": "already_running"}));}@@ -2091,9 +2115,19 @@ pub async fn lmstudio_list_loaded() -> Result<serde_json::Value, String> {.map_err(|e| format!("lmstudio_list_loaded task: {e}"))?}-#[allow(non_snake_case)]+// ASYNC + spawn_blocking: a SYNCHRONOUS Tauri command runs on the MAIN thread,+// so every millisecond spent here is a frozen window. Same treatment+// `lmstudio_server_status` already got — this one was simply missed.#[tauri::command]-pub fn lmstudio_load_model(model: String, contextLength: Option<u32>) -> Result<serde_json::Value, String> {+#[allow(non_snake_case)]+pub async fn lmstudio_load_model(model: String, contextLength: Option<u32>) -> Result<serde_json::Value, String> {+ tokio::task::spawn_blocking(move || lmstudio_load_model_blocking(model, contextLength))+ .await+ .map_err(|e| format!("lmstudio_load_model task: {e}"))?+}++#[allow(non_snake_case)]+fn lmstudio_load_model_blocking(model: String, contextLength: Option<u32>) -> Result<serde_json::Value, String> {let lms = lmstudio_lms_path().ok_or_else(|| "lms CLI not found — install LM Studio first".to_string())?;// `lms load` blocks until the model is in memory. The caller is expected@@ -2215,8 +2249,17 @@ pub async fn lmstudio_model_context(model: String) -> Result<serde_json::Value,.map_err(|e| format!("lmstudio_model_context task: {e}"))?}+// ASYNC + spawn_blocking: a SYNCHRONOUS Tauri command runs on the MAIN thread,+// so every millisecond spent here is a frozen window. Same treatment+// `lmstudio_server_status` already got — this one was simply missed.#[tauri::command]-pub fn lmstudio_unload_model(model: String) -> Result<serde_json::Value, String> {+pub async fn lmstudio_unload_model(model: String) -> Result<serde_json::Value, String> {+ tokio::task::spawn_blocking(move || lmstudio_unload_model_blocking(model))+ .await+ .map_err(|e| format!("lmstudio_unload_model task: {e}"))?+}++fn lmstudio_unload_model_blocking(model: String) -> Result<serde_json::Value, String> {let lms = lmstudio_lms_path().ok_or_else(|| "lms CLI not found".to_string())?;let mut cmd = Command::new(&lms);diff --git a/src-tauri/src/commands/remote.rs b/src-tauri/src/commands/remote.rsindex 66621ad6..c452e348 100644--- a/src-tauri/src/commands/remote.rs+++ b/src-tauri/src/commands/remote.rs@@ -742,7 +742,7 @@ async fn handle_agent_tool(}"system_info" => crate::commands::system::system_info(),"process_list" => crate::commands::system::process_list(),- "screenshot" => crate::commands::system::screenshot(),+ "screenshot" => crate::commands::system::screenshot().await,"get_current_time" => crate::commands::system::get_current_time(),"image_generate" => {// Image generation requires the desktop Agent path — too muchdiff --git a/src-tauri/src/commands/system.rs b/src-tauri/src/commands/system.rsindex 143b8624..53c064ac 100644--- a/src-tauri/src/commands/system.rs+++ b/src-tauri/src/commands/system.rs@@ -52,8 +52,17 @@ pub fn process_list() -> Result<serde_json::Value, String> {Ok(serde_json::json!({ "processes": processes, "count": processes.len() }))}+// ASYNC + spawn_blocking: a SYNCHRONOUS Tauri command runs on the MAIN thread,+// so every millisecond spent here is a frozen window. Same treatment+// `lmstudio_server_status` already got — this one was simply missed.#[tauri::command]-pub fn screenshot() -> Result<serde_json::Value, String> {+pub async fn screenshot() -> Result<serde_json::Value, String> {+ tokio::task::spawn_blocking(screenshot_blocking)+ .await+ .map_err(|e| format!("screenshot task: {e}"))?+}++fn screenshot_blocking() -> Result<serde_json::Value, String> {// Use PowerShell to capture screen on Windows#[cfg(target_os = "windows")]{