Skip to content

The agent that grows with you

fix(gateway): skip served profile setup install

KoNit-Kedca3c26531c
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py
index 4c7e7c0d511..ebd1367ce42 100644
--- a/hermes_cli/gateway.py
+++ b/hermes_cli/gateway.py
@@ -5783,6 +5783,12 @@ def _wizard_post_setup() -> None:
"""Offer to install/start/restart the gateway once at least one platform has progress."""
print()
print(color("─" * 58, Colors.DIM))
+ if named_profile_served_by_running_multiplexer():
+ print_success(
+ f"Profile '{_current_profile_name()}' is already served by the default multiplexer."
+ )
+ print_info("No standalone gateway service was installed or started.")
+ return
service_installed = _is_service_installed()
service_running = _is_service_running()
diff --git a/tests/hermes_cli/test_gateway_multiplex_served_record.py b/tests/hermes_cli/test_gateway_multiplex_served_record.py
index c73c5ac8623..bb1526ffad8 100644
--- a/tests/hermes_cli/test_gateway_multiplex_served_record.py
+++ b/tests/hermes_cli/test_gateway_multiplex_served_record.py
@@ -72,6 +72,30 @@ def test_probe_survives_a_missing_default_pid_file(served_root):
assert named_profile_served_by_running_multiplexer("coder") is True
+def test_setup_wizard_skips_service_install_for_profile_served_by_multiplexer(
+ served_root, monkeypatch, capsys,
+):
+ """Gateway setup must not create a standalone service for an already served profile."""
+ import hermes_cli.gateway as gw
+
+ calls: list[str] = []
+ monkeypatch.setattr(gw, "_is_service_installed", lambda: False)
+ monkeypatch.setattr(gw, "_is_service_running", lambda: False)
+ monkeypatch.setattr(gw, "_service_backend", lambda: "systemd")
+ monkeypatch.setattr(gw, "prompt_yes_no", lambda *args, **kwargs: True)
+ monkeypatch.setattr(
+ gw, "install_linux_gateway_from_setup", lambda **kwargs: calls.append("install"),
+ )
+ monkeypatch.setattr(
+ gw, "_setup_service_action", lambda *args, **kwargs: calls.append("start"),
+ )
+
+ gw._wizard_post_setup()
+
+ assert calls == []
+ assert "already served by the default multiplexer" in capsys.readouterr().out
+
+
def test_recycled_pid_does_not_lend_a_stale_record_its_served_profiles(served_root):
"""A stale default record whose PID now belongs to an unrelated process (start time differs, command
line is not a gateway's) must not make its ``served_profiles`` authoritative: bare PID existence