Skip to content

Conversation

@justschen
Copy link
Collaborator

@justschen justschen commented Oct 31, 2025

Copilot AI review requested due to automatic review settings October 31, 2025 20:05
// Restore the snapshot to what it was before the request(s) that we deleted
const snapshotRequestId = chatRequests[itemIndex].id;
await session.restoreSnapshot(snapshotRequestId, undefined);
if (itemIndex < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this tested somewhere? If so, it'd be nice to add tests.

// Restore the snapshot to what it was before the request(s) that we deleted
const snapshotRequestId = chatRequests[itemIndex].id;
await session.restoreSnapshot(snapshotRequestId, undefined);
if (itemIndex < 0 && widget?.viewModel?.sessionResource) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

dmitrivMS
dmitrivMS previously approved these changes Oct 31, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modifies the logic for restoring snapshots in chat editing actions. The change adjusts the index calculation to point to the request before the target request (by subtracting 1 from the findIndex result), and adds special handling for the edge case where this results in a negative index (indicating the first request is being undone).

Key Changes:

  • Modified index calculation to subtract 1 from findIndex result
  • Added conditional logic to handle the case when undoing the first request (itemIndex < 0)
  • Applied same pattern across both chatEditingActions.ts and chatExecuteActions.ts

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts Updates restoreSnapshotWithConfirmation function to adjust index calculation and handle first-request edge case
src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts Updates SubmitAction.run method with same index adjustment and edge case handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restoring checkpoint does not delete last message, shows broken button

3 participants