Critical bug revert undo messages #7377

Open
opened 2026-02-16 18:06:59 -05:00 by yindo · 7 comments
Owner

Originally created by @Genrie9 on GitHub (Jan 23, 2026).

Originally assigned to: @rekram1-node on GitHub.

Undo/revert reverts files to incorrect (old) state, deleting committed code

Description

When using the "revert messages" / undo functionality in the OpenCode TUI, files in the working directory were reverted to an old state (from weeks ago), not to the state before the reverted message. This caused ~1300 lines of committed code to be silently deleted from the working directory.

Steps to Reproduce

  1. Have a project with recent commits (e.g., commits from the past 2 weeks)
  2. Use "revert messages" or undo in the OpenCode TUI to undo a recent message
  3. Run git status — shows many modified files
  4. Run git diff --stat — shows massive deletions

Expected Behavior

Files should be reverted to their state before the undone message's changes, preserving all other committed code.

Actual Behavior

  • Multiple files were modified (uncommitted changes appeared)
  • git diff --stat showed ~1300 lines deleted across ~35 files
  • The deleted code was from commits made days/weeks ago (not from the reverted message)
  • Affected files included core entities, DbContext, services, etc.
  • Running dotnet build failed with 40+ errors due to missing properties/entities
  • git reflog showed NO reset/revert operations — changes were only in working directory
  • git checkout -- . restored everything correctly

Environment

  • OS: Windows 10
  • OpenCode version: latest as of Jan 2026
  • Shell: PowerShell / Git Bash

Workaround

Run git checkout -- . to restore all files to the last committed state.

Impact

High — This bug can silently delete large amounts of committed code without any warning. Users may not notice until build fails or runtime errors occur. If users commit these changes without reviewing, they could lose significant work.

Related Issues

  • #8098 — opposite problem (undo doesn't revert files at all)
  • #10210 — undo fails for non-ASCII filenames on Windows
  • #9811 — UI stuck on 'message reverted'
Originally created by @Genrie9 on GitHub (Jan 23, 2026). Originally assigned to: @rekram1-node on GitHub. # Undo/revert reverts files to incorrect (old) state, deleting committed code ## Description When using the "revert messages" / undo functionality in the OpenCode TUI, files in the working directory were reverted to an **old state** (from weeks ago), not to the state before the reverted message. This caused ~1300 lines of committed code to be silently deleted from the working directory. ## Steps to Reproduce 1. Have a project with recent commits (e.g., commits from the past 2 weeks) 2. Use "revert messages" or undo in the OpenCode TUI to undo a recent message 3. Run `git status` — shows many modified files 4. Run `git diff --stat` — shows massive deletions ## Expected Behavior Files should be reverted to their state **before the undone message's changes**, preserving all other committed code. ## Actual Behavior - Multiple files were modified (uncommitted changes appeared) - `git diff --stat` showed **~1300 lines deleted** across ~35 files - The deleted code was from commits made **days/weeks ago** (not from the reverted message) - Affected files included core entities, DbContext, services, etc. - Running `dotnet build` failed with 40+ errors due to missing properties/entities - `git reflog` showed NO reset/revert operations — changes were only in working directory - `git checkout -- .` restored everything correctly ## Environment - **OS:** Windows 10 - **OpenCode version:** latest as of Jan 2026 - **Shell:** PowerShell / Git Bash ## Workaround Run `git checkout -- .` to restore all files to the last committed state. ## Impact **High** — This bug can silently delete large amounts of committed code without any warning. Users may not notice until build fails or runtime errors occur. If users commit these changes without reviewing, they could lose significant work. ## Related Issues - #8098 — opposite problem (undo doesn't revert files at all) - #10210 — undo fails for non-ASCII filenames on Windows - #9811 — UI stuck on 'message reverted'
yindo added the windows label 2026-02-16 18:06:59 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 23, 2026):

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

  • #8098: Files not reverted when using /undo (opposite problem but same undo/revert system)
  • #5910: Undo command claims to restore to arbitrary state but doesn't actually apply changes
  • #7775: Unrevert from subdirectory overwrites files with stale versions from weeks ago
  • #8607: Revert is incomplete - TUI only traces part of diff
  • #9811: UI stuck on 'message reverted' while model runs invisibly

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 23, 2026): This issue might be a duplicate of existing issues. Please check: - #8098: Files not reverted when using /undo (opposite problem but same undo/revert system) - #5910: Undo command claims to restore to arbitrary state but doesn't actually apply changes - #7775: Unrevert from subdirectory overwrites files with stale versions from weeks ago - #8607: Revert is incomplete - TUI only traces part of diff - #9811: UI stuck on 'message reverted' while model runs invisibly Feel free to ignore if none of these address your specific case.
Author
Owner

