Skip to content

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.

Manifest entry
./undo.ts
Runtime surface
Slash command

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_call and tool_result events for edit and write tools.
  • 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 / pathDescription
/undoUndo the last tracked turn.
/undo --forceForce undo when confirmation would normally be required.

Source evidence

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

CommandDescription
/undoUndo the last user turn and restore tracked edit/write changes.
/undo --forceRestore tracked changes even if the file has been modified since the checkpoint.
/undo-statusShow 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 edit and write tool 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 /new or /tree instead.
  • Files larger than 512 KiB at the time of the original write cannot be restored from the saved content.
  • /undo without --force refuses 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.

Source evidence

Selesai version: 0.10.0