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(process): route LM Studio and Ollama installer/CLI spawns through foreign_system_command (K14 Punkt 5)
purpledaf8d8660ffb
diff --git a/src-tauri/src/commands/install/lmstudio.rs b/src-tauri/src/commands/install/lmstudio.rsindex 4e1f5015..95ed850a 100644--- a/src-tauri/src/commands/install/lmstudio.rs+++ b/src-tauri/src/commands/install/lmstudio.rs@@ -17,16 +17,10 @@//! des eingefrorenen Fensters, nicht die Anfrage selbst.use std::path::{Path, PathBuf};-use std::process::{Command, Stdio};--#[cfg(target_os = "windows")]-use std::os::windows::process::CommandExt;+use std::process::Stdio;use crate::os_error;-#[cfg(target_os = "windows")]-use super::CREATE_NO_WINDOW;-pub(super) const LMSTUDIO_DEFAULT_PORT: u16 = 1234;pub(crate) fn lmstudio_lms_path() -> Option<PathBuf> {@@ -100,10 +94,9 @@ pub(crate) fn lmstudio_lms_path() -> Option<PathBuf> {// Last resort: PATH lookup. Catches non-standard installs (Chocolatey,// user-relocated install dir, etc.). CREATE_NO_WINDOW so this `where` probe// never flashes a console window at the end user.- let mut where_cmd = Command::new("where");+ let mut where_cmd = crate::process_util::foreign_system_command("where");where_cmd.arg("lms");- #[cfg(target_os = "windows")]- where_cmd.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut where_cmd);if let Ok(out) = where_cmd.output() {if out.status.success() {let s = String::from_utf8_lossy(&out.stdout);@@ -303,13 +296,12 @@ fn start_lmstudio_server_blocking() -> Result<serde_json::Value, String> {}match lmstudio_lms_path() {Some(p) => {- let mut srv = Command::new(&p);+ let mut srv = crate::process_util::foreign_system_command(&p);srv.args(["server", "start", "--cors", "--port"]).arg(LMSTUDIO_DEFAULT_PORT.to_string()).stdout(Stdio::null()).stderr(Stdio::null());- #[cfg(target_os = "windows")]- srv.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut srv);srv.spawn().map_err(|e| format!("spawn lms: {}", os_error::english(&e)))?;Ok(serde_json::json!({"status": "starting"}))@@ -442,10 +434,9 @@ fn lmstudio_load_model_blocking(model: String, contextLength: Option<u32>) -> Re// Hide the console window the `lms` CLI would otherwise flash on// Windows (CREATE_NO_WINDOW) — these run during normal model// switching / the VRAM hand-off, not just at install time.- let mut unload = Command::new(&lms);+ let mut unload = crate::process_util::foreign_system_command(&lms);unload.args(["unload", &model]);- #[cfg(target_os = "windows")]- unload.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut unload);let _ = unload.output();}let ctx = contextLength.unwrap_or(0);@@ -455,10 +446,9 @@ fn lmstudio_load_model_blocking(model: String, contextLength: Option<u32>) -> Reargs.push("-c");args.push(ctx_str.as_str());}- let mut cmd = Command::new(&lms);+ let mut cmd = crate::process_util::foreign_system_command(&lms);cmd.args(&args);- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut cmd);let output = cmd.output().map_err(|e| format!("spawn lms load: {}", os_error::english(&e)))?;@@ -549,10 +539,9 @@ pub async fn lmstudio_unload_model(model: String) -> Result<serde_json::Value, Sfn 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);+ let mut cmd = crate::process_util::foreign_system_command(&lms);cmd.args(["unload", &model]);- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut cmd);let output = cmd.output().map_err(|e| format!("spawn lms unload: {}", os_error::english(&e)))?;diff --git a/src-tauri/src/commands/install/lmstudio_install.rs b/src-tauri/src/commands/install/lmstudio_install.rsindex 5b4923a2..b1b93a98 100644--- a/src-tauri/src/commands/install/lmstudio_install.rs+++ b/src-tauri/src/commands/install/lmstudio_install.rs@@ -17,10 +17,7 @@//! Studio einmal von Hand öffnen und den Server-Schalter umlegen.use std::fs;-use std::process::{Command, Stdio};--#[cfg(target_os = "windows")]-use std::os::windows::process::CommandExt;+use std::process::Stdio;use tauri::State;@@ -30,8 +27,6 @@ use crate::state::AppState;use super::download::{download_file_blocking, verify_downloaded_installer};use super::lmstudio::{lmstudio_gui_exe, lmstudio_lms_path, lmstudio_server_running,LMSTUDIO_DEFAULT_PORT};-#[cfg(target_os = "windows")]-use super::CREATE_NO_WINDOW;/// SHA-256 of the LM Studio installer at [`LMSTUDIO_INSTALLER_URL`].///@@ -271,10 +266,9 @@ pub fn install_lmstudio(state: State<'_, AppState>) -> Result<serde_json::Value,// electron-builder NSIS supports /S for silent install. Ignore exit// code: real failures surface via the absence of lms.exe afterwards.- let mut cmd = Command::new(&installer_path);+ let mut cmd = crate::process_util::foreign_system_command(&installer_path);cmd.arg("/S");- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut cmd);match cmd.output() {Ok(_) => println!("[LMStudio] Installer finished"),Err(e) => {@@ -305,10 +299,9 @@ pub fn install_lmstudio(state: State<'_, AppState>) -> Result<serde_json::Value,let initial_lms = lmstudio_lms_path();match &initial_lms {Some(p) => {- let mut bs = Command::new(p);+ let mut bs = crate::process_util::foreign_system_command(p);bs.arg("bootstrap");- #[cfg(target_os = "windows")]- bs.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut bs);let _ = bs.output();}None => {@@ -338,9 +331,8 @@ pub fn install_lmstudio(state: State<'_, AppState>) -> Result<serde_json::Value,"Launching LM Studio briefly to finalise CLI setup (you may see the window flash)...",);if let Some(gui) = lmstudio_gui_exe() {- let mut g = Command::new(&gui);- #[cfg(target_os = "windows")]- g.creation_flags(CREATE_NO_WINDOW);+ let mut g = crate::process_util::foreign_system_command(&gui);+ crate::process_util::suppress_window(&mut g);let _ = g.spawn();}@@ -361,10 +353,9 @@ pub fn install_lmstudio(state: State<'_, AppState>) -> Result<serde_json::Value,// After GUI launch the .lmstudio dir might already contain a// launcher; if not, the pre-bootstrap path is still valid.if let Some(p) = lmstudio_lms_path() {- let mut bs = Command::new(&p);+ let mut bs = crate::process_util::foreign_system_command(&p);bs.arg("bootstrap");- #[cfg(target_os = "windows")]- bs.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut bs);let _ = bs.output();}}@@ -377,13 +368,12 @@ pub fn install_lmstudio(state: State<'_, AppState>) -> Result<serde_json::Value,// promoted us from the pre-bootstrap path to ~/.lmstudio/bin/lms.exe.update("starting", "Starting LM Studio server on port 1234...");if let Some(p) = lmstudio_lms_path() {- let mut srv = Command::new(&p);+ let mut srv = crate::process_util::foreign_system_command(&p);srv.args(["server", "start", "--cors", "--port"]).arg(LMSTUDIO_DEFAULT_PORT.to_string()).stdout(Stdio::null()).stderr(Stdio::null());- #[cfg(target_os = "windows")]- srv.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut srv);let _ = srv.spawn();}diff --git a/src-tauri/src/commands/install/ollama.rs b/src-tauri/src/commands/install/ollama.rsindex c50a7086..071bad4e 100644--- a/src-tauri/src/commands/install/ollama.rs+++ b/src-tauri/src/commands/install/ollama.rs@@ -181,9 +181,9 @@ fn install_ollama_windows_impl<F: Fn(&str, &str)>(return;}update("installing", "Download complete. Installing Ollama...");- let mut cmd = Command::new(&installer_path);+ let mut cmd = crate::process_util::foreign_system_command(&installer_path);cmd.arg("/S");- cmd.creation_flags(CREATE_NO_WINDOW);+ crate::process_util::suppress_window(&mut cmd);match cmd.output() {Ok(o) => {let code = o.status.code().unwrap_or(-1);