`/undo` command only rolls back AI conversation message, not the associated file changes
Description
In OpenCode, when using the /undo command to revert an AI-generated change (e.g., after the AI modified code or wrote new code), only the conversation message in the chat is rolled back, but the actual file changes made by the AI remain in the workspace. This results in a mismatch between the conversation history and the actual code state.
OpenCode version
1.0.152
Steps to reproduce
- Start a conversation with the AI in OpenCode.
- Ask the AI to make changes to a file (e.g., "add a function to main.js").
- Let the AI apply the changes to your workspace.
- Type
/undoin the chat to undo the last AI action. - Observe: the conversation message disappears, but the file changes remain in your project.
Screenshot and/or share link
Operating System
macos 15.7.1
Terminal
item2
This issue might be a duplicate of existing issues. Please check:
- #4704: /undo and /timeline undo does not revert file edits - directly related issue reporting the same problem
- #4548: /undo does not update Modified Files list - related issue where undo doesn't properly revert file changes
- #3901: Undo command doesn't allow editing reverted message like keyboard shortcut - related to undo command behavior issues
Feel free to ignore if none of these address your specific case.
Hi. Yes, I got same behavior with opencode 1.0.150.
I've tried this in the 1.0.152 I can't seem to replicate it, yeah the undo doesn't affect the modified files list like in #4548
are you working in a git repo? It will only undo changes in git repos
Hi
are you working in a git repo? It will only undo changes in git repos
Great. But this is missing in doc https://opencode.ai/docs/#undo-changes
Regards & cheers and many thanks for sharing this so great tool 💌
ill doc it
are you working in a git repo? It will only undo changes in git repos
Yes, I am currently running within a Git repository. You can refer to the screenshot I included in the issue for confirmation.
does this repo have commits in it?
does this issue happen consistently?
does this repo have commits in it?
does this issue happen consistently?
Yes, the code repository is connected to a remote repository. I have tried executing /undo in several states—after unstaging, staging, and committing—with the same code. In all these cases, it never rolls back my code; it only rolls back the AI session. This issue does not occur 100% of the time.
I experienced something else - using /timeline (so it might be different, I am not sure) it seems to only revert the agent's that were made with the file write tools? While I get why that might be (restoring a snapshot like CC does might lead to the user's changes being reverted) this causes issues with side effects such as the agent running bun add <package>