Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

test(ai): rewind an earlier message after a later one in its own test

EtienneLescot94c0511d2937
diff --git a/electron/ai-edition/chat-persistence.test.ts b/electron/ai-edition/chat-persistence.test.ts
index 8c57b01a5..782ed579d 100644
--- a/electron/ai-edition/chat-persistence.test.ts
+++ b/electron/ai-edition/chat-persistence.test.ts
@@ -116,8 +116,6 @@ describe("local Agent chat history", () => {
expect(undo.success && undo.prompt).toBe("add an annotation and a zoom");
const kept = selectSession("proj_rewound", session.id)?.messages;
expect(kept?.map((m) => m.content)).toEqual(["smart cuts", "reply"]);
- // The earlier message can still be rewound.
- expect(kept?.[0]?.checkpointId).toBeTruthy();
await flushChatPersistence();
expect(readFileSync(path.join(root, "proj_rewound.chat.json"), "utf8")).not.toContain(
"add an annotation",
@@ -130,6 +128,18 @@ describe("local Agent chat history", () => {
expect(payload).not.toContain("add an annotation and a zoom");
});
+ it("still rewinds an earlier message after a later one was rewound", async () => {
+ const session = createSession("proj_rewind_twice");
+ const document = createEmptyDocument({ title: "Test", projectId: "proj_rewind_twice" });
+ await runChat("proj_rewind_twice", session.id, "smart cuts", config(), document);
+ await runChat("proj_rewind_twice", session.id, "add a zoom", config(), document);
+ const second = selectSession("proj_rewind_twice", session.id)?.messages[2];
+ expect(rewindToMessage("proj_rewind_twice", session.id, second?.id ?? "").success).toBe(true);
+ const first = selectSession("proj_rewind_twice", session.id)?.messages[0];
+ const undo = rewindToMessage("proj_rewind_twice", session.id, first?.id ?? "");
+ expect(undo.success && undo.prompt).toBe("smart cuts");
+ });
+
it("restores compaction boundary for the model while keeping the full transcript", async () => {
modelMock.mockImplementation(
async () =>