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

Commit 7ee88cc

Browse files
committed
fix: add missing checkpointRestoreToBase function
This function was in the old PR #10908 but was not included when we created the new branch from origin/main. It's needed for restoring to the initial checkpoint state.
1 parent a89acc5 commit 7ee88cc

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

src/core/checkpoints/index.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,44 @@ export async function checkpointRestore(
326326
}
327327
}
328328

329+
/**
330+
* Restore to the initial checkpoint (base state when task started).
331+
* This is used by the InitialCheckpoint component since it doesn't have a message timestamp.
332+
*/
333+
export async function checkpointRestoreToBase(task: Task): Promise<boolean> {
334+
const service = await getCheckpointService(task)
335+
336+
if (!service) {
337+
return false
338+
}
339+
340+
const baseHash = service.baseHash
341+
342+
if (!baseHash) {
343+
const provider = task.providerRef.deref()
344+
provider?.log("[checkpointRestoreToBase] no baseHash available")
345+
return false
346+
}
347+
348+
const provider = task.providerRef.deref()
349+
350+
try {
351+
await service.restoreCheckpoint(baseHash)
352+
TelemetryService.instance.captureCheckpointRestored(task.taskId)
353+
await provider?.postMessageToWebview({ type: "currentCheckpointUpdated", text: baseHash })
354+
355+
// Cancel the task to reinitialize with the restored state
356+
// This follows the same pattern as checkpointRestore
357+
provider?.cancelTask()
358+
359+
return true
360+
} catch (err) {
361+
provider?.log("[checkpointRestoreToBase] disabling checkpoints for this task")
362+
task.enableCheckpoints = false
363+
return false
364+
}
365+
}
366+
329367
export type CheckpointDiffOptions = {
330368
ts?: number
331369
previousCommitHash?: string

0 commit comments

Comments
 (0)