BUG: Undo undoes MY changes in built-in Plan agent when assistant made no changes #8555

Open
opened 2026-02-16 18:10:16 -05:00 by yindo · 1 comment
Owner

Originally created by @tgrushka on GitHub (Feb 4, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

  1. I ask the agent a question about some file in default Plan mode (may happen in other modes too!).
  2. The agent gets confused over the ambiguity I introduced, e.g. through copy/paste and my own failure to edit the pasted line.
  3. I notice this and correct my own error in the copy/paste. We're in Plan mode, so the agent has not touched anything.
  4. I then /undo the last chat message.
  5. I re-submit my question to the agent.
  6. 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 /redo immediately 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

  1. Create a new session in OpenCode in the default Plan mode.
  2. Edit a file that is not .gitignored in your project. Make a deliberate error in your edit.
  3. Ask the agent a question about the file. Be sure to include the file as an attachment with an @ prefix.
  4. The agent might notice your mistake or might not. It doesn't matter.
  5. Order is critical here. Correct your own error in the file.
  6. After correcting your own error, /undo the last chat message.
  7. Notice that your correction to your own file has been reverted to the error!

Screenshot and/or share link

No response

Operating System

macOS

Terminal

iTerm2

Originally created by @tgrushka on GitHub (Feb 4, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description 1. I ask the agent a question about some file in default Plan mode (may happen in other modes too!). 2. The agent gets confused over the ambiguity I introduced, e.g. through copy/paste and my own failure to edit the pasted line. 3. I notice this and correct my own error in the copy/paste. We're in Plan mode, so the agent has not touched anything. 4. I then `/undo` the last chat message. 5. I re-submit my question to the agent. 6. **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 `/redo` _immediately_ 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 1. Create a new session in OpenCode in the default Plan mode. 2. Edit a file that is not .gitignored in your project. Make a deliberate error in your edit. 3. Ask the agent a question about the file. Be sure to include the file as an attachment with an @ prefix. 4. The agent might notice your mistake or might not. It doesn't matter. 5. **Order is critical here.** Correct your own error in the file. 6. **After correcting your own error,** `/undo` the last chat message. 7. Notice that your correction to your own file has been reverted to the error! ### Screenshot and/or share link _No response_ ### Operating System macOS ### Terminal iTerm2
yindo added the bug label 2026-02-16 18:10:16 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 4, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5910: Undo previous message incorrectly restores project state
  • #10287: Critical bug revert undo messages - files reverted to old state, deleting committed code
  • #7963: [FEATURE] Undo message only - keep file changes (requests ability to undo without reverting file changes)
  • #4704: /undo and /timeline undo does not revert file edits (opposite issue - undo doesn't revert files at all)

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[bot] commented on GitHub (Feb 4, 2026): This issue might be a duplicate of existing issues. Please check: - #5910: Undo previous message incorrectly restores project state - #10287: Critical bug revert undo messages - files reverted to old state, deleting committed code - #7963: [FEATURE] Undo message only - keep file changes (requests ability to undo without reverting file changes) - #4704: /undo and /timeline undo does not revert file edits (opposite issue - undo doesn't revert files at all) 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8555