The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): table-drive the service-managed restart hint
kshitijk4poorc4f1e9ed57a2
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex d238e1508a2..4730718d3d8 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -5516,12 +5516,8 @@ def _refuse_restart_of_service_managed_gateway(pid: int | None) -> None:if unit is None:returnscope = _dash._extract_scope_from_cgroup(_dash._get_pid_cgroup_path(pid) or "")- if scope == "user":- cmds = [f"systemctl --user restart {unit}"]- elif scope == "system":- cmds = [f"sudo systemctl restart {unit}"]- else:- cmds = [f"systemctl --user restart {unit}", f"sudo systemctl restart {unit} (system unit)"]+ user_cmd, system_cmd = f"systemctl --user restart {unit}", f"sudo systemctl restart {unit}"+ cmds = {"user": [user_cmd], "system": [system_cmd]}.get(scope, [user_cmd, system_cmd])_print_lines("",f"✗ Gateway (PID {pid}) is managed by systemd unit {unit}.",diff --git a/tests/hermes_cli/test_gateway_restart_external_supervisor.py b/tests/hermes_cli/test_gateway_restart_external_supervisor.pyindex ab9d0a1aa7a..7d95b4b7aa8 100644--- a/tests/hermes_cli/test_gateway_restart_external_supervisor.py+++ b/tests/hermes_cli/test_gateway_restart_external_supervisor.py@@ -130,5 +130,4 @@ def test_service_managed_gateway_refuses_fallback_takeover(restart_calls, monkeyout = capsys.readouterr().outfor hint in hints:assert hint in out- if len(hints) == 1:- assert out.count("systemctl") == 1, "a known scope must print only its own command"+ assert out.count("systemctl") == len(hints), "a known scope must print only its own command"