fix(webui): complete temporary chat mode

This commit is contained in:
chengyongru
2026-08-07 17:07:58 +08:00
parent 324a61dff1
commit 36253685bd
51 changed files with 1285 additions and 945 deletions
-53
View File
@@ -140,59 +140,6 @@ def test_webui_default_access_applies_to_unscoped_old_sessions(tmp_path, monkeyp
assert new_scope.access_mode == "full"
def test_transient_session_defaults_to_restricted_access(tmp_path, monkeypatch) -> None:
monkeypatch.setattr("nanobot.webui.workspaces.get_webui_dir", lambda: tmp_path / "webui")
default = tmp_path / "default"
default.mkdir()
write_webui_default_access_mode("full")
sessions = SessionManager(tmp_path / "sessions")
key = "websocket:temporary-default"
sessions.get_or_create_transient(key)
controller = WebUIWorkspaceController(
session_manager=sessions,
default_workspace=default,
default_restrict_to_workspace=False,
)
scope = controller.scope_for_message(
{},
chat_id="temporary-default",
chat_running=False,
controls_available=True,
)
assert scope.project_path == default.resolve()
assert scope.access_mode == "restricted"
def test_transient_session_uses_live_scope_during_active_turn(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()
write_webui_default_access_mode("full")
sessions = SessionManager(tmp_path / "sessions")
sessions.get_or_create_transient("websocket:temporary-scoped")
controller = WebUIWorkspaceController(
session_manager=sessions,
default_workspace=default,
default_restrict_to_workspace=False,
)
restricted = default_workspace_scope(project, restrict_to_workspace=True)
controller.persist_scope("temporary-scoped", restricted)
scope = controller.scope_for_message(
{WORKSPACE_SCOPE_METADATA_KEY: restricted.payload()},
chat_id="temporary-scoped",
chat_running=True,
controls_available=True,
)
assert scope.project_path == project.resolve()
assert scope.access_mode == "restricted"
def test_indexed_scope_preserves_missing_and_explicit_null_semantics(tmp_path, monkeypatch) -> None:
monkeypatch.setattr("nanobot.webui.workspaces.get_webui_dir", lambda: tmp_path / "webui")
default = tmp_path / "default"