diff options
| author | Adam Malczewski <[email protected]> | 2026-10-23 01:39:03 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-10-23 01:39:03 +0900 |
| commit | 330d8e2ba81460ddd1ab1e9cb753fc1fbe5a4a62 (patch) | |
| tree | fa3a11a100136f102d5ee26404cb2ec5192ce43a /src/core/chunks/trim.ts | |
| parent | 511d415b4ec07d435ea73ab8e5421949392d922d (diff) | |
| parent | 75680eac7071c6968eaa5470686ad102a82103db (diff) | |
| download | dispatch-web-330d8e2ba81460ddd1ab1e9cb753fc1fbe5a4a62.tar.gz dispatch-web-330d8e2ba81460ddd1ab1e9cb753fc1fbe5a4a62.zip | |
Merge branch 'feature/fix-ongoing-chat-tool-calls' into dev
Diffstat (limited to 'src/core/chunks/trim.ts')
| -rw-r--r-- | src/core/chunks/trim.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/core/chunks/trim.ts b/src/core/chunks/trim.ts index 259c101..6612bfe 100644 --- a/src/core/chunks/trim.ts +++ b/src/core/chunks/trim.ts @@ -14,6 +14,7 @@ // "Show earlier messages" affordance knows where to page back in from. import type { StoredChunk } from "@dispatch/wire"; +import { selectRenderedCount } from "./selectors"; import type { TranscriptState } from "./types"; /** Default chat limit (max loaded chunks per conversation). */ @@ -46,9 +47,14 @@ export function initialWindowSize(limit: number): number { return Math.max(1, Math.floor(limit * 0.75)); } -/** Total loaded (rendered) chunk count: committed + provisional + accumulating. */ +/** + * Total loaded (rendered) chunk count: committed + provisional + accumulating, + * EXCLUDING provisional replay duplicates of committed chunks (a late-join + * replay re-delivers an in-flight turn's already-persisted steps). Counting + * those invisible duplicates unloaded real history to make room for them. + */ function totalCount(state: TranscriptState): number { - return state.committed.length + state.provisional.length + (state.accumulating !== null ? 1 : 0); + return selectRenderedCount(state); } function countThinking(chunks: readonly StoredChunk[]): number { |