@AndryHTC commented on GitHub (Feb 4, 2026):

This is killing me. I have to step out of OpenCode. So many lost changes

@AndryHTC commented on GitHub (Feb 4, 2026): This is killing me. I have to step out of OpenCode. So many lost changes
Author
Owner

@Woukim commented on GitHub (Feb 4, 2026):

This is killing me. I have to step out of OpenCode. So many lost changes

And this will be the right decision

@Woukim commented on GitHub (Feb 4, 2026): > This is killing me. I have to step out of OpenCode. So many lost changes And this will be the right decision
Author
Owner

@f123888 commented on GitHub (Feb 6, 2026):

It's hard to believe that a project with nearly 100,000 stars would have such a basic bug.

@f123888 commented on GitHub (Feb 6, 2026): It's hard to believe that a project with nearly 100,000 stars would have such a basic bug.
Author
Owner

@Jebvvnnb commented on GitHub (Feb 6, 2026):

I've encountered this problem as well, and not just once. I thought I accidentally pressed some button, but it seems this is an ongoing bug... I'm speechless.

@Jebvvnnb commented on GitHub (Feb 6, 2026): I've encountered this problem as well, and not just once. I thought I accidentally pressed some button, but it seems this is an ongoing bug... I'm speechless.
Author
Owner

@AledHe commented on GitHub (Feb 13, 2026):

Same here via clicking a message and choosing revert. I was trying to revert a interruptted message, and see all my recent git diff also reverted. I realized something happened again felt really frustrated.

Looks like a simple restore/reset --hard if opencode bugged, but we don't know what the bug is, I suggest developers don’t simply do reset/restore (git) with the revert (opencode) for now. This causes disasters.

btw, after seeing the code diff showed up after the revert message, I tried ctrl+x r, no recovery

@AledHe commented on GitHub (Feb 13, 2026): Same here via clicking a message and choosing revert. I was trying to revert a interruptted message, and see all my recent git diff also reverted. I realized something happened again felt really frustrated. Looks like a simple restore/reset --hard if opencode bugged, but we don't know what the bug is, I suggest developers don’t simply do reset/restore (git) with the revert (opencode) for now. This causes disasters. btw, after seeing the code diff showed up after the revert message, I tried ctrl+x r, no recovery
Author
Owner

@UPROOT01 commented on GitHub (Feb 16, 2026):

https://github.com/anomalyco/opencode/issues/7775#issue-3801050703

I think these two might be related because when i hit redo (after I got this other folder reverted to IDK when after an undo), it didnt redo the other foler, i had to restore my last commit which luckily was pretty recent but I completely do not trust the undo/redo commands right now

@UPROOT01 commented on GitHub (Feb 16, 2026): https://github.com/anomalyco/opencode/issues/7775#issue-3801050703 I think these two might be related because when i hit redo (after I got this other folder reverted to IDK when after an undo), it didnt redo the other foler, i had to restore my last commit which luckily was pretty recent but I completely do not trust the undo/redo commands right now
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7377