/undo command only rolls back AI conversation message, not the associated file changes #3517

Open
opened 2026-02-16 17:40:26 -05:00 by yindo · 11 comments
Owner

Originally created by @sdivens on GitHub (Dec 13, 2025).

Originally assigned to: @rekram1-node on GitHub.

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

  1. Start a conversation with the AI in OpenCode.
  2. Ask the AI to make changes to a file (e.g., "add a function to main.js").
  3. Let the AI apply the changes to your workspace.
  4. Type /undo in the chat to undo the last AI action.
  5. Observe: the conversation message disappears, but the file changes remain in your project.

Screenshot and/or share link

Image Image Image

Operating System

macos 15.7.1

Terminal

item2

Originally created by @sdivens on GitHub (Dec 13, 2025). Originally assigned to: @rekram1-node on GitHub. ### 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 1. Start a conversation with the AI in OpenCode. 2. Ask the AI to make changes to a file (e.g., "add a function to main.js"). 3. Let the AI apply the changes to your workspace. 4. Type `/undo` in the chat to undo the last AI action. 5. Observe: the conversation message disappears, but the file changes remain in your project. ### Screenshot and/or share link <img width="2276" height="292" alt="Image" src="https://github.com/user-attachments/assets/8ed5249a-b008-4ae6-a4dd-6f0f0b0d41ac" /> <img width="1505" height="116" alt="Image" src="https://github.com/user-attachments/assets/4a4db8c4-ff05-4712-a253-ce68c3db755f" /> <img width="454" height="121" alt="Image" src="https://github.com/user-attachments/assets/20d8ec55-4480-452e-9373-fa805bd8a550" /> ### Operating System macos 15.7.1 ### Terminal item2
yindo added the bug label 2026-02-16 17:40:26 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 13, 2025):

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.

@github-actions[bot] commented on GitHub (Dec 13, 2025): 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.
Author
Owner

@Cyrille37 commented on GitHub (Dec 13, 2025):

Hi. Yes, I got same behavior with opencode 1.0.150.

@Cyrille37 commented on GitHub (Dec 13, 2025): Hi. Yes, I got same behavior with opencode 1.0.150.
Author
Owner

@nalin-singh commented on GitHub (Dec 13, 2025):

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

@nalin-singh commented on GitHub (Dec 13, 2025): 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
Author
Owner

@rekram1-node commented on GitHub (Dec 13, 2025):

are you working in a git repo? It will only undo changes in git repos

@rekram1-node commented on GitHub (Dec 13, 2025): are you working in a git repo? It will only undo changes in git repos
Author
Owner

@Cyrille37 commented on GitHub (Dec 13, 2025):

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 💌

@Cyrille37 commented on GitHub (Dec 13, 2025): 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 💌
Author
Owner

@rekram1-node commented on GitHub (Dec 13, 2025):

ill doc it

@rekram1-node commented on GitHub (Dec 13, 2025): ill doc it
Author
Owner

@sdivens commented on GitHub (Dec 13, 2025):

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.

@sdivens commented on GitHub (Dec 13, 2025): > > 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.
Author
Owner

@rekram1-node commented on GitHub (Dec 13, 2025):

does this repo have commits in it?

does this issue happen consistently?

@rekram1-node commented on GitHub (Dec 13, 2025): does this repo have commits in it? does this issue happen consistently?
Author
Owner

@sdivens commented on GitHub (Dec 14, 2025):

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.

@sdivens commented on GitHub (Dec 14, 2025): > 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.
Author
Owner

@gergesh commented on GitHub (Dec 15, 2025):

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>

@gergesh commented on GitHub (Dec 15, 2025): 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>`
Author
Owner

@Siroguh commented on GitHub (Jan 1, 2026):

I can confirm this happens to me in 1.0.223.

Only changes in setup i've made is i've started to use tmux and lazygit.

git was present all along.

EDIT:

A very quick test running opencode in tmux (ghostty) and another in plain terminal (ghostty) for the same file: tmux session can't undo changes to files and plain ghostty can.

EDIT 2: now tmux session worked.

@Siroguh commented on GitHub (Jan 1, 2026): I can confirm this happens to me in 1.0.223. Only changes in setup i've made is i've started to use tmux and lazygit. git was present all along. EDIT: A very quick test running opencode in tmux (ghostty) and another in plain terminal (ghostty) for the same file: tmux session can't undo changes to files and plain ghostty can. EDIT 2: now tmux session worked.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3517