The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): dashboard plugin toggles now surface that a restart is required (#54941)
chris-young47c202479a62
diff --git a/hermes_cli/web_routers/dashboard_ui.py b/hermes_cli/web_routers/dashboard_ui.pyindex b323fbf27de..6b50ab18d28 100644--- a/hermes_cli/web_routers/dashboard_ui.py+++ b/hermes_cli/web_routers/dashboard_ui.py@@ -249,17 +249,34 @@ async def _named_plugin_action(request: Request, name: str, action: Callable[[staction(_validate_plugin_name(name)), fallback_error, rescan=rescan))+def _set_agent_plugin_enabled_with_restart_hint(name: str, *, enabled: bool) -> dict:+ """Toggle an agent plugin, stamping ``restart_required`` on the ok result.++ Config-only change: running gateway/TUI processes scan plugins once at+ start and won't pick this up, so tell the UI a restart is needed —+ mirrors the CLI's "Takes effect on next session." (#54941). Contract:+ every ok toggle result carries an explicit ``unchanged`` boolean (pinned+ by test_real_toggle_always_reports_unchanged); a missing key errs on the+ side of prompting a restart. Imported late so a test's monkeypatch on+ ``plugins_cmd`` wins at call time.+ """+ from hermes_cli.plugins_cmd import dashboard_set_agent_plugin_enabled++ result = dashboard_set_agent_plugin_enabled(name, enabled=enabled)+ if result.get("ok"):+ result["restart_required"] = not result.get("unchanged", False)+ return result++@router.post("/api/dashboard/agent-plugins/{name:path}/enable")async def post_agent_plugin_enable(request: Request, name: str):- from hermes_cli.plugins_cmd import dashboard_set_agent_plugin_enabled- return await _named_plugin_action(request, name, lambda n: dashboard_set_agent_plugin_enabled(n, enabled=True),+ return await _named_plugin_action(request, name, lambda n: _set_agent_plugin_enabled_with_restart_hint(n, enabled=True),"Enable failed.", rescan=False)@router.post("/api/dashboard/agent-plugins/{name:path}/disable")async def post_agent_plugin_disable(request: Request, name: str):- from hermes_cli.plugins_cmd import dashboard_set_agent_plugin_enabled- return await _named_plugin_action(request, name, lambda n: dashboard_set_agent_plugin_enabled(n, enabled=False),+ return await _named_plugin_action(request, name, lambda n: _set_agent_plugin_enabled_with_restart_hint(n, enabled=False),"Disable failed.", rescan=False)diff --git a/tests/hermes_cli/test_dashboard_plugin_toggle_restart_hint.py b/tests/hermes_cli/test_dashboard_plugin_toggle_restart_hint.pynew file mode 100644index 00000000000..6ed18052bfd--- /dev/null+++ b/tests/hermes_cli/test_dashboard_plugin_toggle_restart_hint.py@@ -0,0 +1,92 @@+"""Dashboard plugin toggle responses surface ``restart_required`` (#54941).++Plugin enable/disable writes config only — running gateway/TUI processes+scan plugins once at start and never see the change, so the dashboard must+tell the user a restart is needed (the CLI already prints "Takes effect on+next session."). These tests pin the endpoint-layer contract: a toggle that+changed state reports ``restart_required: true``; a no-op toggle reports+``restart_required: false``.++The underlying config write (``dashboard_set_agent_plugin_enabled``) is+stubbed — its own behaviour is covered by tests/hermes_cli/test_plugins_cmd+tests; here we only assert the HTTP layer's annotation.+"""++from __future__ import annotations++import pytest+from fastapi.testclient import TestClient++from hermes_cli import plugins_cmd, web_server+from hermes_cli.dashboard_auth import clear_providers+++def loopback_client():+ clear_providers()+ prev_host = getattr(web_server.app.state, "bound_host", None)+ prev_port = getattr(web_server.app.state, "bound_port", None)+ prev_required = getattr(web_server.app.state, "auth_required", None)+ web_server.app.state.bound_host = "127.0.0.1"+ web_server.app.state.bound_port = 8080+ web_server.app.state.auth_required = False+ client = TestClient(+ web_server.app,+ base_url="http://127.0.0.1:8080",+ headers={"X-Hermes-Session-Token": web_server._SESSION_TOKEN},+ )+ yield client+ web_server.app.state.bound_host = prev_host+ web_server.app.state.bound_port = prev_port+ web_server.app.state.auth_required = prev_required+++def _stub_toggle(monkeypatch, *, unchanged: bool):+ calls = []++ def fake(name, *, enabled):+ calls.append((name, enabled))+ return {"ok": True, "name": "web/exa", "unchanged": unchanged}++ monkeypatch.setattr(+ plugins_cmd, "dashboard_set_agent_plugin_enabled", fake+ )+ return calls+++def test_enable_change_reports_restart_required(loopback_client, monkeypatch):+ calls = _stub_toggle(monkeypatch, unchanged=False)+ resp = loopback_client.post("/api/dashboard/agent-plugins/web/exa/enable")+ assert resp.status_code == 200+ body = resp.json()+ assert body["ok"] is True+ assert body["restart_required"] is True+ assert calls == [("web/exa", True)]+++def test_disable_change_reports_restart_required(loopback_client, monkeypatch):+ calls = _stub_toggle(monkeypatch, unchanged=False)+ resp = loopback_client.post("/api/dashboard/agent-plugins/web/exa/disable")+ assert resp.status_code == 200+ body = resp.json()+ assert body["ok"] is True+ assert body["restart_required"] is True+ assert calls == [("web/exa", False)]+++def test_noop_toggle_reports_no_restart(loopback_client, monkeypatch):+ _stub_toggle(monkeypatch, unchanged=True)+ resp = loopback_client.post("/api/dashboard/agent-plugins/web/exa/enable")+ assert resp.status_code == 200+ assert resp.json()["restart_required"] is False+++def test_failed_toggle_has_no_restart_field(loopback_client, monkeypatch):+ def fake(name, *, enabled):+ return {"ok": False, "error": "Plugin 'nope' is not installed or bundled."}++ monkeypatch.setattr(+ plugins_cmd, "dashboard_set_agent_plugin_enabled", fake+ )+ resp = loopback_client.post("/api/dashboard/agent-plugins/nope/disable")+ assert resp.status_code == 400diff --git a/web/src/i18n/af.ts b/web/src/i18n/af.tsindex d55741a2045..fe1a3e56800 100644--- a/web/src/i18n/af.ts+++ b/web/src/i18n/af.ts@@ -324,6 +324,8 @@ export const af: Translations = {disableRuntime: "Deaktiveer",enableAfterInstall: "Aktiveer ná installasie",enableRuntime: "Aktiveer",+ toggleTakesEffectNextSession:+ "Gestoor — geld vir nuwe sessies. Herbegin die gateway om dit oral toe te pas.",forceReinstall: "Forseer herinstallasie (skrap eers bestaande gids)",headline:"Ontdek, installeer, aktiveer en werk Hermes-inproppe op (`hermes plugins` ekwivalent).",diff --git a/web/src/i18n/de.ts b/web/src/i18n/de.tsindex 657a7f96bf9..c05e89031b7 100644--- a/web/src/i18n/de.ts+++ b/web/src/i18n/de.ts@@ -324,6 +324,8 @@ export const de: Translations = {disableRuntime: "Deaktivieren",enableAfterInstall: "Nach Installation aktivieren",enableRuntime: "Aktivieren",+ toggleTakesEffectNextSession:+ "Gespeichert — gilt für neue Sitzungen. Gateway neu starten, um es überall anzuwenden.",forceReinstall: "Neuinstallation erzwingen (bestehenden Ordner zuerst löschen)",headline:"Hermes-Plugins entdecken, installieren, aktivieren und aktualisieren (entspricht `hermes plugins`).",diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.tsindex 9f208d63acb..a5036f1cef2 100644--- a/web/src/i18n/en.ts+++ b/web/src/i18n/en.ts@@ -398,6 +398,8 @@ export const en: Translations = {disableRuntime: "Disable",enableAfterInstall: "Enable after install",enableRuntime: "Enable",+ toggleTakesEffectNextSession:+ "Saved — takes effect for new sessions. Restart the gateway to apply it everywhere.",forceReinstall: "Force reinstall (delete existing folder first)",headline:"Discover, install, enable, and update Hermes plugins (`hermes plugins` parity).",diff --git a/web/src/i18n/es.ts b/web/src/i18n/es.tsindex 2ecc2bf98cc..35e19eb2865 100644--- a/web/src/i18n/es.ts+++ b/web/src/i18n/es.ts@@ -325,6 +325,8 @@ export const es: Translations = {disableRuntime: "Deshabilitar",enableAfterInstall: "Habilitar tras instalar",enableRuntime: "Habilitar",+ toggleTakesEffectNextSession:+ "Guardado: surte efecto en nuevas sesiones. Reinicia el gateway para aplicarlo en todas partes.",forceReinstall: "Forzar reinstalación (eliminar carpeta existente primero)",headline:"Descubre, instala, habilita y actualiza complementos de Hermes (equivalente a `hermes plugins`).",diff --git a/web/src/i18n/fr.ts b/web/src/i18n/fr.tsindex b2148ac45dd..54c7498b3a1 100644--- a/web/src/i18n/fr.ts+++ b/web/src/i18n/fr.ts@@ -325,6 +325,8 @@ export const fr: Translations = {disableRuntime: "Désactiver",enableAfterInstall: "Activer après l'installation",enableRuntime: "Activer",+ toggleTakesEffectNextSession:+ "Enregistré — prend effet pour les nouvelles sessions. Redémarrez la passerelle pour l'appliquer partout.",forceReinstall: "Forcer la réinstallation (supprimer d'abord le dossier existant)",headline:"Découvrez, installez, activez et mettez à jour les plugins Hermes (parité avec `hermes plugins`).",diff --git a/web/src/i18n/ga.ts b/web/src/i18n/ga.tsindex 39d20cd4a14..34488236721 100644--- a/web/src/i18n/ga.ts+++ b/web/src/i18n/ga.ts@@ -332,6 +332,8 @@ export const ga: Translations = {disableRuntime: "Díchumasaigh",enableAfterInstall: "Cumasaigh tar éis suiteála",enableRuntime: "Cumasaigh",+ toggleTakesEffectNextSession:+ "Sábháilte — i bhfeidhm do sheisiúin nua. Atosaigh an gateway chun é a chur i bhfeidhm i ngach áit.",forceReinstall: "Cuir iallach ar athshuiteáil (scrios an fillteán atá ann ar dtús)",headline:"Faigh, suiteáil, cumasaigh agus nuashonraigh plugins Hermes (paireacht le `hermes plugins`).",diff --git a/web/src/i18n/hu.ts b/web/src/i18n/hu.tsindex 9d57977e01f..17fbe45aee8 100644--- a/web/src/i18n/hu.ts+++ b/web/src/i18n/hu.ts@@ -324,6 +324,8 @@ export const hu: Translations = {disableRuntime: "Letiltás",enableAfterInstall: "Engedélyezés a telepítés után",enableRuntime: "Engedélyezés",+ toggleTakesEffectNextSession:+ "Mentve — az új munkamenetekre érvényes. Indítsa újra az átjárót, hogy mindenhol érvénybe lépjen.",forceReinstall: "Kényszerített újratelepítés (a meglévő mappa előbb törlődik)",headline:"Hermes-bővítmények felfedezése, telepítése, engedélyezése és frissítése (a `hermes plugins` paritás).",diff --git a/web/src/i18n/it.ts b/web/src/i18n/it.tsindex f9eea78f758..8f95946e1e9 100644--- a/web/src/i18n/it.ts+++ b/web/src/i18n/it.ts@@ -324,6 +324,8 @@ export const it: Translations = {disableRuntime: "Disabilita",enableAfterInstall: "Abilita dopo l'installazione",enableRuntime: "Abilita",+ toggleTakesEffectNextSession:+ "Salvato: ha effetto nelle nuove sessioni. Riavvia il gateway per applicarlo ovunque.",forceReinstall: "Forza reinstallazione (elimina prima la cartella esistente)",headline:"Scopri, installa, abilita e aggiorna i plugin Hermes (parità con `hermes plugins`).",diff --git a/web/src/i18n/ja.ts b/web/src/i18n/ja.tsindex f7028115dca..f8f4d00b2cf 100644--- a/web/src/i18n/ja.ts+++ b/web/src/i18n/ja.ts@@ -323,6 +323,8 @@ export const ja: Translations = {disableRuntime: "無効化",enableAfterInstall: "インストール後に有効化",enableRuntime: "有効化",+ toggleTakesEffectNextSession:+ "保存しました — 新しいセッションから有効になります。すべてに適用するにはゲートウェイを再起動してください。",forceReinstall: "強制再インストール (既存のフォルダを先に削除)",headline:"Hermes プラグインを発見、インストール、有効化、更新します (`hermes plugins` 相当)。",diff --git a/web/src/i18n/ko.ts b/web/src/i18n/ko.tsindex 168acbdb29f..e7f54440f5a 100644--- a/web/src/i18n/ko.ts+++ b/web/src/i18n/ko.ts@@ -323,6 +323,8 @@ export const ko: Translations = {disableRuntime: "비활성화",enableAfterInstall: "설치 후 활성화",enableRuntime: "활성화",+ toggleTakesEffectNextSession:+ "저장됨 — 새 세션부터 적용됩니다. 모든 곳에 적용하려면 게이트웨이를 다시 시작하세요.",forceReinstall: "강제 재설치 (기존 폴더를 먼저 삭제)",headline:"Hermes 플러그인을 검색, 설치, 활성화 및 업데이트합니다 (`hermes plugins` 동등).",diff --git a/web/src/i18n/pt.ts b/web/src/i18n/pt.tsindex 4a3bf5d9f4e..dfb05aa7848 100644--- a/web/src/i18n/pt.ts+++ b/web/src/i18n/pt.ts@@ -325,6 +325,8 @@ export const pt: Translations = {disableRuntime: "Desativar",enableAfterInstall: "Ativar após instalação",enableRuntime: "Ativar",+ toggleTakesEffectNextSession:+ "Salvo — entra em vigor em novas sessões. Reinicie o gateway para aplicar em todos os lugares.",forceReinstall: "Forçar reinstalação (eliminar pasta existente primeiro)",headline:"Descobrir, instalar, ativar e atualizar plugins Hermes (paridade com `hermes plugins`).",diff --git a/web/src/i18n/ru.ts b/web/src/i18n/ru.tsindex cd41b74dd05..9b57274d3e2 100644--- a/web/src/i18n/ru.ts+++ b/web/src/i18n/ru.ts@@ -324,6 +324,8 @@ export const ru: Translations = {disableRuntime: "Отключить",enableAfterInstall: "Включить после установки",enableRuntime: "Включить",+ toggleTakesEffectNextSession:+ "Сохранено — вступит в силу для новых сессий. Перезапустите шлюз, чтобы применить везде.",forceReinstall: "Принудительная переустановка (сначала удалить существующую папку)",headline:"Поиск, установка, включение и обновление плагинов Hermes (аналог `hermes plugins`).",diff --git a/web/src/i18n/tr.ts b/web/src/i18n/tr.tsindex 6db4474a651..2d9bbfaa541 100644--- a/web/src/i18n/tr.ts+++ b/web/src/i18n/tr.ts@@ -324,6 +324,8 @@ export const tr: Translations = {disableRuntime: "Devre dışı bırak",enableAfterInstall: "Yüklemeden sonra etkinleştir",enableRuntime: "Etkinleştir",+ toggleTakesEffectNextSession:+ "Kaydedildi — yeni oturumlarda geçerli olur. Her yerde uygulamak için ağ geçidini yeniden başlatın.",forceReinstall: "Yeniden yüklemeyi zorla (önce mevcut klasörü sil)",headline:"Hermes eklentilerini keşfedin, yükleyin, etkinleştirin ve güncelleyin (`hermes plugins` ile eşdeğer).",diff --git a/web/src/i18n/types.ts b/web/src/i18n/types.tsindex ddb367363e4..bb84f4c3fc3 100644--- a/web/src/i18n/types.ts+++ b/web/src/i18n/types.ts@@ -345,6 +345,7 @@ export interface Translations {disableRuntime: string;enableAfterInstall: string;enableRuntime: string;+ toggleTakesEffectNextSession: string;forceReinstall: string;headline: string;identifierLabel: string;diff --git a/web/src/i18n/uk.ts b/web/src/i18n/uk.tsindex 7a5810432a6..41f2f807bda 100644--- a/web/src/i18n/uk.ts+++ b/web/src/i18n/uk.ts@@ -325,6 +325,8 @@ export const uk: Translations = {disableRuntime: "Вимкнути",enableAfterInstall: "Увімкнути після встановлення",enableRuntime: "Увімкнути",+ toggleTakesEffectNextSession:+ "Збережено — набуде чинності для нових сесій. Перезапустіть шлюз, щоб застосувати всюди.",forceReinstall: "Примусово перевстановити (спершу видалити наявну теку)",headline:"Знаходьте, встановлюйте, вмикайте та оновлюйте плагіни Hermes (паритет з `hermes plugins`).",diff --git a/web/src/i18n/zh-hant.ts b/web/src/i18n/zh-hant.tsindex a08c9febf87..ab6dbb9d651 100644--- a/web/src/i18n/zh-hant.ts+++ b/web/src/i18n/zh-hant.ts@@ -323,6 +323,8 @@ export const zhHant: Translations = {disableRuntime: "停用",enableAfterInstall: "安裝後啟用",enableRuntime: "啟用",+ toggleTakesEffectNextSession:+ "已儲存 — 對新工作階段生效。重新啟動閘道以套用到所有工作階段。",forceReinstall: "強制重新安裝(先刪除既有資料夾)",headline:"探索、安裝、啟用並更新 Hermes 外掛(對齊 `hermes plugins` CLI)。",diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.tsindex 76d7dcd23d9..4a233b9932d 100644--- a/web/src/i18n/zh.ts+++ b/web/src/i18n/zh.ts@@ -320,6 +320,8 @@ export const zh: Translations = {disableRuntime: "禁用",enableAfterInstall: "安装后启用",enableRuntime: "启用",+ toggleTakesEffectNextSession:+ "已保存 — 对新会话生效。重启网关以应用到所有会话。",forceReinstall: "强制重装(先删除已有目录)",headline: "发现、安装、启用和更新 Hermes 插件(对齐 `hermes plugins` CLI)。",identifierLabel: "Git 地址或 owner/repo",diff --git a/web/src/lib/api.ts b/web/src/lib/api.tsindex 16fb2f04930..c2e02765b2f 100644--- a/web/src/lib/api.ts+++ b/web/src/lib/api.ts@@ -1056,16 +1056,24 @@ export const api = {}),enableAgentPlugin: (name: string) =>- fetchJSON<{ ok: boolean; name: string; unchanged?: boolean }>(- `/api/dashboard/agent-plugins/${pluginPath(name)}/enable`,- { method: "POST" },- ),+ fetchJSON<{+ ok: boolean;+ name: string;+ unchanged?: boolean;+ restart_required?: boolean;+ }>(`/api/dashboard/agent-plugins/${pluginPath(name)}/enable`, {+ method: "POST",+ }),disableAgentPlugin: (name: string) =>- fetchJSON<{ ok: boolean; name: string; unchanged?: boolean }>(- `/api/dashboard/agent-plugins/${pluginPath(name)}/disable`,- { method: "POST" },- ),+ fetchJSON<{+ ok: boolean;+ name: string;+ unchanged?: boolean;+ restart_required?: boolean;+ }>(`/api/dashboard/agent-plugins/${pluginPath(name)}/disable`, {+ method: "POST",+ }),updateAgentPlugin: (name: string) =>fetchJSON<AgentPluginUpdateResponse>(diff --git a/web/src/pages/PluginsPage.tsx b/web/src/pages/PluginsPage.tsxindex 652f3d16812..809f3487f52 100644--- a/web/src/pages/PluginsPage.tsx+++ b/web/src/pages/PluginsPage.tsx@@ -1123,8 +1123,13 @@ function PluginRowCard(props: PluginRowCardProps) {size="sm"onClick={() => {void setRuntimeLoading(row.name, async () => {- await api.disableAgentPlugin(row.name);- showToast(t.pluginsPage.disableRuntime, "success");+ const res = await api.disableAgentPlugin(row.name);+ showToast(+ res.restart_required+ ? t.pluginsPage.toggleTakesEffectNextSession+ : t.pluginsPage.disableRuntime,+ "success",+ );});}}>@@ -1137,8 +1142,13 @@ function PluginRowCard(props: PluginRowCardProps) {size="sm"onClick={() => {void setRuntimeLoading(row.name, async () => {- await api.enableAgentPlugin(row.name);- showToast(t.pluginsPage.enableRuntime, "success");+ const res = await api.enableAgentPlugin(row.name);+ showToast(+ res.restart_required+ ? t.pluginsPage.toggleTakesEffectNextSession+ : t.pluginsPage.enableRuntime,+ "success",+ );});}}>