Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ abstract class SubmitAction extends Action2 {

if (requestId) {
const chatRequests = chatModel.getRequests();
const itemIndex = chatRequests.findIndex(request => request.id === requestId);
const itemIndex = chatRequests.findIndex(request => request.id === requestId) - 1;
const editsToUndo = chatRequests.length - itemIndex;

const requestsToRemove = chatRequests.slice(itemIndex);
Expand Down Expand Up @@ -149,8 +149,13 @@ abstract class SubmitAction extends Action2 {
}

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

const snapshotRequestId = chatRequests[0].id;
chatService.removeRequest(widget.viewModel.sessionResource, snapshotRequestId);
} else {
const snapshotRequestId = chatRequests[itemIndex].id;
await session.restoreSnapshot(snapshotRequestId, undefined);
}
}
} else if (widget?.viewModel?.model.checkpoint) {
widget.viewModel.model.setCheckpoint(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ async function restoreSnapshotWithConfirmation(accessor: ServicesAccessor, item:

if (requestId) {
const chatRequests = chatModel.getRequests();
const itemIndex = chatRequests.findIndex(request => request.id === requestId);
const itemIndex = chatRequests.findIndex(request => request.id === requestId) - 1;
const editsToUndo = chatRequests.length - itemIndex;

const requestsToRemove = chatRequests.slice(itemIndex);
Expand Down Expand Up @@ -367,8 +367,13 @@ async function restoreSnapshotWithConfirmation(accessor: ServicesAccessor, item:
}

// 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

const snapshotRequestId = chatRequests[0].id;
chatService.removeRequest(widget.viewModel.sessionResource, snapshotRequestId);
} else {
const snapshotRequestId = chatRequests[itemIndex].id;
await session.restoreSnapshot(snapshotRequestId, undefined);
}
}
}

Expand Down
Loading