summaryrefslogtreecommitdiffhomepage
path: root/src/core/chunks/reducer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/chunks/reducer.ts')
-rw-r--r--src/core/chunks/reducer.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/chunks/reducer.ts b/src/core/chunks/reducer.ts
index 035846c..37f0164 100644
--- a/src/core/chunks/reducer.ts
+++ b/src/core/chunks/reducer.ts
@@ -54,8 +54,10 @@ export function applyHistory(
): TranscriptState {
const seqMap = new Map<number, StoredChunk>();
for (const c of state.committed) seqMap.set(c.seq, c);
+ let addedNew = false;
for (const c of chunks) {
if (c.seq < state.hiddenBeforeSeq) continue;
+ if (!seqMap.has(c.seq)) addedNew = true;
seqMap.set(c.seq, c);
}
const committed = Array.from(seqMap.values()).sort((a, b) => a.seq - b.seq);
@@ -70,6 +72,15 @@ export function applyHistory(
};
}
+ // During generation: if new committed chunks arrived (CR-6 — backend
+ // persists at step boundaries), clear provisional chunks. They're
+ // duplicates — the same content was folded from live events but is now
+ // persisted with seq. Keep the accumulating chunk (current in-progress
+ // step, not yet persisted).
+ if (addedNew && state.generating) {
+ return { ...state, committed, provisional: [], accumulating: state.accumulating };
+ }
+
return { ...state, committed };
}