Turn-level undo
The undo extension restores file changes from the most recent user turn. It tracks edit and write tool calls and can undo them one turn at a time, bringing the conversation back to the previous user message.
Bundled with Selesai
Loaded automatically with Selesai; no per-extension npm install is required.
Setup and prerequisites
- This extension is bundled with Selesai. It is loaded automatically; you do not need to install it separately.
- Works inside a single Selesai session. Undo uses the current working directory of the session to resolve relative paths.
- Requires an interactive session with a TUI for slash command input.
What it sets up
- Watches
tool_callandtool_resultevents foreditandwritetools. - Builds a per-user-turn checkpoint that stores inverse edits, original file contents, and SHA-256 hashes of post-change file states.
- Detects mutating Bash commands by pattern analysis but does not track their filesystem effects.
What you can configure
Undo tracks edits, writes, and mutating shell commands per turn. Retention and buffer sizes are fixed.
No user configuration
This capability does not expose user-editable settings. Its behavior is controlled by the commands and runtime rules documented below.
Command, tool, and shortcut controls
| Key / path | Description |
|---|---|
/undo | Undo the last tracked turn. |
/undo --force | Force undo when confirmation would normally be required. |
Source evidence
src/extensions/undo.tsUndo source
What you can do
- Undo the most recent user turn and restore tracked file changes.
- See how many tracked operations are pending with
/undo-status. - Force a restore even if the file changed since the checkpoint by using
/undo --force.
Commands, tools, and shortcuts
| Command | Description |
|---|---|
/undo | Undo the last user turn and restore tracked edit/write changes. |
/undo --force | Restore tracked changes even if the file has been modified since the checkpoint. |
/undo-status | Show a summary of tracked checkpoints for the session. |
When you run /undo, Selesai navigates the session tree to the parent of the current user message, restores the editor prompt, and deletes the checkpoint after replay.
Limits and safety
- Only
editandwritetool effects are restored. Mutating Bash commands are flagged but not reverted; you must undo those by hand. - Undo cannot revert root prompts in-place. For the very first prompt, use
/newor/treeinstead. - Files larger than 512 KiB at the time of the original
writecannot be restored from the saved content. /undowithout--forcerefuses to restore a file whose current SHA-256 hash no longer matches the post-change hash recorded at the time of the original tool call.- Checkpoints are held in memory for the session; they are lost when the session ends.