Skip to content

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

Closed

Description

@tgrushka

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

Activity

  1. github-actions commented on Feb 4, 2026

    @github-actions
    Contributor

    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.

  2. github-actions commented on Apr 6, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  3. yizhepku commented on May 6, 2026

    @yizhepku

    Issue still persists. Please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions