Skip to content

fix(windows): hide console windows from subprocess spawns - #54082

Closed
MichaelQee wants to merge 2 commits into
NousResearch:mainfrom
MichaelQee:fix/windows-console-flash
Closed

fix(windows): hide console windows from subprocess spawns#54082
MichaelQee wants to merge 2 commits into
NousResearch:mainfrom
MichaelQee:fix/windows-console-flash

Conversation

@MichaelQee

@MichaelQee MichaelQee commented Jun 28, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes three Windows-specific console window flash issues:

  1. _SlashWorker post-turn restartsubprocess.Popen in tui_gateway/server.py was missing creationflags=subprocess.CREATE_NO_WINDOW. Every agent turn restarted the worker, flashing a Python window each time.

  2. ps.exe fallback in process checksgateway/status.py and hermes_cli/gateway.py had code comments saying "Windows has no ps", but Git Bash installs ps.exe at C:\Git\usr\bin\ps.exe. The fallback executed ps in a visible console window. Fixed by skipping ps on Windows and using psutil directly.

  3. Weixin aiodns SelectorEventLoop erroraiohttp on Windows requires WindowsSelectorEventLoopPolicy, which wasn't set before asyncio.run() in run_gateway(). This caused weixin/微信 connections to fail with "aiodns needs a SelectorEventLoop". Fixed by setting the policy at startup.

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • tui_gateway/server.py: Add creationflags=CREATE_NO_WINDOW to _SlashWorker.__init__ Popen call
  • gateway/status.py: Skip ps.exe fallback in _read_process_cmdline on Windows, use psutil
  • hermes_cli/gateway.py: (1) Add sys.platform == "win32" guard to _get_parent_pid ps fallback. (2) Set WindowsSelectorEventLoopPolicy before asyncio.run() in run_gateway

How to Test

  1. Test 1 (SlashWorker flash): On Windows with Hermes TUI, send a message that triggers tool calls. After the agent responds, observe no Python window flash.
  2. Test 2 (ps.exe flash): On Windows with Git Bash installed, run hermes gateway run and observe no blank ps.exe window at 30-second intervals.
  3. Test 3 (Weixin): On Windows, configure weixin platform and start gateway. Verify connect succeeds instead of failing with "aiodns needs SelectorEventLoop".

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Windows 11

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide
  • I've updated tool descriptions/schemas — or N/A

Three Windows-specific fixes for console window flashes:

1. tui_gateway/server.py: Add CREATE_NO_WINDOW to _SlashWorker's
   subprocess.Popen call. The worker is restarted after every agent
   turn, and the missing flag caused a visible python.exe window
   to flash each time.

2. gateway/status.py: Skip ps.exe fallback in _read_process_cmdline
   on Windows. Git Bash ships ps.exe, so the 'Windows has no ps'
   assumption is incorrect. Go straight to psutil instead.

3. hermes_cli/gateway.py: (a) Same ps.exe guard in _get_parent_pid.
   (b) Set WindowsSelectorEventLoopPolicy before asyncio.run() in
   run_gateway so aiohttp/aiodns works with weixin on Windows.
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery 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 platform/wecom WeCom / WeChat Work adapter sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows P2 Medium — degraded but workaround exists labels Jun 28, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: LGTM

Hides console windows from subprocess spawns on Windows. Three targeted fixes across different subsystems.

Changes

  • gateway/status.py: Uses psutil instead of ps command on Windows (avoids Git Bash console flash)
  • hermes_cli/gateway.py: Skips ps fallback on Windows, adds WindowsSelectorEventLoopPolicy for aiohttp
  • tui_gateway/server.py: Adds CREATE_NO_WINDOW flag to subprocess.Popen

Looks Good

  • psutil is already a dependency, clean fallback
  • WindowsSelectorEventLoopPolicy fix is well-documented (aiohttp/aiodns compatibility)
  • CREATE_NO_WINDOW flag prevents console flashes from TUI gateway
  • Platform-specific guards are correctly conditioned on sys.platform

Reviewed by Hermes Agent

@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by the consolidated Windows console-flash work tracked in #54220.

The relevant pieces from this PR/cluster have now landed through the targeted follow-up PRs #54236, #53892, and #54417, or are recorded in the umbrella tracker for any remaining native-Windows verification. Keeping this separate PR open would duplicate the tracker and the merged follow-up work.

Thanks for digging into this — the reports and PRs in this cluster helped identify the remaining spawn legs.

@teknium1 teknium1 closed this Jun 28, 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/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter 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.

4 participants