conversation-session-v4-edit.test.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // PV4-11:stable compact 覆盖 latest user query 后,edit 仍在原 session 做 branch cut。
  2. // compact summary 与旧回复退出 active branch,模型只收到编辑后的 intent,不创建 child,
  3. // 不注入 rewind reminder;UI 与 cold transcript 都以 branch cut 为第一层权威。
  4. import { TID_V4_COMPOSER_INPUT } from "@zcode/shared/test-ids";
  5. import { clearAppData, setInputValueByTestIdDom } from "#e2e/helpers/desktop-app";
  6. import {
  7. clickV4Send,
  8. editFirstV4UserQuery,
  9. getV4PaneSnapshot,
  10. prepareV4ConversationE2E,
  11. sendV4Prompt,
  12. waitForV4CompactMarker,
  13. waitForV4Edit,
  14. waitForV4Pane,
  15. waitForV4TimelineContaining,
  16. } from "#e2e/helpers/v4-conversation";
  17. describe("PV4-11 compact-covered editUserQuery", () => {
  18. after(async () => {
  19. await browser.electron.restoreAllMocks();
  20. await clearAppData();
  21. });
  22. it("compact 后 edit → 原 session branch cut,无旧分支和 reminder", async () => {
  23. await prepareV4ConversationE2E();
  24. await sendV4Prompt("E2E_V4_EDIT_ORIGINAL 原始问题");
  25. await waitForV4TimelineContaining("V4_EDIT_ORIGINAL_REPLY", 60000);
  26. const original = await waitForV4Pane(
  27. (s) => s.sessionId !== "draft" && s.sessionId !== null,
  28. "首发后没有绑定 session",
  29. );
  30. const originalSessionId = original.sessionId;
  31. await setInputValueByTestIdDom(TID_V4_COMPOSER_INPUT, "/compact", {
  32. timeout: 15000,
  33. timeoutMsg: "composer 输入框没有出现",
  34. });
  35. await clickV4Send();
  36. await waitForV4CompactMarker({ origin: "manual", status: "success" }, 90000);
  37. // UI history 不被 compact scope 截断;latest real-user row 仍可编辑。
  38. await waitForV4Edit();
  39. await editFirstV4UserQuery("E2E_V4_EDIT_NEWTEXT 编辑后的问题");
  40. // 编辑后:该轮被 newText 替换并重跑 → 新回复出现,原回复消失。
  41. await waitForV4TimelineContaining("V4_EDIT_NEW_REPLY", 60000);
  42. const finalSnapshot = await getV4PaneSnapshot();
  43. expect(finalSnapshot.sessionId).toBe(originalSessionId);
  44. expect(finalSnapshot.timelineText).toContain("V4_EDIT_NEW_REPLY");
  45. expect(finalSnapshot.timelineText).not.toContain("V4_EDIT_ORIGINAL_REPLY");
  46. expect(finalSnapshot.timelineText).not.toContain("E2E_V4_EDIT_ORIGINAL");
  47. expect(finalSnapshot.timelineText).not.toContain("Conversation rewind applied");
  48. });
  49. });