The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
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.pyindex 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 excdiff --git a/tests/hermes_cli/test_plugins_hub_perf_guard.py b/tests/hermes_cli/test_plugins_hub_perf_guard.pyindex 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 asyncioimport threadingfrom pathlib import Pathfrom types import SimpleNamespace@@ -10,6 +11,7 @@ import hermes_cli.web_routers.dashboard_ui as _rt_dashboard_uiimport hermes_cli.web_server_dashboard as _web_server_dashboardimport hermes_cli.web_server_memory as _web_server_memoryfrom hermes_cli import plugins_cmd+from hermes_cli import plugins_cmd_catalogfrom 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