Configuration
Snapshots are enabled by default. Setsnapshots to false in your configuration to stop capturing
filesystem state:
opencode.jsonc
What is captured
For each model step, OpenCode attempts to capture the worktree immediately before the model call and after a cleanly completed step. It records the paths changed between those two points on the assistant message. Snapshots use a separate internal Git object database in the OpenCode data directory. They do not create commits, move branches, or intentionally modify your repository’s Git index. Capture is limited to the session’s active directory, which may be a subdirectory of the repository. Within that directory, snapshots include tracked files and untracked files that are not ignored by Git. An individual untracked file larger than 2 MiB is excluded. Ignored files, files outside the active directory, and changes to Git metadata are not captured. During undo, OpenCode does not check out an entire tree. It restores only paths attributed to cleanly completed assistant steps after the selected conversation boundary. Each path is restored to its state before the first affected step.Undo
Wait for the session to become idle, then run:- The selected user message and every later message are hidden, but not deleted yet.
- The selected message’s text, attachments, and agent mentions are placed in the composer for revision.
- Captured files changed by the affected assistant steps are restored to their earlier contents. Files created by those steps are removed when they did not exist in the earlier snapshot.
- A summary shows the staged message count and restored paths.
/undo again moves the staged boundary to an earlier user message. OpenCode keeps the filesystem state from
immediately before the first undo as the redo baseline, so repeated undos form one wider staged revert rather than a redo
stack.
Redo
While a revert is staged, run:Revert a message
The TUI’s Message Actions menu also provides Revert. It stages the selected message as the conversation boundary and uses the same file restoration and redo behavior, but it does not copy that message into the composer. For a conversation-and-files rollback, select a user message. If an assistant message is selected, that message is hidden, but only file changes attributed to later assistant steps are restored; the selected assistant message’s own file changes are not included.Limitations and safety
- Capture is best effort. A failed capture is logged and the model step continues, so conversation rollback may have no matching file rollback.
- Interrupted or failed steps do not receive a completed end snapshot. File changes made before the failure may remain.
- Shell commands can change databases, services, processes, network resources, Git state, ignored build output, or files outside the active directory. Undo and redo do not reverse those side effects.
- Undo overwrites the current contents of affected paths with older contents. Redo likewise overwrites those paths with the pre-undo state, including edits made after running undo.
- Other processes can edit the worktree between capture and restore. The server rejects revert operations while the session is actively running, but it cannot protect against external editors or commands.
- Snapshot objects can contain complete contents of tracked and non-ignored untracked files. They are stored locally in the OpenCode data directory; do not treat snapshots as secret-free metadata.
- Undo is not secure erasure. Committing a revert removes messages from the active projection, not from durable session history or existing snapshot storage.
/undo and /redo are interactive TUI commands. The non-interactive run command does not provide them.