Merge branch 'r-dev' of https://github.com/Mai-with-u/MaiBot into r-dev

This commit is contained in:
SengokuCola
2026-04-17 10:57:22 +08:00
3 changed files with 11 additions and 10 deletions

View File

@@ -1719,7 +1719,7 @@ export function KnowledgeBasePage() {
} }
}, [selectedFeedbackCorrection?.task_id]) }, [selectedFeedbackCorrection?.task_id])
const selectedFeedbackResolved = useMemo(() => { const selectedFeedbackResolved = useMemo<MemoryFeedbackCorrectionDetailTaskPayload | null>(() => {
if (!selectedFeedbackCorrection) { if (!selectedFeedbackCorrection) {
return null return null
} }
@@ -1732,7 +1732,7 @@ export function KnowledgeBasePage() {
return selectedFeedbackTaskDetail ?? selectedFeedbackCorrection return selectedFeedbackTaskDetail ?? selectedFeedbackCorrection
}, [selectedFeedbackCorrection, selectedFeedbackTaskDetail]) }, [selectedFeedbackCorrection, selectedFeedbackTaskDetail])
const selectedFeedbackActionLogs = Array.isArray(selectedFeedbackResolved?.action_logs) const selectedFeedbackActionLogs: MemoryFeedbackActionLogPayload[] = Array.isArray(selectedFeedbackResolved?.action_logs)
? selectedFeedbackResolved.action_logs ? selectedFeedbackResolved.action_logs
: [] : []
const filteredFeedbackActionLogs = useMemo(() => { const filteredFeedbackActionLogs = useMemo(() => {

View File

@@ -79,7 +79,7 @@ def test_resolve_static_path_prefers_installed_dashboard_package(monkeypatch, tm
assert resolved_path == package_dist 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 = tmp_path / "dashboard" / "dist"
dashboard_dist.mkdir(parents=True) dashboard_dist.mkdir(parents=True)
(dashboard_dist / "index.html").write_text("<html></html>", encoding="utf-8") (dashboard_dist / "index.html").write_text("<html></html>", 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): with patch.object(webui_app, "import_module", side_effect=ImportError):
resolved_path = webui_app._resolve_static_path() 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 = tmp_path / "dashboard" / "dist"
dashboard_dist.mkdir(parents=True) dashboard_dist.mkdir(parents=True)

View File

@@ -205,11 +205,12 @@ def _setup_static_files(app: FastAPI):
def _resolve_static_path() -> Path | None: def _resolve_static_path() -> Path | None:
# 开发环境优先允许复用仓库里的现成 dist # 临时仅允许使用已安装的 maibot-dashboard 包,不使用仓库本地 dashboard/dist
base_dir = _get_project_root() # 如需恢复本地回退逻辑,可取消下方注释。
static_path = base_dir / "dashboard" / "dist" # base_dir = _get_project_root()
if static_path.is_dir() and (static_path / "index.html").exists(): # static_path = base_dir / "dashboard" / "dist"
return static_path # if static_path.is_dir() and (static_path / "index.html").exists():
# return static_path
try: try:
module = import_module("maibot_dashboard") module = import_module("maibot_dashboard")