You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: Undo undoes MY changes in built-in Plan agent when assistant made no changes #12201
I ask the agent a question about some file in default Plan mode (may happen in other modes too!).
The agent gets confused over the ambiguity I introduced, e.g. through copy/paste and my own failure to edit the pasted line.
I notice this and correct my own error in the copy/paste. We're in Plan mode, so the agent has not touched anything.
I then /undo the last chat message.
I re-submit my question to the agent.
BOOM! The agent complains again about the ambiguity I thought I had fixed. OpenCode has reverted my own edit to my own file when I was in Plan mode.
This is really bad, because human changes should NEVER be automatically reverted by OpenCode unless the user specifically wants that (I don't know how you would do that, maybe via a setting to include human changes in undo/redo).
This could result in data loss. If the human changes are larger, one must remember to /redoimmediately to recover the reverted changes, without submitting another chat message and losing the data permanently.
I don't know how OpenCode tracks undo/redo internally. Does it use a git-like history? Perhaps on undo, it should raise some kind of "merge conflict" warning/error or something, maybe prompt the user or something.
But it should be able to revert just the AI agent changes while keeping the human changes, as git itself can do this via git stash and git stash pop, unless the changes are so complex it gets confused, in which a conflict is raised.
Plugins
None
OpenCode version
1.1.51
Steps to reproduce
Create a new session in OpenCode in the default Plan mode.
Edit a file that is not .gitignored in your project. Make a deliberate error in your edit.
Ask the agent a question about the file. Be sure to include the file as an attachment with an @ prefix.
The agent might notice your mistake or might not. It doesn't matter.
Order is critical here. Correct your own error in the file.
After correcting your own error,/undo the last chat message.
Notice that your correction to your own file has been reverted to the error!
These issues describe related problems with the undo/snapshot system where file state handling is incorrect or inconsistent. Your issue specifically reports that human-made changes are being reverted when undoing an AI message in Plan mode.
Feel free to ignore if none of these address your specific case.
Activity
github-actions commentedon Feb 4, 2026
This issue might be a duplicate of existing issues. Please check:
These issues describe related problems with the undo/snapshot system where file state handling is incorrect or inconsistent. Your issue specifically reports that human-made changes are being reverted when undoing an AI message in Plan mode.
Feel free to ignore if none of these address your specific case.
github-actions commentedon Apr 6, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.
yizhepku commentedon May 6, 2026
Issue still persists. Please reopen.