From c9ea9fc5c1538f23cecb1043807671731a5db571 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Thu, 2 Oct 2025 11:16:38 +0000 Subject: [PATCH] fix: add checkpoints at task start, attempt_completion, and mode switch - Add checkpoint creation at task start to allow reverting to the beginning - Add checkpoint creation when attempt_completion is called to mark task completion - Add checkpoint creation before mode switches to preserve state before mode change - All checkpoints use suppressMessage flag to keep timeline clean Fixes #8458 --- src/core/task/Task.ts | 5 +++++ src/core/tools/attemptCompletionTool.ts | 5 +++++ src/core/tools/switchModeTool.ts | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 851df91e6c..098234962e 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -1219,6 +1219,11 @@ export class Task extends EventEmitter implements TaskLike { // Task starting + // Create a checkpoint at task start to allow reverting to the beginning + // Use allowEmpty=true to ensure checkpoint is created even with no file changes + // Suppress the checkpoint_saved chat row to keep the timeline clean + await this.checkpointSave(true, true) + await this.initiateTaskLoop([ { type: "text", diff --git a/src/core/tools/attemptCompletionTool.ts b/src/core/tools/attemptCompletionTool.ts index 5074d7f4e8..f456751acc 100644 --- a/src/core/tools/attemptCompletionTool.ts +++ b/src/core/tools/attemptCompletionTool.ts @@ -89,6 +89,11 @@ export async function attemptCompletionTool( cline.consecutiveMistakeCount = 0 + // Create a checkpoint when task is completed + // Use allowEmpty=true to ensure checkpoint is created even with no file changes + // Suppress the checkpoint_saved chat row to keep the timeline clean + await cline.checkpointSave(true, true) + // Command execution is permanently disabled in attempt_completion // Users must use execute_command tool separately before attempt_completion await cline.say("completion_result", result, undefined, false) diff --git a/src/core/tools/switchModeTool.ts b/src/core/tools/switchModeTool.ts index 8ce906b41f..5ccf6000bd 100644 --- a/src/core/tools/switchModeTool.ts +++ b/src/core/tools/switchModeTool.ts @@ -61,6 +61,11 @@ export async function switchModeTool( return } + // Create a checkpoint before switching modes + // Use allowEmpty=true to ensure checkpoint is created even with no file changes + // Suppress the checkpoint_saved chat row to keep the timeline clean + await cline.checkpointSave(true, true) + // Switch the mode using shared handler await cline.providerRef.deref()?.handleModeSwitch(mode_slug)