The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): say to restart the gateway after fixing an unavailable Webapp
emozillae28eb12064a6
diff --git a/hermes_cli/webapp_launcher.py b/hermes_cli/webapp_launcher.pyindex 402d52c17a6..09fbca7c0db 100644--- a/hermes_cli/webapp_launcher.py+++ b/hermes_cli/webapp_launcher.py@@ -13,6 +13,8 @@ import jsonfrom pathlib import PathRESTART_COMMAND = "hermes gateway restart"+# The gateway reads the Webapp's settings and sign-in providers only when it starts.+RETRY_AFTER_FIX = f"The gateway reads these settings when it starts: after fixing them, run {RESTART_COMMAND}."class GatewayUnreachable(Exception):@@ -99,6 +101,7 @@ def _status(target: Path) -> int:print(f"The Webapp is off. Set webapp.enabled: true in {target / 'config.yaml'}, then run {RESTART_COMMAND}.")else:print(f"Unavailable: {status['reason']}")+ print(RETRY_AFTER_FIX)return 0@@ -125,6 +128,8 @@ def _explain_refused_launch(target: Path, response: dict) -> int:print(f"The gateway started before the Webapp was turned on. Restart it to serve the Webapp: {RESTART_COMMAND}")else:print(_refusal(response))+ if state == "unavailable":+ print(RETRY_AFTER_FIX)return 1diff --git a/tests/hermes_cli/test_webapp_launcher.py b/tests/hermes_cli/test_webapp_launcher.pyindex 2fd3b32a22a..eaab4b7caa7 100644--- a/tests/hermes_cli/test_webapp_launcher.py+++ b/tests/hermes_cli/test_webapp_launcher.py@@ -112,13 +112,19 @@ def test_a_gateway_started_before_the_webapp_was_turned_on_asks_for_a_restart(woassert world["calls"]["opened"] == []-def test_a_webapp_the_gateway_could_not_serve_reports_why(world, capsys):+def test_a_webapp_the_gateway_could_not_serve_reports_why_and_how_to_retry(world, capsys):+ # The gateway reads the Webapp's settings and sign-in providers when it starts, so a fix only+ # takes effect after a restart.reason = "could not listen on 127.0.0.1:9120 (Address already in use)"world["answers"]["webapp-launch"] = {"ok": False, "error": f"RuntimeError: The Webapp is unavailable: {reason}"}world["answers"]["webapp-status"] = {"ok": True, "result": {"state": "unavailable", "url": None,"reason": reason}}assert launcher.cmd_webapp(_args()) == 1- assert reason in capsys.readouterr().out+ out = capsys.readouterr().out+ assert reason in out and "hermes gateway restart" in out+ assert launcher.cmd_webapp(_args(status=True)) == 0+ out = capsys.readouterr().out+ assert reason in out and "hermes gateway restart" in outdef test_no_open_prints_the_link_instead(world, capsys):