fix(windows): suppress console window flashes in env probes, lazy installs, and platform.win32_ver() - #67690
Closed
m4r13y wants to merge 1 commit into
Closed
Conversation
…talls, and platform.win32_ver()
From windowless processes (the pythonw gateway and the kanban workers it
spawns), three spawn paths flash visible console windows on Windows:
1. tools/env_probe.py::_run() ran its interpreter/pip probes
(python3 / python / pip / 'python3 -m pip' / PEP-668 check, ~5 per
worker start) without creationflags — one console flash per probe.
2. tools/lazy_deps.py had four spawn sites with the same defect:
'uv pip install', the 'pip --version' probe, ensurepip, and the
pip install fallback.
Both now pass creationflags=windows_hide_flags() (CREATE_NO_WINDOW on
Windows, 0 on POSIX) — stdio capture still works because the child is
hidden, not detached.
3. CPython 3.11's platform.win32_ver() unconditionally calls
_syscmd_ver(), which runs 'cmd /c ver' via
subprocess.check_output(shell=True) with no window suppression. Any
dependency touching platform.uname()/version()/platform() at import
time flashes one 'cmd' window per windowless process. New helper
_subprocess_compat.suppress_platform_ver_console() (Windows-only,
never raises) stubs platform._syscmd_ver so win32_ver() falls back to
sys.getwindowsversion().platform_version — verified byte-identical
platform.platform() output on CPython 3.11
('Windows-10-10.0.26100-SP0' either way). Called at the top of
hermes_cli/main.py, right after the hermes_bootstrap guard, before
heavyweight imports.
Verified on Windows 11 by polling EnumWindows at ~15 ms and attributing
new visible HWNDs to the suspect process tree (conhost child presence is
NOT evidence of a visible window — it appears even with
CREATE_NO_WINDOW). Tests: tests/tools/test_windows_native_support.py,
test_env_probe.py, test_lazy_deps.py, test_lazy_deps_durable_target.py —
153 passed; the 3 failures are pre-existing on upstream/main in a
Windows environment (POSIX-only assertions and NTFS chmod semantics).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
teknium1
added a commit
that referenced
this pull request
Jul 23, 2026
…run + add no-window tests (#67690 follow-up) Follow-up to the #67690 salvage (@m4r13y). The PR's tools/env_probe.py hunk was written against the old capture_output=True _run(); #67964/#67999 rewrote _run to temp-file capture on July 20, so that hunk no longer applied — but the rewritten _run still lacked creationflags and kept flashing one console per probe (~5 per kanban worker start) from windowless parents. Re-implement the one-line fix against the current shape: creationflags=windows_hide_flags() on the temp-file subprocess.run, preserving the #67964 grandchild-can't-wedge-the-pipe contract. Also add the tests the PR didn't ship, in tests/test_windows_subprocess_no_window_flags.py: - env_probe._run passes CREATE_NO_WINDOW and keeps temp-file (non-PIPE) stdout/stderr + DEVNULL stdin - lazy_deps uv install / pip --version probe / pip install fallback / ensurepip bootstrap all pass CREATE_NO_WINDOW - suppress_platform_ver_console: POSIX no-op (platform._syscmd_ver untouched, win32_ver() still returns), and simulated-Windows stubbing (echo stub installed, idempotent, never raises)
teknium1
added a commit
that referenced
this pull request
Jul 24, 2026
…run + add no-window tests (#67690 follow-up) Follow-up to the #67690 salvage (@m4r13y). The PR's tools/env_probe.py hunk was written against the old capture_output=True _run(); #67964/#67999 rewrote _run to temp-file capture on July 20, so that hunk no longer applied — but the rewritten _run still lacked creationflags and kept flashing one console per probe (~5 per kanban worker start) from windowless parents. Re-implement the one-line fix against the current shape: creationflags=windows_hide_flags() on the temp-file subprocess.run, preserving the #67964 grandchild-can't-wedge-the-pipe contract. Also add the tests the PR didn't ship, in tests/test_windows_subprocess_no_window_flags.py: - env_probe._run passes CREATE_NO_WINDOW and keeps temp-file (non-PIPE) stdout/stderr + DEVNULL stdin - lazy_deps uv install / pip --version probe / pip install fallback / ensurepip bootstrap all pass CREATE_NO_WINDOW - suppress_platform_ver_console: POSIX no-op (platform._syscmd_ver untouched, win32_ver() still returns), and simulated-Windows stubbing (echo stub installed, idempotent, never raises)
teknium1
added a commit
that referenced
this pull request
Jul 24, 2026
…run + add no-window tests (#67690 follow-up) Follow-up to the #67690 salvage (@m4r13y). The PR's tools/env_probe.py hunk was written against the old capture_output=True _run(); #67964/#67999 rewrote _run to temp-file capture on July 20, so that hunk no longer applied — but the rewritten _run still lacked creationflags and kept flashing one console per probe (~5 per kanban worker start) from windowless parents. Re-implement the one-line fix against the current shape: creationflags=windows_hide_flags() on the temp-file subprocess.run, preserving the #67964 grandchild-can't-wedge-the-pipe contract. Also add the tests the PR didn't ship, in tests/test_windows_subprocess_no_window_flags.py: - env_probe._run passes CREATE_NO_WINDOW and keeps temp-file (non-PIPE) stdout/stderr + DEVNULL stdin - lazy_deps uv install / pip --version probe / pip install fallback / ensurepip bootstrap all pass CREATE_NO_WINDOW - suppress_platform_ver_console: POSIX no-op (platform._syscmd_ver untouched, win32_ver() still returns), and simulated-Windows stubbing (echo stub installed, idempotent, never raises)
Contributor
|
Merged via PR #70264 — your commit was cherry-picked onto current main with authorship preserved (rebase-merge). The |
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…run + add no-window tests (NousResearch#67690 follow-up) Follow-up to the NousResearch#67690 salvage (@m4r13y). The PR's tools/env_probe.py hunk was written against the old capture_output=True _run(); NousResearch#67964/NousResearch#67999 rewrote _run to temp-file capture on July 20, so that hunk no longer applied — but the rewritten _run still lacked creationflags and kept flashing one console per probe (~5 per kanban worker start) from windowless parents. Re-implement the one-line fix against the current shape: creationflags=windows_hide_flags() on the temp-file subprocess.run, preserving the NousResearch#67964 grandchild-can't-wedge-the-pipe contract. Also add the tests the PR didn't ship, in tests/test_windows_subprocess_no_window_flags.py: - env_probe._run passes CREATE_NO_WINDOW and keeps temp-file (non-PIPE) stdout/stderr + DEVNULL stdin - lazy_deps uv install / pip --version probe / pip install fallback / ensurepip bootstrap all pass CREATE_NO_WINDOW - suppress_platform_ver_console: POSIX no-op (platform._syscmd_ver untouched, win32_ver() still returns), and simulated-Windows stubbing (echo stub installed, idempotent, never raises)
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.
Summary
Three Windows console-window-flash fixes, all hit from windowless processes (a
pythonwgateway and every kanban worker it spawns). Each worker start was flashing a burst of visible console windows on the user's desktop.tools/env_probe.py—_run()calledsubprocess.runwithoutcreationflags. The probe sequence (python3/python/pip/python3 -m pip/ PEP-668 check) is ~5 spawns per worker start, each flashing a console. Now passescreationflags=windows_hide_flags().tools/lazy_deps.py— four spawn sites with the same defect (uv pip install, thepip --versionprobe,ensurepip, and the pip-install fallback). Same fix.platform.win32_ver()/_syscmd_ver()— CPython 3.11'splatform.win32_ver()unconditionally calls_syscmd_ver(), which runscmd /c verviasubprocess.check_output(shell=True)with no window suppression. Any dependency that merely touchesplatform.uname()/version()/platform()at import time flashes onecmdwindow per windowless process. New_subprocess_compat.suppress_platform_ver_console()helper (Windows-only, wrapped in try/except, no-op on POSIX) stubsplatform._syscmd_versowin32_ver()takes its documented fallback tosys.getwindowsversion().platform_version. Called at the very top ofhermes_cli/main.py, right after thehermes_bootstrapimport guard, before heavyweight imports.windows_hide_flags()returnsCREATE_NO_WINDOWon Windows and0on POSIX, and — unlike the detach flags — keeps stdio inherited, socapture_output=Truein all touched call sites keeps working.Verification
platform.platform()output is byte-identical with the stub active on CPython 3.11 / Windows 11 (Windows-10-10.0.26100-SP0either way; the fallback reads the same build number in-process viasys.getwindowsversion()).EnumWindowsat ~15 ms and attributing new visible HWNDs to the suspect process tree — note that aconhost.exechild is not evidence of a visible window (it appears even withCREATE_NO_WINDOW), so control runs with/without the flag were used.tests/tools/test_windows_native_support.py,test_env_probe.py,test_lazy_deps.py,test_lazy_deps_durable_target.py— 153 passed, 1 skipped. The 3 failures (test_no_op_on_posix,test_getattr_fallback_prefers_sigkill_when_present,test_readonly_target_reports_error) reproduce identically on a pristineupstream/maincheckout in the same environment — pre-existing POSIX-only assertions and NTFSchmodsemantics, unrelated to this change.🤖 Generated with Claude Code