Revert changes with checkpoints and editing requests
A chat session in Visual Studio Code might result in changes to one or more files in your workspace, which could be tedious to manually revert. For example, you might want to refine a previous chat request, try a different approach, or recover from unexpected changes.
This article describes how to edit previous chat requests and how to use checkpoints to roll back file changes made by chat.
Edit a previous chat request
The ability to edit chat requests is available as of VS Code version 1.102.
Each chat request in your conversation history is editable. When you edit a previous chat request, the edited request is sent to the language model as a new request, and any file changes made by the original request and subsequent requests are reverted.
To edit a previous chat request, select the request in the Chat view to modify and then resend it. You can configure or disable the editing experience with the chat.editRequests setting.
Use checkpoints to revert file changes
Checkpoints are available as of VS Code release 1.103.
Chat checkpoints provide a way to restore the state of your workspace to a previous point in time, and are useful when chat interactions resulted in changes across multiple files.
When checkpoints are enabled, VS Code automatically creates snapshots of your files at key points during chat interactions, allowing you to return to a known good state if the changes made by chat requests are not what you expected or if you want to try a different approach.
To enable checkpoints, configure the chat.checkpoints.enabled setting.
Restore a checkpoint
When you restore a checkpoint, VS Code reverts the workspace to the state it was in at the time of that checkpoint. This means that all changes made to files after that checkpoint will be undone.
To restore your workspace to a previous checkpoint:
-
In the Chat view, navigate to previous chat request in the chat session.
-
Hover over the chat request and select Restore Checkpoint.
-
Confirm that you want to restore the checkpoint and undo any file changes made after that point.
Notice that the chat request is removed from the conversation history, and the workspace files are restored to their state at the time of the checkpoint.
Redo after restoring
After restoring to a previous checkpoint, you can redo the changes that were undone. This might be useful if you inadvertently restored to a checkpoint.
To redo changes after restoring a checkpoint, select Redo in the Chat view.
View file changes in checkpoints
To help you understand the effect of each chat request and make it easier to decide which checkpoint to restore to, enable the chat.checkpoints.showFileChanges setting. This shows the list of files that were modified at the end of each chat request, along with the number of lines added and removed in each file.
Frequently asked questions
Do checkpoints replace Git version control?
No. Checkpoints are designed for quick iteration within a chat session and are temporary. They complement Git but don't replace it. Use Git for permanent version control and collaboration. Checkpoints are ideal for experimenting during active chat sessions.