summaryrefslogtreecommitdiffhomepage
path: root/src/core/chunks/reducer.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-22 14:18:56 +0900
committerAdam Malczewski <[email protected]>2026-06-22 14:18:56 +0900
commitb3c830237206a319348a0eb7078b49e20f60883b (patch)
tree2eab38e02b5e0ab209185a92e3ac60f54ea56415 /src/core/chunks/reducer.ts
parent4e1d041c0ee34fa1b74b0d5ecbd432cdacf696e9 (diff)
downloaddispatch-web-b3c830237206a319348a0eb7078b49e20f60883b.tar.gz
dispatch-web-b3c830237206a319348a0eb7078b49e20f60883b.zip
fix: trim provisional chunks during long turns (browser stays responsive)
trimTranscript now drops oldest provisional chunks (the in-flight turn) when committed chunks are exhausted. Previously it bailed with drop=0 when committed was empty, allowing unbounded provisional growth during long generating turns (300+ chunks → browser crawls). Root cause of the syncTail approach failing: the kernel emits step-complete (line 360) BEFORE calling onStepComplete (line 542) — chunks are persisted only after tool results come back, not when step-complete fires. So syncTail on step-complete found nothing. Reverted the applyHistory + syncTail-on-step-complete changes from 4e1d041. The new approach is simpler: trim provisional directly in trimTranscript. Dropped chunks are lost temporarily (no Show Earlier) but come back as committed when the turn seals and syncTail fetches everything from the server. 686 tests green.
Diffstat (limited to 'src/core/chunks/reducer.ts')
-rw-r--r--src/core/chunks/reducer.ts11
1 files changed, 0 insertions, 11 deletions
diff --git a/src/core/chunks/reducer.ts b/src/core/chunks/reducer.ts
index 37f0164..035846c 100644
--- a/src/core/chunks/reducer.ts
+++ b/src/core/chunks/reducer.ts
@@ -54,10 +54,8 @@ 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);
@@ -72,15 +70,6 @@ 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 };
}