Hide hosted dashboard update controls

This commit is contained in:
Shannon Sands 2026-06-16 11:24:14 +10:00 committed by Teknium
parent 55cb4103be
commit 0b6b29a30c
7 changed files with 242 additions and 82 deletions

View file

@ -245,6 +245,16 @@ class TestWebServerEndpoints:
assert "version" in data
assert "hermes_home" in data
assert "active_sessions" in data
assert data["can_update_hermes"] is True
def test_get_status_hides_update_capability_in_hosted_mode(self, monkeypatch):
import hermes_cli.web_server as web_server
monkeypatch.setattr(web_server, "_dashboard_hosted_agent_mode", lambda: True)
resp = self.client.get("/api/status")
assert resp.status_code == 200
assert resp.json()["can_update_hermes"] is False
# ── GET /api/media (remote image display) ───────────────────────────
@ -912,6 +922,48 @@ class TestWebServerEndpoints:
assert status_data["pid"] is None
assert any("docker pull nousresearch/hermes-agent:latest" in line for line in status_data["lines"])
def test_update_hermes_returns_hosted_guidance_without_spawning(self, monkeypatch):
import hermes_cli.web_server as web_server
spawned = False
detected = False
def fail_spawn(*_args, **_kwargs):
nonlocal spawned
spawned = True
raise AssertionError("hosted update guard should not spawn hermes update")
def fail_detect(*_args, **_kwargs):
nonlocal detected
detected = True
raise AssertionError("hosted update guard should not detect install method")
monkeypatch.setattr(web_server, "_dashboard_hosted_agent_mode", lambda: True)
monkeypatch.setattr(web_server, "detect_install_method", fail_detect)
monkeypatch.setattr(web_server, "_spawn_hermes_action", fail_spawn)
web_server._ACTION_PROCS.pop("hermes-update", None)
web_server._ACTION_RESULTS.pop("hermes-update", None)
resp = self.client.post("/api/hermes/update")
assert resp.status_code == 200
data = resp.json()
assert data["ok"] is False
assert data["name"] == "hermes-update"
assert data["pid"] is None
assert data["error"] == "hosted_update_managed"
assert "hosted agent service" in data["message"]
assert spawned is False
assert detected is False
status = self.client.get("/api/actions/hermes-update/status")
assert status.status_code == 200
status_data = status.json()
assert status_data["running"] is False
assert status_data["exit_code"] == 1
assert status_data["pid"] is None
assert any("hosted agent service" in line for line in status_data["lines"])
def test_update_hermes_spawns_on_non_docker_install(self, monkeypatch):
import hermes_cli.web_server as web_server