Skip to content

Commit f934276

Browse files
committed
refactor: streamline checkpoint handling and enhance getCheckpoints method
1 parent 958a437 commit f934276

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,6 @@ export async function presentAssistantMessage(cline: Task) {
532532
break
533533
}
534534

535-
const recentlyModifiedFiles = cline.fileContextTracker.getAndClearCheckpointPossibleFile()
536-
537-
if (recentlyModifiedFiles.length > 0) {
538-
// TODO: We can track what file changes were made and only
539-
// checkpoint those files, this will be save storage.
540-
await checkpointSave(cline)
541-
}
542-
543535
// Seeing out of bounds is fine, it means that the next too call is being
544536
// built up and ready to add to assistantMessageContent to present.
545537
// When you see the UI inactive during this, it means that a tool is

src/core/checkpoints/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,19 @@ export async function checkpointDiff(cline: Task, { ts, previousCommitHash, comm
298298

299299
TelemetryService.instance.captureCheckpointDiffed(cline.taskId)
300300

301-
if (!previousCommitHash && mode === "checkpoint") {
302-
const previousCheckpoint = cline.clineMessages
303-
.filter(({ say }) => say === "checkpoint_saved")
304-
.sort((a, b) => b.ts - a.ts)
305-
.find((message) => message.ts < ts)
306-
307-
previousCommitHash = previousCheckpoint?.text
301+
let from = commitHash
302+
let to: string | undefined
303+
304+
const checkpoints = typeof service.getCheckpoints === "function" ? service.getCheckpoints() : []
305+
const idx = checkpoints.indexOf(commitHash)
306+
if (idx !== -1 && idx < checkpoints.length - 1) {
307+
to = checkpoints[idx + 1]
308+
} else {
309+
to = undefined
308310
}
309311

310312
try {
311-
const changes = await service.getDiff({ from: previousCommitHash, to: commitHash })
313+
const changes = await service.getDiff({ from, to })
312314

313315
if (!changes?.length) {
314316
vscode.window.showInformationMessage("No changes found.")

src/services/checkpoints/ShadowCheckpointService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export abstract class ShadowCheckpointService extends EventEmitter {
3838
return !!this.git
3939
}
4040

41+
public getCheckpoints(): string[] {
42+
return this._checkpoints.slice()
43+
}
44+
4145
constructor(taskId: string, checkpointsDir: string, workspaceDir: string, log: (message: string) => void) {
4246
super()
4347

0 commit comments

Comments
 (0)