fix(windows): stop console windows flashing on every host spawn#115
Merged
Conversation
CLAI's desktop binary is a GUI-subsystem app, so every console-subsystem
child it spawns makes CreateProcessW allocate a new visible console: the
startup which/where probes, editor/terminal detection, .cmd editor shims,
explorer.exe file-open, provider CLI sessions, stdio MCP servers, git for
skill sources, taskkill tree-kills and bash_exec children all flashed a
console window on Windows.
Add a HideConsoleWindow trait (CREATE_NO_WINDOW on Windows, no-op
elsewhere) for std and tokio Commands and apply it at every spawn site
except terminal launches, where the visible console IS the product
(cmd/PowerShell fallbacks); spawn_host_detached now takes an explicit
HostWindow::{Hidden,Visible} so that decision is typed at the call site.
juacker
marked this pull request as ready for review
July 22, 2026 22:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, every host process CLAI spawns briefly flashes a console window: the startup
which/whereprovider probes (two flashes per cold boot), editor/terminal detection, opening a file with the system default app (explorer.exe), opening an editor (.cmdshims likecode.cmd), thewherePATHEXT resolution, provider CLI sessions, stdio MCP servers, git for skill sources,taskkilltree-kills, andbash_execchildren.Root cause: CLAI's desktop binary is a GUI-subsystem app with no console of its own, so
CreateProcessWallocates a brand-new visible console for every console-subsystem child unless the spawn passesCREATE_NO_WINDOW.Fix
src-tauri/src/windows_console.rs:HideConsoleWindowtrait withhide_console_window()forstd::process::Commandandtokio::process::Command— appliescreation_flags(CREATE_NO_WINDOW)on Windows, no-op elsewhere, so call sites stay platform-unconditional.providers::get_host_command(allwhich/where/version/xdg-mime probes),providers::build_host_cli_command_impl(provider CLI sessions),system_apps::resolve_windows_program'swhereprobe,spawn_host_detachedhidden paths (editors,explorer.exe/open/xdg-open), stdio MCP server spawns, git for skill sources,taskkill, and the unsupported-sandbox runner (bash_execon Windows).spawn_host_detachednow takes an explicitHostWindow::{Hidden,Visible}: terminal launches stayVisible(forcmd/powershellthe console window is the launched terminal;wtdraws its own window either way), and custom editor commands stayVisible(a console custom editor like vim would otherwise run invisibly holding the file).windows-sysgains theWin32_System_Threadingfeature for theCREATE_NO_WINDOWconstant.Verification
cargo test --lib: 802/802 passed (incl. 2 new smoke tests covering both command types); clippy and rustfmt clean.production_qualitywith 3 minor findings, all fixed; round 2production_quality, zero findings.#[cfg(windows)]paths are eye-verified only (dev host is Linux) — please confirm the Windows CI build, and ideally one manual smoke on Windows: cold boot (no flashes), open file/editor (no flash), open terminal (window still appears).