From c077b3ff644a16366d05f71e32a674c83ff101a4 Mon Sep 17 00:00:00 2001 From: raymond <13162938362@163.com> Date: Sat, 25 Jul 2026 10:52:39 +0800 Subject: [PATCH] fix(windows): suppress console flash on child process spawns Three console-subsystem child processes were spawned without the Windows CREATE_NO_WINDOW flag, each flashing a terminal window when launched from the GUI host (which has no console of its own): - whoami in app-paths::current_windows_account_for_acl (hit on every sensitive-file write: key save, token refresh, first-launch install_id) - bundled Peekaboo CLI in agent-core (screenshot/accessibility tool) - taskkill in benchmark::process::terminate_process Each site now mirrors the existing guarded pattern in its own file. Pre-commit hook ran. Total eslint: 0, total circular: 0 --- .../tools/impls/desktop/peekaboo_cli_tool.rs | 5 +++++ src-tauri/crates/app-paths/src/lib.rs | 8 +++++--- src-tauri/src/benchmark/process.rs | 17 ++++++++++------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src-tauri/crates/agent-core/src/core/tools/impls/desktop/peekaboo_cli_tool.rs b/src-tauri/crates/agent-core/src/core/tools/impls/desktop/peekaboo_cli_tool.rs index ad0e39884..4c4198d40 100644 --- a/src-tauri/crates/agent-core/src/core/tools/impls/desktop/peekaboo_cli_tool.rs +++ b/src-tauri/crates/agent-core/src/core/tools/impls/desktop/peekaboo_cli_tool.rs @@ -587,6 +587,11 @@ async fn run_peekaboo_cli_command( #[cfg(unix)] command.process_group(0); + // Suppress the console window the bundled Peekaboo CLI would otherwise + // flash on Windows (it is spawned without a parent console). + #[cfg(windows)] + command.creation_flags(app_platform::CREATE_NO_WINDOW); + let child = command .spawn() .map_err(|err| format!("Failed to run bundled Peekaboo CLI: {}", err))?; diff --git a/src-tauri/crates/app-paths/src/lib.rs b/src-tauri/crates/app-paths/src/lib.rs index 24d8f84ff..bfb6f15c8 100644 --- a/src-tauri/crates/app-paths/src/lib.rs +++ b/src-tauri/crates/app-paths/src/lib.rs @@ -876,9 +876,11 @@ pub fn set_sensitive_file_permissions(path: &Path) -> std::io::Result<()> { #[cfg(windows)] fn current_windows_account_for_acl() -> Option { - let whoami = std::process::Command::new("whoami") - .stdin(Stdio::null()) - .stderr(Stdio::null()) + let mut cmd = std::process::Command::new("whoami"); + cmd.stdin(Stdio::null()).stderr(Stdio::null()); + // Suppress console window on Windows. + app_platform::hide_console(&mut cmd); + let whoami = cmd .output() .ok() .and_then(|output| { diff --git a/src-tauri/src/benchmark/process.rs b/src-tauri/src/benchmark/process.rs index 8c21a5c54..c22aeb94b 100644 --- a/src-tauri/src/benchmark/process.rs +++ b/src-tauri/src/benchmark/process.rs @@ -199,13 +199,16 @@ pub(super) async fn terminate_process(process_id: u32) -> Result<(), String> { .await; #[cfg(windows)] - let output = Command::new("taskkill") - .arg("/PID") - .arg(process_id.to_string()) - .arg("/T") - .arg("/F") - .output() - .await; + let output = { + let mut cmd = Command::new("taskkill"); + cmd.arg("/PID") + .arg(process_id.to_string()) + .arg("/T") + .arg("/F"); + // Suppress the console window on Windows. + cmd.creation_flags(app_platform::CREATE_NO_WINDOW); + cmd.output().await + }; let output = output.map_err(|error| format!("Failed to terminate process {process_id}: {error}"))?;