Skip to content

fix(windows): prevent helper process console flashes - #68472

Closed
YuYigeng wants to merge 1 commit into
NousResearch:mainfrom
YuYigeng:agent/windows-windowless-subprocesses
Closed

fix(windows): prevent helper process console flashes#68472
YuYigeng wants to merge 1 commit into
NousResearch:mainfrom
YuYigeng:agent/windows-windowless-subprocesses

Conversation

@YuYigeng

@YuYigeng YuYigeng commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Prevents visible console flashes from the two remaining helper-process spawn paths on Windows installations created by uv.

The venv python.exe launcher re-execs the base console interpreter, so CREATE_NO_WINDOW on the launcher cannot suppress the second conhost. This change reuses the existing uv-aware interpreter resolution to launch both the TUI slash worker and the gateway restart watcher with the base pythonw.exe. It also supplies the VIRTUAL_ENV and PYTHONPATH overlay required by the base interpreter, while preserving profile-specific HERMES_HOME and safe fallback behavior.

Related Issue

Fixes #68457

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • Added a private reusable windowless-Python spawn specification in hermes_cli/gateway_windows.py.
  • Updated tui_gateway/server.py so _SlashWorker launches uv environments through the base pythonw.exe and retains its profile environment.
  • Updated hermes_cli/gateway.py so the restart watcher itself, not only the gateway it later respawns, uses pythonw.exe with the required cwd and environment.
  • Added behavioral coverage for real uv pyvenv.cfg resolution, profile propagation, non-Windows behavior, and resolution-failure fallback.

Validation

After rebasing onto current main (including #56747's additional Windows hide-flag paths and tests):

  • HERMES_PYTHON=/path/to/python scripts/run_tests.sh tests/hermes_cli/test_gateway.py tests/hermes_cli/test_gateway_windows.py tests/gateway/test_restart_drain.py tests/test_tui_gateway_server.py tests/test_windows_subprocess_no_window_flags.py tests/tui_gateway/test_slash_worker_profile_home.py589 passed
  • ruff check hermes_cli/gateway.py hermes_cli/gateway_windows.py tui_gateway/server.py tests/hermes_cli/test_gateway.py tests/test_windows_subprocess_no_window_flags.py — passed
  • python scripts/check-windows-footguns.py --diff upstream/main — passed across all five changed files
  • git diff --check upstream/main...HEAD — passed

The spawn-path tests construct a real uv-style pyvenv.cfg, base pythonw.exe, and venv site-packages so the resolver is exercised end to end. Non-Windows behavior and resolution failure retain the original sys.executable fallback. The upstream #56747 regression coverage for the six other GUI-reachable spawn sites remains intact.

I also attempted the full suite. It reached 37% before I stopped it after unrelated host/environment failures, including a Linux systemd abstract-socket test on macOS and Discord fixture URLs resolving to an SSRF-blocked reserved address. All suites covering the changed paths passed.

Checklist

  • Read the contribution guidance
  • Conventional commit and GitHub-linked author identity
  • Searched for duplicate PRs
  • Only scoped files are changed
  • Added behavioral regression coverage
  • Considered Windows and non-Windows behavior
  • No public API or configuration keys added

Screenshots / Logs

Not applicable: this is process-launch behavior covered by subprocess-spawn assertions and real uv-layout resolver fixtures.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Jul 21, 2026
@YuYigeng
YuYigeng force-pushed the agent/windows-windowless-subprocesses branch 3 times, most recently from fd57cdd to 142f3ca Compare July 22, 2026 09:06
@YuYigeng
YuYigeng marked this pull request as ready for review July 22, 2026 09:07
@YuYigeng
YuYigeng force-pushed the agent/windows-windowless-subprocesses branch from 142f3ca to 2de9de6 Compare July 23, 2026 12:45
@YuYigeng
YuYigeng force-pushed the agent/windows-windowless-subprocesses branch from 2de9de6 to 3a6381a Compare July 23, 2026 18:05
@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by PR #70205 (merged as 0dbf639), which fixes this class in the opposite direction.

This PR rewrites the restart watcher to GUI-subsystem pythonw.exe — but main just removed all pythonw daemon launches deliberately: a console-less parent is what causes the per-descendant console flashes (#54220/#56747), since every console-subsystem child must allocate its own visible console. The watcher now runs console python under CREATE_NO_WINDOW (it owns one hidden console its children inherit), and the slash_worker spawn already carries windows_hide_flags() on main.

If you still see a flash on these legs on current main, please re-open with the flashing process name — that would be a leg the parent-console fix doesn't cover. Thanks for the detailed spawn-chain analysis.

@teknium1 teknium1 closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: uv venv launcher shim re-exec causes console window flashes on every subprocess spawn (SlashWorker, gateway restart watcher)

3 participants