Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 845865e

Browse files
committed
fix: record truncation event when condensation fails but truncation succeeds
The else-if chain in attemptApiRequest() prevented both error AND truncation events from being recorded when context condensation fails but sliding window truncation succeeds as a fallback. When manageContext() returns both 'error' (condensation failed) and 'truncationId' (truncation happened as fallback), only the error was shown because of the else-if chain. This meant the sliding_window_truncation clineMessage was never created, breaking rewind functionality since MessageManager.collectRemovedContextEventIds() couldn't find the truncation ID to clean up orphaned truncationParent tags. Fix: Change 'else if' to separate 'if' statements so both events can be recorded, allowing rewind to properly restore hidden messages.
1 parent 7534e19 commit 845865e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/core/task/Task.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4012,7 +4012,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
40124012
}
40134013
if (truncateResult.error) {
40144014
await this.say("condense_context_error", truncateResult.error)
4015-
} else if (truncateResult.summary) {
4015+
}
4016+
if (truncateResult.summary) {
40164017
const { summary, cost, prevContextTokens, newContextTokens = 0, condenseId } = truncateResult
40174018
const contextCondense: ContextCondense = {
40184019
summary,

0 commit comments

Comments
 (0)