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 tts/whisper/agent/video python spawns through python_command (K14 Punkt 5)
purpleca3229aadd0c
diff --git a/src-tauri/src/commands/agent.rs b/src-tauri/src/commands/agent.rsindex 0dda977b..f2d64a87 100644--- a/src-tauri/src/commands/agent.rs+++ b/src-tauri/src/commands/agent.rs@@ -1,18 +1,12 @@use crate::os_error;use std::fs;use std::path::PathBuf;-use std::process::{Command, Stdio};--#[cfg(target_os = "windows")]-use std::os::windows::process::CommandExt;+use std::process::Stdio;use tauri::{AppHandle, Manager, State};use crate::state::AppState;-#[cfg(target_os = "windows")]-const CREATE_NO_WINDOW: u32 = 0x08000000;-/// Base directory for all agent workspaces. Per-chat subfolders are/// created lazily by `agent_workspace(chat_id)` on the first write.fn agent_workspace_root() -> PathBuf {@@ -459,14 +453,12 @@ pub(crate) fn execute_code_blocking(.to_string(),);}- let mut cmd = Command::new(&python_bin);+ let mut cmd = crate::python::python_command(&python_bin);cmd.arg(&script_path).current_dir(&workspace).stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped());- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);let mut child = cmd.spawn().map_err(|e| format!("Spawn Python: {}", os_error::english(&e)))?;diff --git a/src-tauri/src/commands/tts.rs b/src-tauri/src/commands/tts.rsindex 089d3e25..a826e3c9 100644--- a/src-tauri/src/commands/tts.rs+++ b/src-tauri/src/commands/tts.rs@@ -11,19 +11,13 @@use crate::os_error;use std::io::Write;use std::path::PathBuf;-use std::process::{Command, Stdio};--#[cfg(target_os = "windows")]-use std::os::windows::process::CommandExt;+use std::process::Stdio;use base64::Engine;use tauri::{Manager, State};use crate::state::AppState;-#[cfg(target_os = "windows")]-const CREATE_NO_WINDOW: u32 = 0x08000000;-/// The default Piper voice LU downloads + speaks with. Medium-quality English,/// ~63 MB. Files land in `<app_data>/piper_voices/`.pub const PIPER_VOICE: &str = "en_US-lessac-medium";@@ -86,7 +80,7 @@ pub fn tts_status(let mut piper_importable = false;if !python.is_empty() && crate::python::is_real_python(&python) {- let mut cmd = Command::new(&python);+ let mut cmd = crate::python::python_command(&python);// find_spec, not a full `import piper`, so the badge stays a cheap// installability check that can't stall on a heavy import (mirrors// whisper_package_installed — see #78).@@ -96,8 +90,6 @@ pub fn tts_status(]).stdout(Stdio::null()).stderr(Stdio::null());- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);piper_importable = cmd.output().map(|o| o.status.success()).unwrap_or(false);}@@ -184,7 +176,7 @@ fn download_voice_blocking(let dir = piper_voices_dir(&app)?;let _ = std::fs::create_dir_all(&dir);- let mut cmd = Command::new(&python);+ let mut cmd = crate::python::python_command(&python);cmd.args(["-m","piper.download_voices",@@ -194,8 +186,6 @@ fn download_voice_blocking(]).stdout(Stdio::piped()).stderr(Stdio::piped());- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);let output = cmd.output().map_err(|e| format!("could not start voice download: {}", os_error::english(&e)))?;if !output.status.success() {@@ -275,7 +265,7 @@ fn synthesize_blocking(.unwrap_or(0);let out_wav = std::env::temp_dir().join(format!("lu-tts-{}.wav", stamp));- let mut cmd = Command::new(&python);+ let mut cmd = crate::python::python_command(&python);cmd.args(["-m","piper",@@ -289,8 +279,6 @@ fn synthesize_blocking(.stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::piped());- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);let mut child = cmd.spawn().map_err(|e| format!("Failed to start piper: {}", os_error::english(&e)))?;// Feed stdin from its own thread. Writing the whole text inline and onlydiff --git a/src-tauri/src/commands/video.rs b/src-tauri/src/commands/video.rsindex 9d69b7e6..85ce5130 100644--- a/src-tauri/src/commands/video.rs+++ b/src-tauri/src/commands/video.rs@@ -244,7 +244,7 @@ fn python_for(state: &AppState) -> Option<String> {}fn mlx_video_installed(python: &str) -> bool {- Command::new(python)+ crate::python::python_command(python).args(["-c", "import mlx_video"]).stdout(Stdio::null()).stderr(Stdio::null())@@ -254,7 +254,7 @@ fn mlx_video_installed(python: &str) -> bool {}fn python_has_module(python: &str, module: &str) -> bool {- Command::new(python)+ crate::python::python_command(python).args(["-c", &format!("import {module}")]).stdout(Stdio::null()).stderr(Stdio::null())@@ -278,7 +278,7 @@ pub(crate) fn ensure_python_module(return Ok(());}slot.log(format!("installing {pip_spec} (one-time)"));- let mut cmd = Command::new(python);+ let mut cmd = crate::python::python_command(python);cmd.args(["-m", "pip", "install", "--upgrade", pip_spec]);run_streamed(slot, &mut cmd).map_err(|e| format!("pip install {pip_spec}: {e}"))?;@@ -291,7 +291,7 @@ pub(crate) fn ensure_python_module(}fn mlx_video_version(python: &str) -> Option<String> {- let out = Command::new(python)+ let out = crate::python::python_command(python).args(["-c","import importlib.metadata as m; print(m.version('mlx-video'))",@@ -407,7 +407,7 @@ pub fn video_install_mlx(state: &AppState, _args: &Value) -> CmdResult {slot.start();let slot2 = slot.clone();std::thread::spawn(move || {- let mut cmd = Command::new(&python);+ let mut cmd = crate::python::python_command(&python);cmd.args(["-m","pip",@@ -532,7 +532,7 @@ fn install_model_steps(r = entry.repo,t = download_to.to_string_lossy(),);- let mut cmd = Command::new(python);+ let mut cmd = crate::python::python_command(python);cmd.args(["-c", &script]).env("HF_HOME", hf_home_dir()).env("HF_XET_CACHE", hf_home_dir().join("xet"));@@ -548,7 +548,7 @@ fn install_model_steps(let out_dir = weights_dir(entry);slot.log(format!("converting {} to MLX (one-time)", entry.name));- let mut convert = Command::new(python);+ let mut convert = crate::python::python_command(python);convert.arg("-m").arg("mlx_video.models.wan_2.convert")@@ -642,7 +642,7 @@ pub fn video_generate(state: &AppState, args: &Value) -> CmdResult {// Blaizzy/mlx-video):// ltx_2 → --model-repo <dir> --pipeline <p> -o <out> -n <frames>// wan_2 → --model-dir <dir> --num-frames (4n+1) --output-path <out>- let mut cmd = Command::new(&python);+ let mut cmd = crate::python::python_command(&python);cmd.arg("-m").arg(format!("mlx_video.models.{}.generate", entry.family)).arg("--prompt")diff --git a/src-tauri/src/commands/whisper.rs b/src-tauri/src/commands/whisper.rsindex d2de0295..1001b558 100644--- a/src-tauri/src/commands/whisper.rs+++ b/src-tauri/src/commands/whisper.rs@@ -1,21 +1,15 @@use crate::os_error;use std::io::{BufRead, BufReader, Write};-use std::process::{Child, Command, Stdio};+use std::process::{Child, Stdio};use std::sync::{mpsc, Arc, Mutex};use std::path::PathBuf;-#[cfg(target_os = "windows")]-use std::os::windows::process::CommandExt;-use base64::Engine;use tauri::{AppHandle, Manager, State};use tracing::{error, info};use crate::state::AppState;-#[cfg(target_os = "windows")]-const CREATE_NO_WINDOW: u32 = 0x08000000;-pub struct WhisperServer {process: Option<Child>,stdin_tx: Option<std::io::BufWriter<std::process::ChildStdin>>,@@ -90,13 +84,11 @@ impl WhisperServer {println!("[Whisper] Starting persistent server: {} {}", python_bin, script_path);- let mut cmd = Command::new(python_bin);+ let mut cmd = crate::python::python_command(python_bin);cmd.arg(script_path).stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::piped());- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);let mut child = cmd.spawn().map_err(|e| format!("Failed to start whisper server: {}", os_error::english(&e)))?;// Long lived Python server: it must not outlive the app on a hard kill.@@ -295,7 +287,7 @@ fn whisper_package_installed(state: &AppState) -> bool {if python.is_empty() {return false;}- let mut cmd = Command::new(&python);+ let mut cmd = crate::python::python_command(&python);// Probe INSTALLABILITY with importlib.find_spec, NOT a full// `import faster_whisper`. The real import pulls in ctranslate2 / onnxruntime// / av and takes ~8 s warm (longer with a cold OS file cache), which on the@@ -310,8 +302,6 @@ fn whisper_package_installed(state: &AppState) -> bool {.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);let mut child = match cmd.spawn() {Ok(c) => c,Err(_) => return false,@@ -522,10 +512,8 @@ pub fn auto_start_whisper_sync(whisper: &Arc<Mutex<WhisperServer>>,) -> Result<(), String> {// Check if faster-whisper is installed- let mut cmd = Command::new(python_bin);+ let mut cmd = crate::python::python_command(python_bin);cmd.args(["-c", "import faster_whisper"]);- #[cfg(target_os = "windows")]- cmd.creation_flags(CREATE_NO_WINDOW);let check = cmd.output();match check {@@ -636,6 +624,7 @@ mod response_channel_tests {mod dead_server_tests {use super::*;use serde_json::json;+ use std::process::Command;/// A child that is gone almost at once.fn spawn_quick() -> Child {