fix: 岗位会商历史按用户隔离,并为 write-file 预览启用 AI 写作视图
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8c3d6a02fc
commit
8ce3a62826
5 files changed
+67
-38
No files matched your search
@@ -526,40 +526,48 @@ async def test_conversation_snapshots_round_trip_and_history_delete_removes_node
|
||||
assert saved_node is not None
|
||||
assert saved_node["conversation_snapshot"] == node_conversation
|
||||
|
||||
# Position roundtable history is shared by taskId, so a collaborator can
|
||||
# read and remove the same task conversation without being its creator.
|
||||
assert await store.get_session(created["id"], "user-b") is not None
|
||||
assert await store.delete_session(created["id"], "user-b")
|
||||
# History is partitioned by creator: another user working the same taskId
|
||||
# can neither read nor remove this conversation.
|
||||
assert await store.get_session(created["id"], "user-b") is None
|
||||
assert not await store.delete_session(created["id"], "user-b")
|
||||
assert await store.get_session(created["id"], "user-a") is not None
|
||||
assert await store.delete_session(created["id"], "user-a")
|
||||
assert await store.get_session(created["id"], "user-a") is None
|
||||
assert await store.list_nodes(created["id"], "user-a") is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_task_scoped_history_is_shared_but_never_mixes_tasks(store):
|
||||
shared = await store.create_session(
|
||||
async def test_task_scoped_history_is_partitioned_by_user_but_never_mixes_tasks(store):
|
||||
creator_session = await store.create_session(
|
||||
"user-a",
|
||||
external_task_id="external-task-100",
|
||||
task_snapshot={"id": "external-task-100", "title": "共享任务"},
|
||||
)
|
||||
await store.create_session(
|
||||
"user-b",
|
||||
external_task_id="external-task-200",
|
||||
task_snapshot={"id": "external-task-200", "title": "另一任务"},
|
||||
)
|
||||
|
||||
visible_to_creator = await store.list_sessions(
|
||||
"user-a", external_task_id="external-task-100"
|
||||
)
|
||||
assert [row["id"] for row in visible_to_creator] == [creator_session["id"]]
|
||||
|
||||
# The same taskId no longer exposes another user's rows: a collaborator
|
||||
# starts from an empty list and only ever sees rows they created.
|
||||
assert await store.list_sessions("user-b", external_task_id="external-task-100") == []
|
||||
collaborator_session = await store.create_session(
|
||||
"user-b",
|
||||
external_task_id="external-task-100",
|
||||
task_snapshot={"id": "external-task-100", "title": "协作者自己的会话"},
|
||||
)
|
||||
visible_to_collaborator = await store.list_sessions(
|
||||
"user-b", external_task_id="external-task-100"
|
||||
)
|
||||
assert [row["id"] for row in visible_to_collaborator] == [shared["id"]]
|
||||
assert [row["id"] for row in visible_to_collaborator] == [collaborator_session["id"]]
|
||||
|
||||
updated = await store.update_session(
|
||||
shared["id"],
|
||||
assert await store.update_session(
|
||||
creator_session["id"],
|
||||
"user-b",
|
||||
task_snapshot={"id": "external-task-100", "title": "协作者已更新"},
|
||||
)
|
||||
assert updated is not None
|
||||
assert updated["task_snapshot"]["title"] == "协作者已更新"
|
||||
assert (await store.get_session(shared["id"], "user-a"))["task_snapshot"]["title"] == "协作者已更新"
|
||||
) is None
|
||||
assert (await store.get_session(creator_session["id"], "user-a"))["task_snapshot"]["title"] == "共享任务"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -577,7 +585,7 @@ async def test_unscoped_history_keeps_original_user_isolation(store):
|
||||
|
||||
# Old client records could already carry a mock task id. The new database
|
||||
# marker keeps them personal after the migration; only a new explicit
|
||||
# route taskId creates a shared row.
|
||||
# route taskId creates a task-bound row.
|
||||
legacy_with_mock_task_id = await store.create_session(
|
||||
"user-a",
|
||||
external_task_id="legacy-mock-task-id",
|
||||
|
||||
Reference in new issue
Block a user