fix: synchronize task collaboration session titles

Apply creation titles and repaired history names to cached sessions.
Keep messages and reading state intact and preserve title edits received
while a collaboration request is in flight.

Validation: pnpm lint; pnpm typecheck; 604 unit tests; two browser regressions.
This commit is contained in:
2026-10-29 16:55:31 +08:00
parent 5b710d1247
commit 7621bf0f86
4 changed files with 79 additions and 1 deletions
+27
View File
@@ -5,6 +5,33 @@ import { createServer, type ServerResponse } from "node:http";
import { responseFixtureWriter } from "./support/responses-fixture";
import { expectThemeColor } from "./support/theme-colors";
test("history repairs a cached collaboration title without reloading its conversation", async ({ page }, testInfo) => {
await page.emulateMedia({ reducedMotion: "reduce" });
await mockWorkbenchContext(page);
const session = { session_id: "collaboration-50000000-0000-4000-8000-000000000001",
purpose: "task_collaboration", title: "任务协作", created_at: Date.now(), updated_at: Date.now() };
await mockAgentApi(page, { sessions: [session] });
let loads = 0;
page.on("request", (request) => {
if (request.method() === "GET" && new URL(request.url()).pathname.endsWith(`/session/${session.session_id}`)) loads += 1;
});
await page.goto("/", { waitUntil: "domcontentloaded" });
await page.getByRole("button", { name: /展开 Agent 助手面板/ }).click();
const panel = page.getByRole("complementary", { name: "Agent 命令面板" });
await panel.getByRole("button", { name: "打开 Agent 历史记录" }).click();
const dialog = page.getByRole("dialog", { name: "历史对话" });
await dialog.locator("button.agent-history-session-trigger").filter({ hasText: "任务协作" }).click();
await expect(panel.locator(".agent-chat-context-bar > p")).toHaveText("任务协作");
session.title = "南桥管道爆管调查";
await panel.getByRole("button", { name: "打开 Agent 历史记录" }).click();
await dialog.getByRole("button", { name: "刷新 Agent 历史记录" }).click();
await expect(dialog.locator("button.agent-history-session-trigger").filter({ hasText: session.title })).toBeVisible();
await page.keyboard.press("Escape");
await expect(panel.locator(".agent-chat-context-bar > p")).toHaveText(session.title);
expect(loads).toBe(1);
await panel.screenshot({ path: testInfo.outputPath("collaboration-title-repaired.png"), animations: "disabled" });
});
async function prepare(page: Page) {
await page.emulateMedia({ reducedMotion: "reduce" });
await mockWorkbenchContext(page);