anomalyco / anomalyco/opencode
Bug: `/undo` reports success but does not revert files in non-Git projects
@jlongster is already working on this.
Since Jul 24, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Bug Description
When using OpenCode in a non-Git project directory, running /undo or clicking the undo button shows "1 message reverted" but the actual file changes are NOT reverted at all.
Steps to Reproduce
- Start OpenCode in a non-Git directory (no
git initwas run) - Ask OpenCode to modify a file (e.g., edit or write content)
- Run
/undoor click the undo button - Observe that it shows a success message, but the file content remains unchanged
Root Cause
OpenCode's undo mechanism relies on Git snapshots for file change tracking. In snapshot/index.ts, when state.vcs !== "git", the snapshot system is silently disabled — track() returns undefined and revert()/restore() become no-ops. However, the higher-level undo flow does not check this state and still reports "success" to the user.
Environment
- OpenCode version: 1.18.4
- OS: Windows 11 (Build 26200)
- PowerShell: 5.1.26100.8115
Expected Behavior
When the project is not a Git repository, the undo action should clearly inform the user, for example: "Cannot undo file changes: the current project is not a Git repository. Please use this feature in a Git project."
Additional Suggestion (Feature Request)
Projects without Git actually have a greater need for undo functionality — users in Git projects can always manually recover via git checkout or git restore, but non-Git projects have no way to restore once files are modified. Consider implementing a file-copy or content-hash-based snapshot mechanism for non-Git environments in the future.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.