summaryrefslogtreecommitdiffhomepage
path: root/src/core/chunks/reducer.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/chunks/reducer.test.ts')
-rw-r--r--src/core/chunks/reducer.test.ts26
1 files changed, 25 insertions, 1 deletions
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");
+ });
+});