Skip to content

Commit 8171b88

Browse files
authored
Fix for checkpoints (RooCodeInc#3993)
1 parent 203f805 commit 8171b88

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

.changeset/breezy-numbers-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": patch
3+
---
4+
5+
Fix for checkpoints

src/core/task/index.ts

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,15 +1229,35 @@ export class Task {
12291229
//
12301230
} else {
12311231
// attempt completion requires checkpoint to be sync so that we can present button after attempt_completion
1232-
const commitHash = await this.checkpointTracker?.commit()
1233-
// For attempt_completion, find the last completion_result message and set its checkpoint hash. This will be used to present the 'see new changes' button
1234-
const lastCompletionResultMessage = findLast(
1235-
this.clineMessages,
1236-
(m) => m.say === "completion_result" || m.ask === "completion_result",
1237-
)
1238-
if (lastCompletionResultMessage) {
1239-
lastCompletionResultMessage.lastCheckpointHash = commitHash
1240-
await this.saveClineMessagesAndUpdateHistory()
1232+
// Check if checkpoint tracker exists, if not, create it
1233+
if (!this.checkpointTracker) {
1234+
try {
1235+
this.checkpointTracker = await CheckpointTracker.create(
1236+
this.taskId,
1237+
this.context.globalStorageUri.fsPath,
1238+
this.enableCheckpoints,
1239+
)
1240+
} catch (error) {
1241+
const errorMessage = error instanceof Error ? error.message : "Unknown error"
1242+
console.error("Failed to initialize checkpoint tracker for attempt completion:", errorMessage)
1243+
return
1244+
}
1245+
}
1246+
1247+
if (this.checkpointTracker) {
1248+
const commitHash = await this.checkpointTracker.commit()
1249+
1250+
// For attempt_completion, find the last completion_result message and set its checkpoint hash. This will be used to present the 'see new changes' button
1251+
const lastCompletionResultMessage = findLast(
1252+
this.clineMessages,
1253+
(m) => m.say === "completion_result" || m.ask === "completion_result",
1254+
)
1255+
if (lastCompletionResultMessage) {
1256+
lastCompletionResultMessage.lastCheckpointHash = commitHash
1257+
await this.saveClineMessagesAndUpdateHistory()
1258+
}
1259+
} else {
1260+
console.error("Checkpoint tracker does not exist and could not be initialized for attempt completion")
12411261
}
12421262
}
12431263

0 commit comments

Comments
 (0)