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(windows): no terminal window flash when killing subprocesses

PurpleDoubleD67d6dd8ac387
diff --git a/src-tauri/src/commands/search.rs b/src-tauri/src/commands/search.rs
index 08c93151..79f7e487 100644
--- a/src-tauri/src/commands/search.rs
+++ b/src-tauri/src/commands/search.rs
@@ -219,22 +219,37 @@ pub fn install_searxng(state: State<'_, AppState>) -> Result<serde_json::Value,
install.logs.push("Pulling SearXNG Docker image...".to_string());
drop(install);
- // Run docker pull + run in background
+ // Run docker pull + run in background.
+ // On Windows we add CREATE_NO_WINDOW so the docker CLI doesn't flash a
+ // console window at the user when they install SearXNG from LU.
std::thread::spawn(move || {
- let pull = std::process::Command::new("docker")
- .args(["pull", "searxng/searxng"])
- .output();
+ #[cfg(windows)]
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+
+ let mut pull_cmd = std::process::Command::new("docker");
+ pull_cmd.args(["pull", "searxng/searxng"]);
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ pull_cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+ let pull = pull_cmd.output();
match pull {
Ok(output) if output.status.success() => {
- let _ = std::process::Command::new("docker")
- .args([
- "run", "-d", "--name", "searxng",
- "-p", "8888:8080",
- "-e", "INSTANCE_NAME=locally-uncensored",
- "searxng/searxng",
- ])
- .output();
+ let mut run_cmd = std::process::Command::new("docker");
+ run_cmd.args([
+ "run", "-d", "--name", "searxng",
+ "-p", "8888:8080",
+ "-e", "INSTANCE_NAME=locally-uncensored",
+ "searxng/searxng",
+ ]);
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ run_cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+ let _ = run_cmd.output();
println!("[SearXNG] Installed and running on port 8888");
}
_ => {
diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs
index 7efb9493..d19dfdec 100644
--- a/src-tauri/src/state.rs
+++ b/src-tauri/src/state.rs
@@ -88,6 +88,12 @@ impl AppState {
}
}
+// On Windows, spawn child processes without flashing a console window.
+// Applied to every taskkill/kill call so LU's process lifecycle stays invisible
+// to the user. 0x08000000 = CREATE_NO_WINDOW.
+#[cfg(windows)]
+const CREATE_NO_WINDOW: u32 = 0x08000000;
+
impl Drop for AppState {
fn drop(&mut self) {
// Kill ComfyUI process tree
@@ -95,12 +101,18 @@ impl Drop for AppState {
if let Some(ref mut child) = *proc {
{
let pid = child.id();
- if cfg!(target_os = "windows") {
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
let _ = std::process::Command::new("taskkill")
.args(["/pid", &pid.to_string(), "/T", "/F"])
+ .creation_flags(CREATE_NO_WINDOW)
.output();
- } else {
+ }
+ #[cfg(not(windows))]
+ {
let _ = child.kill();
+ let _ = pid; // silence unused on non-Windows
}
}
println!("[ComfyUI] Stopped");
@@ -111,12 +123,18 @@ impl Drop for AppState {
if let Ok(mut proc) = self.claude_code_process.lock() {
if let Some(ref mut child) = *proc {
let pid = child.id();
- if cfg!(target_os = "windows") {
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
let _ = std::process::Command::new("taskkill")
.args(["/pid", &pid.to_string(), "/T", "/F"])
+ .creation_flags(CREATE_NO_WINDOW)
.output();
- } else {
+ }
+ #[cfg(not(windows))]
+ {
let _ = child.kill();
+ let _ = pid;
}
println!("[ClaudeCode] Stopped");
}