diff --git a/dashboard/src/routes/resource/knowledge-base.tsx b/dashboard/src/routes/resource/knowledge-base.tsx index 5cc3602f..561f8b97 100644 --- a/dashboard/src/routes/resource/knowledge-base.tsx +++ b/dashboard/src/routes/resource/knowledge-base.tsx @@ -1719,7 +1719,7 @@ export function KnowledgeBasePage() { } }, [selectedFeedbackCorrection?.task_id]) - const selectedFeedbackResolved = useMemo(() => { + const selectedFeedbackResolved = useMemo(() => { if (!selectedFeedbackCorrection) { return null } @@ -1732,7 +1732,7 @@ export function KnowledgeBasePage() { return selectedFeedbackTaskDetail ?? selectedFeedbackCorrection }, [selectedFeedbackCorrection, selectedFeedbackTaskDetail]) - const selectedFeedbackActionLogs = Array.isArray(selectedFeedbackResolved?.action_logs) + const selectedFeedbackActionLogs: MemoryFeedbackActionLogPayload[] = Array.isArray(selectedFeedbackResolved?.action_logs) ? selectedFeedbackResolved.action_logs : [] const filteredFeedbackActionLogs = useMemo(() => { diff --git a/pytests/webui/test_app.py b/pytests/webui/test_app.py index 3ef1cfdd..bc7343ea 100644 --- a/pytests/webui/test_app.py +++ b/pytests/webui/test_app.py @@ -79,7 +79,7 @@ def test_resolve_static_path_prefers_installed_dashboard_package(monkeypatch, tm assert resolved_path == package_dist -def test_resolve_static_path_uses_dashboard_dist(monkeypatch, tmp_path) -> None: +def test_resolve_static_path_ignores_dashboard_dist_when_package_is_unavailable(monkeypatch, tmp_path) -> None: dashboard_dist = tmp_path / "dashboard" / "dist" dashboard_dist.mkdir(parents=True) (dashboard_dist / "index.html").write_text("", encoding="utf-8") @@ -89,10 +89,10 @@ def test_resolve_static_path_uses_dashboard_dist(monkeypatch, tmp_path) -> None: with patch.object(webui_app, "import_module", side_effect=ImportError): resolved_path = webui_app._resolve_static_path() - assert resolved_path == dashboard_dist + assert resolved_path is None -def test_resolve_static_path_falls_back_to_package_when_dashboard_dist_has_no_index(monkeypatch, tmp_path) -> None: +def test_resolve_static_path_uses_package_even_when_dashboard_dist_exists(monkeypatch, tmp_path) -> None: dashboard_dist = tmp_path / "dashboard" / "dist" dashboard_dist.mkdir(parents=True) diff --git a/src/webui/app.py b/src/webui/app.py index 366c1c79..54b1288b 100644 --- a/src/webui/app.py +++ b/src/webui/app.py @@ -205,11 +205,12 @@ def _setup_static_files(app: FastAPI): def _resolve_static_path() -> Path | None: - # 开发环境优先允许复用仓库里的现成 dist - base_dir = _get_project_root() - static_path = base_dir / "dashboard" / "dist" - if static_path.is_dir() and (static_path / "index.html").exists(): - return static_path + # 临时仅允许使用已安装的 maibot-dashboard 包,不使用仓库本地 dashboard/dist。 + # 如需恢复本地回退逻辑,可取消下方注释。 + # base_dir = _get_project_root() + # static_path = base_dir / "dashboard" / "dist" + # if static_path.is_dir() and (static_path / "index.html").exists(): + # return static_path try: module = import_module("maibot_dashboard")