diff --git a/app/src-tauri/src/core_process.rs b/app/src-tauri/src/core_process.rs index 9ca67407a..cd6f214a4 100644 --- a/app/src-tauri/src/core_process.rs +++ b/app/src-tauri/src/core_process.rs @@ -25,6 +25,21 @@ fn apply_core_color_env(cmd: &mut Command) { } } +/// Hide the console window that Windows would otherwise allocate for the +/// core sidecar. The core binary is a console-subsystem executable so that +/// `openhuman core run` in a terminal behaves normally, but when the GUI +/// shell spawns it as a child a stray conhost window pops up on top of the +/// app. `CREATE_NO_WINDOW` suppresses that while leaving stdout/stderr +/// piping intact for our log forwarding. +#[cfg(windows)] +fn apply_core_no_window(cmd: &mut Command) { + const CREATE_NO_WINDOW: u32 = 0x0800_0000; + cmd.creation_flags(CREATE_NO_WINDOW); +} + +#[cfg(not(windows))] +fn apply_core_no_window(_cmd: &mut Command) {} + #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum CoreRunMode { InProcess, @@ -142,6 +157,7 @@ impl CoreProcessHandle { cmd }; apply_core_color_env(&mut cmd); + apply_core_no_window(&mut cmd); let child = cmd .spawn() .map_err(|e| format!("failed to spawn core process: {e}"))?; @@ -180,6 +196,7 @@ impl CoreProcessHandle { }; apply_core_color_env(&mut cmd); + apply_core_no_window(&mut cmd); let child = cmd .spawn() .map_err(|e| format!("failed to spawn core process: {e}"))?; diff --git a/app/src-tauri/src/lib.rs b/app/src-tauri/src/lib.rs index 1a6d8e5f3..84360ab1b 100644 --- a/app/src-tauri/src/lib.rs +++ b/app/src-tauri/src/lib.rs @@ -222,6 +222,13 @@ async fn run_core_cli(args: Vec) -> Result { } cmd.args(&args); + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + const CREATE_NO_WINDOW: u32 = 0x0800_0000; + cmd.creation_flags(CREATE_NO_WINDOW); + } + log::info!( "[service-direct] running {:?} {}{}", bin,