Skip to content

The agent that grows with you

fix(windows): ask gateway setup install questions once and stop after UAC hand-off

joaomarcos7dcb667716b7
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py
index 1682e8424d8..d3a09eccc39 100644
--- a/hermes_cli/gateway.py
+++ b/hermes_cli/gateway.py
@@ -6030,7 +6030,13 @@ def _wizard_platform_loop() -> None:
def _wizard_install_service(backend: str) -> None:
- """Fresh install from the wizard: ask start-now / start-on-login, install, then start."""
+ """Fresh install from the wizard: ask start-now / start-on-login once, install, then start.
+
+ The Windows installer owns its start decision (Scheduled Task and Startup-folder
+ paths start the gateway themselves when start_now is true, and a UAC hand-off
+ installs and starts in the elevated child), so the wizard forwards the answers
+ and returns without a second start. Each install-intent question is asked exactly
+ once per setup run."""
wsl_note = " (note: services may not survive WSL restarts)" if is_wsl() else ""
start_now = prompt_yes_no(" Start the gateway now?", True)
start_on_login = prompt_yes_no(
@@ -6054,7 +6060,8 @@ def _wizard_install_service(backend: str) -> None:
elif backend == "launchd":
launchd_install(force=False)
else:
- _gw_windows().install(force=False)
+ _gw_windows().install(force=False, start_now=start_now, start_on_login=start_on_login)
+ return
print()
if did_install and start_now:
_setup_service_action("start", failed_label="Start failed", system=installed_scope == "system")
diff --git a/tests/hermes_cli/test_gateway_windows.py b/tests/hermes_cli/test_gateway_windows.py
index afc0b3430af..1789d0946de 100644
--- a/tests/hermes_cli/test_gateway_windows.py
+++ b/tests/hermes_cli/test_gateway_windows.py
@@ -601,3 +601,23 @@ def test_hermes_owns_windows_service_requires_name_or_binary_under_a_hermes_root
assert owns("Hermes_Gateway_derek", "", roots)
assert owns("gw", r'"C:\Users\KAIZE\AppData\Local\hermes\hermes-agent\venv\Scripts\hermes.exe" gateway run', roots)
assert owns("gw", r"C:\Users\kaize\AppData\Local\hermes\gateway-service\Hermes_Gateway.cmd", roots)
+
+
+def test_wizard_install_service_asks_once_and_never_starts_after_windows_install(monkeypatch):
+ """The wizard asks start-now/start-on-login once, forwards both answers, and returns
+ without a second start: the Windows installer owns start and the elevated child
+ starts itself, so a parent-side start would re-ask the install questions and re-offer
+ UAC while the child is still waiting on consent (#116550)."""
+ answers = iter([True, True])
+ monkeypatch.setattr(gateway, "prompt_yes_no", lambda *a, **k: next(answers))
+ monkeypatch.setattr(gateway, "is_wsl", lambda: False)
+ installs, starts = [], []
+ monkeypatch.setattr(gateway, "_gw_windows", lambda: SimpleNamespace(
+ install=lambda **kw: installs.append(kw) or True,
+ ))
+ monkeypatch.setattr(gateway, "_setup_service_action", lambda *a, **k: starts.append((a, k)))
+
+ gateway._wizard_install_service("windows")
+
+ assert installs == [{"force": False, "start_now": True, "start_on_login": True}]
+ assert starts == []