Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 19, 2025

This PR attempts to address Issue #8177. Feedback and guidance are welcome.

Problem

Users were experiencing "Error asking question: Current ask promise was ignored" errors when restoring checkpoints, particularly on Windows 11.

Solution

The fix handles pending ask operations before checkpoint restoration by:

  1. Checking if there are any pending ask operations (indicated by lastMessageTs)
  2. Calling handleWebviewAskResponse with a dummy response to unblock any waiting promises
  3. This prevents the "Current ask promise was ignored" error from being thrown

Changes

  • Modified checkpointRestoreHandler.ts to handle pending ask operations for both delete and edit operations
  • Added comprehensive test coverage with 3 new test cases to verify the fix

Testing

  • All existing tests pass
  • Added new tests specifically for pending ask scenarios
  • Tests verify that pending asks are properly resolved before checkpoint restoration

Fixes #8177


Important

Fixes error during checkpoint restoration by handling pending ask operations in handleCheckpointRestoreOperation.

  • Behavior:
    • Fixes error "Current ask promise was ignored" during checkpoint restoration by handling pending ask operations in handleCheckpointRestoreOperation.
    • Checks for pending asks using lastMessageTs and resolves them with handleWebviewAskResponse.
    • Applies to both delete and edit operations.
  • Testing:
    • Adds 3 new test cases in checkpointRestoreHandler.spec.ts to verify handling of pending ask operations.
    • Tests ensure pending asks are resolved before checkpoint restoration.
  • Misc:
    • Modifies checkpointRestoreHandler.ts to include logic for handling pending asks before restoration.

This description was created by Ellipsis for 760ef23. You can customize this summary. It will automatically update as commits are pushed.

- Add handleWebviewAskResponse call before checkpoint restore to resolve any pending ask promises
- This prevents "Current ask promise was ignored" errors when restoring checkpoints
- Add comprehensive tests for pending ask scenarios

Fixes #8177
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 19, 2025 11:21
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Sep 19, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.

if (currentCline) {
// Handle any pending ask operations by providing a response
// This unblocks any waiting ask promises before the checkpoint restore
if (currentCline.lastMessageTs) {
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 using lastMessageTs the most reliable way to detect pending ask operations? This property could be set for other reasons. Consider adding a more explicit flag like hasPendingAsk to avoid potential false positives and make the intent clearer.

// This unblocks any waiting ask promises before the checkpoint restore
if (currentCline.lastMessageTs) {
// Use the public method to set a response for any pending ask
currentCline.handleWebviewAskResponse("messageResponse", "", undefined)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The choice to always use "messageResponse" with empty strings to clear pending asks might not be appropriate for all ask types. Could we either:

  1. Use a more generic cancellation approach
  2. Document why "messageResponse" is the universally correct choice here
  3. Consider different response types based on the pending ask type?

}

// For delete operations, abort the task
if (operation === "delete" && !currentCline.abort) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

// Continue even if timeout - the abort flag should be set
})
if (currentCline) {
// Handle any pending ask operations by providing a response
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 extracting this pending ask handling logic into a separate helper method like clearPendingAskOperations(currentCline) for better code organization and potential reusability. This would also make the main function cleaner and the intent more explicit.

)
})

it("should handle pending ask operations before checkpoint restore", async () => {
Copy link
Contributor Author

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 lastMessageTs is set to 0 or a very old timestamp to ensure the logic handles all scenarios correctly.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 19, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 23, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 23, 2025
@daniel-lxs
Copy link
Member

Closing for now, no repro steps

@daniel-lxs daniel-lxs closed this Sep 25, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 25, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[BUG] "Error asking question: Current ask promise was ignored" when restoring checkpoints

4 participants