Skip to content

The agent that grows with you

fix(update,doctor): reconcile duplicate Windows gateway autostart entries

Brooklyn Nicholson3ddf06867fee
diff --git a/hermes_cli/doctor_platform.py b/hermes_cli/doctor_platform.py
index 48bff79e71b..4533df0c441 100644
--- a/hermes_cli/doctor_platform.py
+++ b/hermes_cli/doctor_platform.py
@@ -499,10 +499,37 @@ def _check_required_packages(should_fix: bool, f: Finding) -> None:
_fail_and_issue(name, "(missing)", f"Repair {name}: {_python_repair_hint()}", f.issues)
+def _check_windows_gateway_autostart(should_fix: bool, f: Finding) -> None:
+ """Windows: the gateway must start at logon from ONE mechanism — a Scheduled Task and a
+ Startup-folder entry side by side launch it twice (#80569)."""
+ if sys.platform != "win32":
+ return
+ from hermes_cli import gateway_windows
+ redundant = gateway_windows.redundant_autostart_entries()
+ if not redundant:
+ return
+ _section("Windows Gateway Autostart")
+ if not should_fix:
+ for path in redundant:
+ check_warn("Redundant gateway login item", f"({path})")
+ f.issues.append("Remove duplicate Windows gateway autostart entries: hermes doctor --fix")
+ return
+ done, warnings = gateway_windows.reconcile_autostart_launchers()
+ for message in done:
+ check_ok(message)
+ for message in warnings:
+ check_warn(message)
+ if done and not warnings:
+ f.fixed += 1
+ if warnings:
+ f.manual_issues.extend(warnings)
+
+
@doctor_check()
def _check_gateway_supervision(should_fix: bool, f: Finding) -> None:
_check_gateway_service_linger(f.issues)
_check_s6_supervision(f.issues)
+ _check_windows_gateway_autostart(should_fix, f)
@doctor_check()
diff --git a/hermes_cli/update_cmd_windows.py b/hermes_cli/update_cmd_windows.py
index ef90b519a7d..0213fa868dc 100644
--- a/hermes_cli/update_cmd_windows.py
+++ b/hermes_cli/update_cmd_windows.py
@@ -1088,6 +1088,12 @@ def _refresh_windows_gateway_launchers() -> None:
if gateway_windows.is_installed():
gateway_windows._write_task_script()
print(" ✓ Refreshed Windows gateway launcher scripts")
+ # Installs from before #80569 can carry a Startup entry beside the task: both fire at logon.
+ done, warnings = gateway_windows.reconcile_autostart_launchers()
+ for message in done:
+ print(f" ✓ {message}")
+ for message in warnings:
+ print(f" ⚠ {message}")
if gateway_windows.is_task_registered():
# A task registered by an older build never picks up template hardening otherwise (#113670).
gateway_windows.reconcile_scheduled_task(gateway_windows.get_task_name())