Skip to content

Commit e6c231b

Browse files
committed
Show diff after running task
1 parent 809e8cd commit e6c231b

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/core/Cline.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,9 @@ export class Cline extends EventEmitter<ClineEvents> {
294294
if (!globalStoragePath) {
295295
throw new Error("Global storage uri is invalid")
296296
}
297-
298-
// Use storagePathManager to retrieve the task storage directory
299-
const { getTaskDirectoryPath } = await import("../shared/storagePathManager")
300-
return getTaskDirectoryPath(globalStoragePath, this.taskId)
297+
const taskDir = path.join(globalStoragePath, "tasks", this.taskId)
298+
await fs.mkdir(taskDir, { recursive: true })
299+
return taskDir
301300
}
302301

303302
private async getSavedApiConversationHistory(): Promise<Anthropic.MessageParam[]> {
@@ -910,11 +909,6 @@ export class Cline extends EventEmitter<ClineEvents> {
910909
}
911910

912911
async abortTask(isAbandoned = false) {
913-
// if (this.abort) {
914-
// console.log(`[subtasks] already aborted task ${this.taskId}.${this.instanceId}`)
915-
// return
916-
// }
917-
918912
console.log(`[subtasks] aborting task ${this.taskId}.${this.instanceId}`)
919913

920914
// Will stop any autonomously running promises.
@@ -943,6 +937,8 @@ export class Cline extends EventEmitter<ClineEvents> {
943937
if (this.isStreaming && this.diffViewProvider.isEditing) {
944938
await this.diffViewProvider.revertChanges()
945939
}
940+
941+
await this.showTaskDiffs()
946942
}
947943

948944
// Tools
@@ -3183,6 +3179,8 @@ export class Cline extends EventEmitter<ClineEvents> {
31833179
telemetryService.captureTaskCompleted(this.taskId)
31843180
this.emit("taskCompleted", this.taskId, this.getTokenUsage())
31853181

3182+
await this.showTaskDiffs()
3183+
31863184
if (this.parentTask) {
31873185
const didApprove = await askFinishSubTaskApproval()
31883186

@@ -4187,6 +4185,24 @@ export class Cline extends EventEmitter<ClineEvents> {
41874185
this.enableCheckpoints = false
41884186
}
41894187
}
4188+
4189+
private async showTaskDiffs() {
4190+
if (this.enableCheckpoints && this.checkpointService?.isInitialized) {
4191+
const checkpoints = this.clineMessages.filter(({ say }) => say === "checkpoint_saved")
4192+
if (checkpoints.length > 0) {
4193+
const initialCheckpoint = checkpoints[0]
4194+
const finalCheckpoint = checkpoints[checkpoints.length - 1]
4195+
if (initialCheckpoint.text && finalCheckpoint.text) {
4196+
await this.checkpointDiff({
4197+
ts: Date.now(),
4198+
previousCommitHash: initialCheckpoint.text,
4199+
commitHash: finalCheckpoint.text,
4200+
mode: "full"
4201+
})
4202+
}
4203+
}
4204+
}
4205+
}
41904206
}
41914207

41924208
function escapeRegExp(string: string): string {

0 commit comments

Comments
 (0)