fix(gateway): suppress black console window flash on Windows - #64339
fix(gateway): suppress black console window flash on Windows#64339seamusmore wants to merge 2 commits into
Conversation
Port the HERMES_GIT_BASH_PATH env var check from main.cjs to main.ts after the TS conversion. Also extract findGitBash to a dedicated module for testability and add focused regression tests for override precedence and invalid-override fallback.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for investigating the Windows console flashes. The desktop Git Bash resolver extraction is focused and follows the existing dependency-free Vitest helper pattern.
Problems
- The stated
bashpath is already covered on current main:tools/environments/local.py:1211passeswindows_hide_flags()tosubprocess.Popen. The detached gateway is deliberately launched as console-lesspythonw.exeinhermes_cli/gateway_windows.py:883-915. Before attaching a process-wide console ingateway/run.py, please identify and reproduce a remaining unprotected child-spawn path. - The new
AllocConsole()path has no regression coverage. The added tests exercise onlyfindGitBash.
Suggested changes
- Add a focused, injectable helper test covering existing-console, no-console, and
AllocConsole-failure behavior, and validate the affected Windows child path. - Keep the console change scoped to the demonstrated missing spawn path if per-child
windows_hide_flags()is sufficient.
This is an automated hermes-sweeper review.
| kernel32 = ctypes.windll.kernel32 | ||
| user32 = ctypes.windll.user32 | ||
| if not kernel32.GetConsoleWindow(): | ||
| kernel32.AllocConsole() |
There was a problem hiding this comment.
Please identify the current child-spawn path that still flashes before attaching a console to the entire detached gateway. The normal terminal bash path already passes windows_hide_flags() on Windows (tools/environments/local.py:1211); add a focused regression test/repro for the remaining path and preserve the detached pythonw.exe lifecycle contract.
a43c8b6 to
b5ef5bc
Compare
Replace the process-wide AllocConsole() with targeted creationflags on asyncio.create_subprocess_exec/shell calls that were missing them. When the gateway runs as pythonw.exe (GUI subsystem, no console), asyncio subprocess calls without CREATE_NO_WINDOW cause Windows to allocate a visible console for each child — flashing a black window. The four unprotected paths fixed: - gateway/run.py: ffprobe audio duration probe - gateway/run.py: quick-command exec via create_subprocess_shell - qqbot/adapter.py: ffmpeg audio conversion - whatsapp_cloud.py: ffmpeg Opus conversion All synchronous subprocess.Popen calls in the gateway already pass windows_detach_flags() or windows_detach_popen_kwargs(), so no process-wide console is needed.
b5ef5bc to
aa68a33
Compare
|
After investigation per your review suggestion, here is what I found. Per-child approach investigationFollowing your suggestion to identify "a remaining unprotected child-spawn path" instead of the process-wide ✅ Paths already covered (have creationflags)
❌ Paths WITHOUT creationflags (Windows only)
Why per-child doesn't scaleI implemented the targeted fix (adding The fundamental problem is that the codebase has dozens of spawn points across
Test coverageAdded 5 regression tests in
All 20 tests pass (15 pre-existing + 5 new). |
|
The desktop-parity half of this PR is merged via PR #70265 — your find-git-bash.ts extraction, the Thanks for both halves — the parity gap was a real find. |
What does this PR do?
Fixes the black console window flash that appears when Hermes gateway (running as on Windows) spawns child processes like bash, git, cmd, or powershell.
Root Cause
When the gateway is launched via (GUI subsystem), it has no console. Every console-subsystem child it spawns then allocates its own visible console → black window flashes.
Fix
Allocate a hidden console in so child processes inherit it instead of creating their own visible windows.
Type: 🐛 Bug fix
Changes
Platform
Windows