fix(win32): add CREATE_NO_WINDOW to all background subprocess calls - #54253
Closed
derek2000139 wants to merge 1 commit into
Closed
fix(win32): add CREATE_NO_WINDOW to all background subprocess calls#54253derek2000139 wants to merge 1 commit into
derek2000139 wants to merge 1 commit into
Conversation
Contributor
Author
|
Closing in favor of upstream fix cb982ad which covers a broader set of files (10 vs 4) using the centralized windows_hide_flags() helper, plus adds test coverage and fixes a CJK path encoding issue. Thanks! |
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.
fix(win32): add CREATE_NO_WINDOW to all background subprocess calls
Fixes #53424
Problem
On Windows, every
subprocess.run([git, ...])orsubprocess.Popen(...)call withoutcreationflags=CREATE_NO_WINDOWcauses a briefconhost.execonsole window to flash on screen. Whilehermes_cli/web_server.pyandhermes_cli/banner.pyalready handle this correctly viawindows_hide_flags(), several other modules missed the flag — most criticallytui_gateway/git_probe.py, which is the central hub for all gateway git probing and can spawn dozens of git processes per second during sidebar refreshes.User-visible symptom: Rapid, continuous console window flashing when the Hermes Desktop app is running on Windows, especially on machines with multiple sessions across different working directories.
Root Cause
pythonw.exe(the dashboard process) is windowless by design, but its child processes (git.exe,pdftoppm,python -m hermes_cli.main) are console executables. WithoutCREATE_NO_WINDOW(0x08000000), Windows allocates a newconhost.exefor each child, producing a visible flash even though the process completes in milliseconds.The
hermes_cli/_subprocess_compat.pymodule already documents this exact issue and provideswindows_hide_flags()— but it was only consumed byweb_server.pyandbanner.py. The gateway, agent, and checkpoint code paths were missed.Fix
Add
creationflagsto everysubprocess.run/subprocess.Popencall that spawns a console executable:tui_gateway/git_probe.pyrun_git()— central hub for all gateway git probestui_gateway/server.py_SlashWorkerPopen, pdftoppm,hermes_cli.main, quick_commands,git rev-parse,git ls-files,shell.execagent/coding_context.py_git()— git context probe per coding sessiontools/checkpoint_manager.py_run_git()hub +_init_store()Two styles used to match existing conventions in each file:
git_probe._CREATE_NO_WINDOW(module-level constant,sys.platform-guarded)getattr(subprocess, CREATE_NO_WINDOW, 0)— zero-import, safe on all platformsBoth approaches resolve to
0x08000000on Windows and0elsewhere — no behavioral change on Linux/macOS.Testing
py_compilesyntax check (Python 3.11).__pycache__, the rapid conhost.exe flashing stopped completely. Process monitoring confirmedgit.execalls still succeed (stdout captured correctly).creationflagsparameter is ignored on POSIX, and the flag values resolve to0.Notes
hermes_cli/main.py(~43 git calls) andcli.py(~17 git calls) also lackcreationflags, but these are CLI-only code paths where the user already has a terminal open, so the flash is not visible. This PR focuses on the background/daemon paths that run headless.Consider a follow-up to centralize the flag via
_subprocess_compat.windows_hide_flags()across all modules for consistency.