File tree 4 files changed +18
-7
lines changed
4 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ async function getInitializedCheckpointService(
152
152
}
153
153
}
154
154
155
- export async function checkpointSave ( cline : Task ) {
155
+ export async function checkpointSave ( cline : Task , force = false ) {
156
156
const service = getCheckpointService ( cline )
157
157
158
158
if ( ! service ) {
@@ -169,7 +169,7 @@ export async function checkpointSave(cline: Task) {
169
169
telemetryService . captureCheckpointCreated ( cline . taskId )
170
170
171
171
// Start the checkpoint process in the background.
172
- return service . saveCheckpoint ( `Task: ${ cline . taskId } , Time: ${ Date . now ( ) } ` ) . catch ( ( err ) => {
172
+ return service . saveCheckpoint ( `Task: ${ cline . taskId } , Time: ${ Date . now ( ) } ` , { allowEmpty : force } ) . catch ( ( err ) => {
173
173
console . error ( "[Cline#checkpointSave] caught unexpected error, disabling checkpoints" , err )
174
174
cline . enableCheckpoints = false
175
175
} )
Original file line number Diff line number Diff line change @@ -1658,8 +1658,8 @@ export class Task extends EventEmitter<ClineEvents> {
1658
1658
1659
1659
// Checkpoints
1660
1660
1661
- public async checkpointSave ( ) {
1662
- return checkpointSave ( this )
1661
+ public async checkpointSave ( force : boolean = false ) {
1662
+ return checkpointSave ( this , force )
1663
1663
}
1664
1664
1665
1665
public async checkpointRestore ( options : CheckpointRestoreOptions ) {
Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ export async function newTaskTool(
69
69
return
70
70
}
71
71
72
+ if ( cline . enableCheckpoints ) {
73
+ cline . checkpointSave ( true )
74
+ await delay ( 350 )
75
+ }
76
+
72
77
// Preserve the current mode so we can resume with it later.
73
78
cline . pausedModeSlug = ( await provider . getState ( ) ) . mode ?? defaultModeSlug
74
79
Original file line number Diff line number Diff line change @@ -214,17 +214,23 @@ export abstract class ShadowCheckpointService extends EventEmitter {
214
214
return this . shadowGitConfigWorktree
215
215
}
216
216
217
- public async saveCheckpoint ( message : string ) : Promise < CheckpointResult | undefined > {
217
+ public async saveCheckpoint (
218
+ message : string ,
219
+ options ?: { allowEmpty ?: boolean } ,
220
+ ) : Promise < CheckpointResult | undefined > {
218
221
try {
219
- this . log ( `[${ this . constructor . name } #saveCheckpoint] starting checkpoint save` )
222
+ this . log (
223
+ `[${ this . constructor . name } #saveCheckpoint] starting checkpoint save (allowEmpty: ${ options ?. allowEmpty ?? false } )` ,
224
+ )
220
225
221
226
if ( ! this . git ) {
222
227
throw new Error ( "Shadow git repo not initialized" )
223
228
}
224
229
225
230
const startTime = Date . now ( )
226
231
await this . stageAll ( this . git )
227
- const result = await this . git . commit ( message )
232
+ const commitArgs = options ?. allowEmpty ? { "--allow-empty" : null } : undefined
233
+ const result = await this . git . commit ( message , commitArgs )
228
234
const isFirst = this . _checkpoints . length === 0
229
235
const fromHash = this . _checkpoints [ this . _checkpoints . length - 1 ] ?? this . baseHash !
230
236
const toHash = result . commit || fromHash
You can’t perform that action at this time.
0 commit comments