From ac43e92d174ed1f081c387944e9044643ee9efc2 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Wed, 21 Oct 2026 15:36:54 +0900 Subject: fix(review-followup-fee): recover omitted chat payloads through history --- src/core/chunks/reducer.test.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/core/chunks/reducer.test.ts') diff --git a/src/core/chunks/reducer.test.ts b/src/core/chunks/reducer.test.ts index ae0aa73..22b94d4 100644 --- a/src/core/chunks/reducer.test.ts +++ b/src/core/chunks/reducer.test.ts @@ -1053,7 +1053,7 @@ describe("turnId provenance on live chunks", () => { }); describe("foldEvent — additive wire compatibility", () => { - it.each(["turn-ended", "future-event"])("preserves transcript identity for %s", (type) => { + it.each(["future-event"])("preserves transcript identity for %s", (type) => { const state = foldEvent(foldEvent(initialState(), turnStart("t1")), textDelta("t1", "partial")); const before = structuredClone(state); const event = { type, conversationId: "c1", turnId: "t1", reason: "sealed" }; @@ -1061,3 +1061,27 @@ describe("foldEvent — additive wire compatibility", () => { expect(state).toEqual(before); }); }); + +describe("foldEvent — authoritative turn terminal", () => { + it.each([ + "sealed", + "aborted", + "error", + "rejected", + ] as const)("ends generation on %s", (reason) => { + const before = foldEvent( + foldEvent(initialState(), turnStart("t1")), + textDelta("t1", "partial"), + ); + const next = foldEvent(before, { + type: "turn-ended", + conversationId: "c1", + turnId: "t1", + reason, + }); + expect(next.generating).toBe(false); + expect(next.accumulating).toBeNull(); + expect(selectChunks(next).map((c) => c.chunk)).toEqual([{ type: "text", text: "partial" }]); + expect(before.accumulating?.text).toBe("partial"); + }); +}); -- cgit v1.2.3