Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,14 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
// Kicks off the checkpoints initialization process in the background.
getCheckpointService(this)

// Create an initial checkpoint at the very beginning of task execution
// This allows users to completely reset to the initial state before any changes
// Use allowEmpty=true to ensure checkpoint is created even with no file changes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider expanding this comment slightly to explain why is essential here:

// Use suppressMessage=true to avoid cluttering the UI with this automatic checkpoint
if (this.enableCheckpoints) {
await this.checkpointSave(true, true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good implementation for adding an initial checkpoint. Consider whether a try/catch wrapper around the await this.checkpointSave(true, true) call might be beneficial to prevent a checkpoint failure from blocking task execution.

Suggested change
await this.checkpointSave(true, true)
try { await this.checkpointSave(true, true) } catch { /* checkpoint failure should not block task execution */ }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this implementation works and follows the existing patterns, consider adding a test to verify that the initial checkpoint is actually created when a task starts. You could add a test in that mocks the checkpoint service and verifies is called with and during task initialization.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is error handling intentional here? The function already handles errors gracefully by logging them and disabling checkpoints, but you might want to consider if a failed initial checkpoint should log a warning or affect task startup in any way. The current approach (silent failure) is probably fine since checkpoints are a nice-to-have feature.

}

let nextUserContent = userContent
let includeFileDetails = true

Expand Down
Loading