fix(webui): delete unpersisted pane sessions (#5624)

Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
Kail Tianandchengyongru authored and GitHub committed 2026-09-02 13:05:36 +08:00
1 parent 9ecdc4533f
commit 042f96f6ba
5 files changed
+108 -3

No files matched your search

@@ -2333,6 +2333,48 @@ async def test_session_delete_removes_transcript_without_canonical_file(
await server_task
@pytest.mark.asyncio
async def test_session_delete_removes_unpersisted_new_chat(
bus: MagicMock, tmp_path: Path
) -> None:
sm = SessionManager(tmp_path / "sessions")
project = tmp_path / "project"
project.mkdir()
channel = _ch(bus, session_manager=sm, workspace_path=tmp_path, port=_free_port())
connection = AsyncMock()
connection.remote_address = ("127.0.0.1", 50123)
await channel._dispatch_envelope(
connection,
"webui-client",
{
"type": "new_chat",
"workspace_scope": {
"project_path": str(project),
"access_mode": "full",
},
},
)
attached = next(
payload
for payload in (
json.loads(call.args[0]) for call in connection.send.await_args_list
)
if payload.get("event") == "attached"
)
key = f"websocket:{attached['chat_id']}"
assert sm.list_sessions() == []
assert channel.gateway.workspaces.scope_for_session_key(key).project_path == project.resolve()
response = await _webui_mutate(channel, "session.delete", {"key": key})
assert response.status_code == 200
assert response.json()["deleted"] is True
assert channel.gateway.workspaces.scope_for_session_key(key).project_path == tmp_path.resolve()
@pytest.mark.asyncio
async def test_webui_automations_route_lists_all_jobs_and_allows_user_actions(
bus: MagicMock, tmp_path: Path