mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-07 02:48:05 +08:00
fix(workspace): skip archived workspaces in navigation indexes
Archived workspaces are hidden in the picker and rejected by the catalog resolve path, but read_workspace_indexes() still polled them, logging a traceback and reporting them as unavailable on every navigation request. Signed-off-by: Eapp1e <163811520+Eapp1e@users.noreply.github.com>
This commit is contained in:
@@ -23,7 +23,14 @@ async def read_workspace_indexes(
|
||||
) -> tuple[list[dict[str, Any]], list[str]]:
|
||||
catalog = get_content_workspace_service().list_workspaces()
|
||||
names = {row["workspace_id"]: row["display_name"] for row in catalog}
|
||||
ids = [""] + [row["workspace_id"] for row in catalog if row["kind"] == "workspace"]
|
||||
# Archived workspaces are hidden everywhere else (the picker and the
|
||||
# catalog resolve path both skip them), so polling them here only reports
|
||||
# a folder the learner has already retired.
|
||||
ids = [""] + [
|
||||
row["workspace_id"]
|
||||
for row in catalog
|
||||
if row["kind"] == "workspace" and not row.get("archived")
|
||||
]
|
||||
rows: list[dict[str, Any]] = []
|
||||
unavailable: list[str] = []
|
||||
for workspace_id in dict.fromkeys(ids):
|
||||
|
||||
@@ -100,6 +100,28 @@ async def test_an_offline_workspace_does_not_hide_other_history(account):
|
||||
assert offline["workspace_id"] in index["unavailable_workspaces"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_an_archived_workspace_is_not_polled(account):
|
||||
from pathlib import Path
|
||||
|
||||
archived = account.create_workspace("Archived")
|
||||
Path(archived["path"]).rename(Path(archived["path"]).with_name("archived-moved"))
|
||||
account.update_workspace(archived["workspace_id"], archived=True)
|
||||
index = await session_index(50, 0)
|
||||
assert archived["workspace_id"] not in index["unavailable_workspaces"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_an_archived_workspace_is_not_polled(account):
|
||||
from pathlib import Path
|
||||
|
||||
archived = account.create_workspace("Archived")
|
||||
Path(archived["path"]).rename(Path(archived["path"]).with_name("archived-moved"))
|
||||
account.update_workspace(archived["workspace_id"], archived=True)
|
||||
index = await session_index(50, 0)
|
||||
assert archived["workspace_id"] not in index["unavailable_workspaces"]
|
||||
|
||||
|
||||
def test_move_rejects_combined_changes_before_mutating_either_store(account, scoped_client):
|
||||
target = account.create_workspace("Target")["workspace_id"]
|
||||
with workspace_context(""):
|
||||
|
||||
Reference in New Issue
Block a user