From 0c0f366b3820136c9877f80005939011c30b2de4 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Wed, 21 Oct 2026 02:56:48 +0900 Subject: fix(review-4.4): tolerate additive terminal turn events --- src/core/chunks/reducer.test.ts | 10 ++++++++++ src/core/chunks/reducer.ts | 3 +++ 2 files changed, 13 insertions(+) (limited to 'src/core/chunks') diff --git a/src/core/chunks/reducer.test.ts b/src/core/chunks/reducer.test.ts index cba6fad..ae0aa73 100644 --- a/src/core/chunks/reducer.test.ts +++ b/src/core/chunks/reducer.test.ts @@ -1051,3 +1051,13 @@ describe("turnId provenance on live chunks", () => { expect(selectChunks(s).map((c) => c.turnId)).toEqual(["t9", undefined]); }); }); + +describe("foldEvent — additive wire compatibility", () => { + it.each(["turn-ended", "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" }; + expect(foldEvent(state, event as Parameters[1])).toBe(state); + expect(state).toEqual(before); + }); +}); diff --git a/src/core/chunks/reducer.ts b/src/core/chunks/reducer.ts index 4eb08c1..0af2ddd 100644 --- a/src/core/chunks/reducer.ts +++ b/src/core/chunks/reducer.ts @@ -408,6 +408,9 @@ function reduceEvent(state: TranscriptState, event: AgentEvent): TranscriptState // (already true from `turn-start`) is left untouched. return { ...state, providerRetry: event }; } + + default: + return state; // Forward-compatible with additive wire events. } } -- cgit v1.2.3