-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: handle pending ask operations during checkpoint restore #8178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,18 +27,27 @@ export async function handleCheckpointRestoreOperation(config: CheckpointRestore | |
| const { provider, currentCline, messageTs, checkpoint, operation, editData } = config | ||
|
|
||
| try { | ||
| // For delete operations, ensure the task is properly aborted to handle any pending ask operations | ||
| // For both delete and edit operations, we need to handle any pending ask operations | ||
| // This prevents "Current ask promise was ignored" errors | ||
| // For edit operations, we don't abort because the checkpoint restore will handle it | ||
| if (operation === "delete" && currentCline && !currentCline.abort) { | ||
| currentCline.abortTask() | ||
| // Wait a bit for the abort to complete | ||
| await pWaitFor(() => currentCline.abort === true, { | ||
| timeout: 1000, | ||
| interval: 50, | ||
| }).catch(() => { | ||
| // Continue even if timeout - the abort flag should be set | ||
| }) | ||
| if (currentCline) { | ||
| // Handle any pending ask operations by providing a response | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider extracting this pending ask handling logic into a separate helper method like |
||
| // This unblocks any waiting ask promises before the checkpoint restore | ||
| if (currentCline.lastMessageTs) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is using |
||
| // Use the public method to set a response for any pending ask | ||
| currentCline.handleWebviewAskResponse("messageResponse", "", undefined) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The choice to always use
|
||
| } | ||
|
|
||
| // For delete operations, abort the task | ||
| if (operation === "delete" && !currentCline.abort) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For delete operations, we're now handling pending asks BEFORE aborting the task, which changes the original flow. Have we verified this doesn't introduce any side effects with the abort process? The order of operations can be critical in async cleanup scenarios. |
||
| currentCline.abortTask() | ||
| // Wait a bit for the abort to complete | ||
| await pWaitFor(() => currentCline.abort === true, { | ||
| timeout: 1000, | ||
| interval: 50, | ||
| }).catch(() => { | ||
| // Continue even if timeout - the abort flag should be set | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // For edit operations, set up pending edit data before restoration | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test coverage! These tests effectively verify the pending ask handling for both delete and edit operations, as well as the case where no pending ask exists. Consider adding an edge case test where
lastMessageTsis set to 0 or a very old timestamp to ensure the logic handles all scenarios correctly.