Skip to content

fix(windows): make gateway install lifecycle idempotent (salvage of #26488)#28874

Merged
teknium1 merged 4 commits into
mainfrom
hermes/hermes-008bccbc
May 19, 2026
Merged

fix(windows): make gateway install lifecycle idempotent (salvage of #26488)#28874
teknium1 merged 4 commits into
mainfrom
hermes/hermes-008bccbc

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvages @nekwo's Windows gateway lifecycle work from #26488 onto current main. Closes #26487 — "Severe: Windows gateway install may spawn repeated console windows that make the desktop unusable" — by making repeated hermes gateway install / start idempotent, hiding subprocess consoles, and routing UAC escalation only through the access-denied path.

Original PR #26488 was 23 commits behind main with major conflicts in cron/scheduler.py, tools/process_registry.py, and tests/hermes_cli/test_gateway_windows.py. This salvage cherry-picks the three substantive contributor commits, resolves conflicts in favor of recent main changes (stdin=DEVNULL fix from 214b953, env=run_env from cron HERMES_HOME work), and adds one follow-up fixup for cross-platform test compatibility.

Changes

  • hermes_cli/gateway_windows.py — idempotent install/start, schtasks /Create /F reconciliation, UAC only on access-denied, pythonw + hidden flags for detached spawn (nekwo, +361/-…)
  • hermes_cli/gateway.py — passes setup choices through to Windows install, honors start/startup choices on systemd, declines launchd when login auto-start declined (nekwo)
  • hermes_cli/main.py — adds --start-now / --no-start-now / --start-on-login / --no-start-on-login / --elevated-handoff for UAC handoff (nekwo)
  • tools/environments/local.py, tools/process_registry.py, cron/scheduler.pycreationflags=windows_hide_flags() so foreground/background terminal subprocesses and cron jobs don't flash cmd/python windows (nekwo)
  • tests/hermes_cli/test_gateway.py, tests/hermes_cli/test_gateway_windows.py — regression coverage for the lifecycle behaviors above (nekwo, +85 / +424). Merged with the 3 pre-existing tests on main covering schtasks fallback patterns and uv venv launcher detection.
  • Follow-up commit (teknium1): monkeypatch.setattr(..., raising=False) on ctypes.windll so the elevated-gateway test runs on non-Windows CI.

Validation

$ scripts/run_tests.sh tests/hermes_cli/test_gateway_windows.py tests/hermes_cli/test_gateway.py
54 passed in 0.97s

Matches the contributor's own pytest … -q result (45 passed at the time of his branch; we have 54 because main added tests in the meantime).

Closes

nekwo and others added 4 commits May 19, 2026 11:12
Apply CREATE_NO_WINDOW flags when the cron scheduler launches job scripts on Windows so gateway-managed no-agent cron jobs do not flash cmd or python console windows every tick.
Apply Windows CREATE_NO_WINDOW flags to foreground local terminal subprocesses and tracked background processes so Hermes operations do not flash or steal focus with extra console windows.
Preserve Windows profile install decisions across UAC handoff, avoid visible console windows by launching via pythonw, make repeated install/start idempotent, recreate stale Scheduled Tasks, and separate start-now from login auto-start behavior. Add Windows gateway regression coverage and systemd setup tests for the shared install flow.
…-Windows

Linux/macOS CI runners don't have ctypes.windll, so the elevated-gateway
test fails at module load. Adding raising=False lets monkeypatch install
the mock attribute without first requiring it to exist.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-008bccbc vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8969 on HEAD, 8966 on base (🆕 +3)

🆕 New issues (4):

Rule Count
no-matching-overload 2
unresolved-attribute 2
First entries
tools/environments/local.py:525: [no-matching-overload] no-matching-overload: No overload of `Popen.__init__` matches arguments
hermes_cli/gateway_windows.py:168: [unresolved-attribute] unresolved-attribute: Module `ctypes` has no member `windll`
tools/process_registry.py:555: [no-matching-overload] no-matching-overload: No overload of `Popen.__init__` matches arguments
tools/environments/local.py:541: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_hermes_pgid` on type `Popen[AnyStr@Popen]`

✅ Fixed issues (2):

Rule Count
unresolved-attribute 2
First entries
tools/process_registry.py:563: [unresolved-attribute] unresolved-attribute: Module `subprocess` has no member `CREATE_NO_WINDOW`
tools/environments/local.py:537: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_hermes_pgid` on type `Popen[str]`

Unchanged: 4720 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1 teknium1 merged commit a19eb54 into main May 19, 2026
17 of 18 checks passed
@teknium1 teknium1 deleted the hermes/hermes-008bccbc branch May 19, 2026 18:23
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/cron Cron scheduler and job management tool/terminal Terminal execution and process management backend/local Local shell execution P1 High — major feature broken, no workaround labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/local Local shell execution comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [Severe] Windows gateway install may spawn repeated console windows that make the desktop unusable

3 participants