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:
@@ -102,6 +102,22 @@ test("单一协作入口展示任务引用,保留草稿且仅手动发送,
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
await mockWorkbenchContext(page);
|
||||
await mockAgentApi(page, { sessions: [{ session_id: "ordinary-main", title: "供水核查主聊天", purpose: "ordinary_chat", created_at: now, updated_at: now }] });
|
||||
let collaborationOpens = 0;
|
||||
const renamedCollaborationTitle = "异味投诉现场复核记录";
|
||||
let finishReopen!: () => void;
|
||||
const reopenGate = new Promise<void>((resolve) => { finishReopen = resolve; });
|
||||
await page.route(`**/task/${taskId}/collaboration/session`, async (route) => {
|
||||
collaborationOpens += 1;
|
||||
if (collaborationOpens === 2) await reopenGate;
|
||||
return route.fulfill({ headers: { "Access-Control-Allow-Origin": "*" }, json: {
|
||||
session_id: `collaboration-${taskId}`, purpose: "task_collaboration", task_id: taskId,
|
||||
title: collaborationOpens <= 2 ? task.title : renamedCollaborationTitle,
|
||||
created: collaborationOpens === 1, status: "active",
|
||||
} });
|
||||
});
|
||||
await page.route(`**/session/collaboration-${taskId}/title`, (route) => route.fulfill({
|
||||
headers: { "Access-Control-Allow-Origin": "*" }, json: { id: `collaboration-${taskId}`, title: route.request().postDataJSON().title },
|
||||
}));
|
||||
let submitted = 0;
|
||||
let inboxReads = 0;
|
||||
let incoming = false;
|
||||
@@ -146,7 +162,7 @@ test("单一协作入口展示任务引用,保留草稿且仅手动发送,
|
||||
await expect(feed.getByRole("button", { name: "Agent 协作", exact: true })).toHaveAttribute("title", "打开调查协作对话,引用此任务,不会直接发送。");
|
||||
await feed.screenshot({ path: testInfo.outputPath("investigation-entry-desktop.png") });
|
||||
await feed.getByRole("button", { name: "Agent 协作", exact: true }).click();
|
||||
await expect(agent.getByText("任务协作问答", { exact: true }).first()).toBeVisible();
|
||||
await expect(agent.locator(".agent-chat-context-bar > p")).toHaveText(task.title);
|
||||
const reference = agent.getByRole("group", { name: "对话引用" });
|
||||
await expect(reference).toContainText("居民异味投诉调查");
|
||||
await expect(reference).toContainText("第 1 轮 · 报告第 3 版");
|
||||
@@ -156,6 +172,18 @@ test("单一协作入口展示任务引用,保留草稿且仅手动发送,
|
||||
await expect(prompt).toBeFocused();
|
||||
expect(submitted).toBe(0);
|
||||
await feed.getByRole("button", { name: "Agent 协作", exact: true }).click();
|
||||
await expect.poll(() => collaborationOpens).toBe(2);
|
||||
await agent.getByRole("button", { name: "打开 Agent 历史记录" }).click();
|
||||
const renameDialog = page.getByRole("dialog", { name: "历史对话" });
|
||||
await renameDialog.getByRole("button", { name: `会话操作:${task.title}` }).click();
|
||||
await page.getByRole("menuitem", { name: "重命名对话", exact: true }).click();
|
||||
await renameDialog.getByRole("textbox", { name: "会话标题", exact: true }).fill(renamedCollaborationTitle);
|
||||
await renameDialog.getByRole("button", { name: "保存对话标题" }).click();
|
||||
await expect(renameDialog.locator("button.agent-history-session-trigger").filter({ hasText: renamedCollaborationTitle })).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
finishReopen();
|
||||
await expect(prompt).toBeFocused();
|
||||
await expect(agent.locator(".agent-chat-context-bar > p")).toHaveText(renamedCollaborationTitle);
|
||||
await expect(prompt).toBeFocused();
|
||||
await expect(prompt).toHaveValue("保留的现场补充草稿");
|
||||
await feed.getByLabel("主要依据").getByRole("button", { name: "围绕此证据提问" }).click();
|
||||
@@ -200,6 +228,7 @@ test("单一协作入口展示任务引用,保留草稿且仅手动发送,
|
||||
await expect(mobileAgent.getByRole("button", { name: "停止 Agent 分析" })).toHaveCount(0);
|
||||
incoming = true;
|
||||
await mobileAgent.getByRole("button", { name: "打开 Agent 历史记录" }).click();
|
||||
await expect(page.getByRole("dialog", { name: "历史对话" }).locator("button.agent-history-session-trigger").filter({ hasText: renamedCollaborationTitle })).toBeVisible();
|
||||
await page.getByRole("dialog", { name: "历史对话" }).getByRole("button", { name: /^供水核查主聊天/ }).click();
|
||||
await expect(mobileAgent.getByRole("group", { name: "对话引用" })).toHaveCount(0);
|
||||
await expect(mobileAgent.getByText("已核对上游监测,请补充现场采样记录。")).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user