Skip to content

Commit c9ea9fc

Browse files
committed
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
1 parent 13534cc commit c9ea9fc

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/core/task/Task.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,11 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
12191219

12201220
// Task starting
12211221

1222+
// Create a checkpoint at task start to allow reverting to the beginning
1223+
// Use allowEmpty=true to ensure checkpoint is created even with no file changes
1224+
// Suppress the checkpoint_saved chat row to keep the timeline clean
1225+
await this.checkpointSave(true, true)
1226+
12221227
await this.initiateTaskLoop([
12231228
{
12241229
type: "text",

src/core/tools/attemptCompletionTool.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ export async function attemptCompletionTool(
8989

9090
cline.consecutiveMistakeCount = 0
9191

92+
// Create a checkpoint when task is completed
93+
// Use allowEmpty=true to ensure checkpoint is created even with no file changes
94+
// Suppress the checkpoint_saved chat row to keep the timeline clean
95+
await cline.checkpointSave(true, true)
96+
9297
// Command execution is permanently disabled in attempt_completion
9398
// Users must use execute_command tool separately before attempt_completion
9499
await cline.say("completion_result", result, undefined, false)

src/core/tools/switchModeTool.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ export async function switchModeTool(
6161
return
6262
}
6363

64+
// Create a checkpoint before switching modes
65+
// Use allowEmpty=true to ensure checkpoint is created even with no file changes
66+
// Suppress the checkpoint_saved chat row to keep the timeline clean
67+
await cline.checkpointSave(true, true)
68+
6469
// Switch the mode using shared handler
6570
await cline.providerRef.deref()?.handleModeSwitch(mode_slug)
6671

0 commit comments

Comments
 (0)