From f26a01137d0314ba53e9295175fb36a393500950 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 29 Dec 2025 22:28:59 +0800 Subject: [PATCH] fix(windows): prevent terminal windows from appearing during version check On Windows, opening the Settings > About section would spawn three terminal windows when checking CLI tool versions (claude, codex, gemini). Root cause: - scan_cli_version() directly executed .cmd files, but child processes (node.exe) spawned by these batch scripts didn't inherit CREATE_NO_WINDOW - PATH separator used Unix-style ":" instead of Windows ";" Fix: - Wrap command execution with `cmd /C` to ensure all child processes run within the same hidden console session - Use platform-specific PATH separators via conditional compilation --- src-tauri/src/commands/misc.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/commands/misc.rs b/src-tauri/src/commands/misc.rs index 15e88145f..2f17d91ce 100644 --- a/src-tauri/src/commands/misc.rs +++ b/src-tauri/src/commands/misc.rs @@ -248,12 +248,18 @@ fn scan_cli_version(tool: &str) -> (Option, Option) { if tool_path.exists() { // 构建 PATH 环境变量,确保 node 可被找到 let current_path = std::env::var("PATH").unwrap_or_default(); + + #[cfg(target_os = "windows")] + let new_path = format!("{};{}", path.display(), current_path); + + #[cfg(not(target_os = "windows"))] let new_path = format!("{}:{}", path.display(), current_path); #[cfg(target_os = "windows")] let output = { - Command::new(&tool_path) - .arg("--version") + // 使用 cmd /C 包装执行,确保子进程也在隐藏的控制台中运行 + Command::new("cmd") + .args(["/C", &format!("\"{}\" --version", tool_path.display())]) .env("PATH", &new_path) .creation_flags(CREATE_NO_WINDOW) .output()