Fix WebUI startup blocking on slow gateway routes

This commit is contained in:
chengyongru
2026-06-13 21:59:36 +08:00
committed by Xubin Ren
parent 3a221d74cf
commit af0e3441d7
12 changed files with 280 additions and 17 deletions
+30 -1
View File
@@ -7,8 +7,8 @@ from nanobot.webui.workspaces import (
read_webui_default_access_mode,
read_webui_workspace_state,
webui_workspace_state_path,
write_webui_default_access_mode,
workspaces_payload,
write_webui_default_access_mode,
)
@@ -152,3 +152,32 @@ def test_webui_default_access_does_not_override_explicit_session_scope(tmp_path,
assert scope.project_path == project.resolve()
assert scope.access_mode == "full"
def test_scope_for_session_key_reads_metadata_without_full_history(
tmp_path,
monkeypatch,
) -> None:
monkeypatch.setattr("nanobot.webui.workspaces.get_webui_dir", lambda: tmp_path / "webui")
default = tmp_path / "default"
project = tmp_path / "project"
default.mkdir()
project.mkdir()
sessions = SessionManager(tmp_path / "sessions")
controller = WebUIWorkspaceController(
session_manager=sessions,
default_workspace=default,
default_restrict_to_workspace=True,
)
explicit = default_workspace_scope(project, restrict_to_workspace=False)
controller.persist_scope("metadata-only", explicit)
def fail_full_read(_key: str) -> None:
raise AssertionError("scope lookup should not read full session history")
monkeypatch.setattr(sessions, "read_session_file", fail_full_read)
scope = controller.scope_for_session_key("websocket:metadata-only")
assert scope.project_path == project.resolve()
assert scope.access_mode == "full"