Skip to content

The agent that grows with you

fix(dashboard): offload plugins hub rebuild

KoNit-K6165b6ebd52d
diff --git a/hermes_cli/web_routers/dashboard_ui.py b/hermes_cli/web_routers/dashboard_ui.py
index 50e3630b065..62736a38f0a 100644
--- a/hermes_cli/web_routers/dashboard_ui.py
+++ b/hermes_cli/web_routers/dashboard_ui.py
@@ -153,7 +153,7 @@ async def get_plugins_hub(request: Request):
"""Unified agent plugins + dashboard extension metadata (session protected)."""
_require_token(request)
try:
- return _merged_plugins_hub()
+ return await asyncio.to_thread(_merged_plugins_hub)
except Exception as exc:
_log.warning("plugins/hub failed: %s", exc)
raise HTTPException(status_code=500, detail="Failed to build plugins hub.") from exc
diff --git a/tests/hermes_cli/test_plugins_hub_perf_guard.py b/tests/hermes_cli/test_plugins_hub_perf_guard.py
index 817a19dbfd1..254a6862ec6 100644
--- a/tests/hermes_cli/test_plugins_hub_perf_guard.py
+++ b/tests/hermes_cli/test_plugins_hub_perf_guard.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import asyncio
import threading
from pathlib import Path
from types import SimpleNamespace
@@ -10,6 +11,7 @@ import hermes_cli.web_routers.dashboard_ui as _rt_dashboard_ui
import hermes_cli.web_server_dashboard as _web_server_dashboard
import hermes_cli.web_server_memory as _web_server_memory
from hermes_cli import plugins_cmd
+from hermes_cli import plugins_cmd_catalog
from tools import registry as tools_registry
@@ -144,6 +146,29 @@ def test_plugins_hub_short_ttl_cache_collapses_duplicate_fetches(monkeypatch):
assert first is second
+def test_plugins_hub_route_builds_catalog_annotations_off_event_loop(monkeypatch):
+ """The synchronous catalog lookup must run in the route's worker thread."""
+ tools_registry.invalidate_check_fn_cache()
+ _web_server_dashboard._invalidate_plugins_hub_cache()
+ event_loop_thread = threading.current_thread()
+ annotation_threads: list[threading.Thread] = []
+
+ _patch_minimal_hub_dependencies(monkeypatch, check_fn=lambda: True)
+ monkeypatch.setattr(web_server, "_require_token", lambda _request: None)
+
+ def removed_annotation(name, _dir_path):
+ annotation_threads.append(threading.current_thread())
+ return "withdrawn by catalog" if name == "demo" else None
+
+ monkeypatch.setattr(plugins_cmd_catalog, "removed_annotation", removed_annotation)
+
+ payload = asyncio.run(_rt_dashboard_ui.get_plugins_hub(object()))
+
+ assert payload["plugins"][0]["removed_reason"] == "withdrawn by catalog"
+ assert annotation_threads == [annotation_threads[0]]
+ assert annotation_threads[0] is not event_loop_thread
+
+
def test_plugin_install_endpoint_invalidates_hub_cache(monkeypatch):
import asyncio