Bug report: VSCode extension failed to revert the changes
What version of the VS Code extension are you using?
0.4.46
What subscription do you have?
bussiness
Which IDE are you using?
vscode
What platform is your computer?
Darwin 25.1.0 arm64 arm
What issue are you seeing?
Environment: macOS, VSCode extension 0.4.46.
Codex deleted parts of my code unexpectedly. When I clicked the Revert changes button in the VSCode extension, it showed “Failed to revert changes.” The history changes panel did not correctly display the deleted parts, although the conversation’s history of changes did show them. I had to manually copy and paste from the conversation history to avoid losing uncommitted code.
The revert button in the VSCode extension does not work properly and needs to be fixed. I also suggest adding an option or prompt to automatically create a commit before Codex starts editing, so it is easier to restore previous versions.
What steps can reproduce the bug?
I asked Codex to find duplicate parts in the code and delete them, but Codex mistakenly started truncating the file from an incorrect location, causing the file to be cut off and a large amount of code after that point to be lost. When I clicked the revert button (↩️), it showed “failed to revert the changes.”
What is the expected behavior?
_No response_
Additional information
_No response_
47 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I would say there is a general need to have snapshots. Once we revert there is no apply patch in case we want. Also i'm not sure how the revert works if i revert non recent change. It's so confusing.
Hi @kaizhuanren, thanks for filling in this bug. How many files did you need to revert changes on? I've just tried on a dummy example and it seemed to work:
https://github.com/user-attachments/assets/108be080-515b-4a33-a656-447fc15d141b
Could you describe a bit more what you see in the IDE?
Same issue here.
Thanks for looking into this!
The key problems may be that Codex informed me that it had incorrectly truncated a document (about 3000 lines lost from a single file). After that, the VScode extension showed "Failed to revert the changes"
I am not fully aware of the internal details of how these Codex tools and vs extensions work, but my guess is that the issue I ran into is related to the tool calls failing to correctly return the corresponding results.
Maybe you could also describe more details , thanks
Oh okay so did Codex by itself tried to Undo its changes @kaizhuanren ?
@aemotyka could you detail a bit more what is happening on your end?
Codex reported the error and asked if I wanted to roll back to a previous version. I agreed, but it tried to restore using the git commit history, which would have caused me to lose some uncommitted code. After that, the ↩️ undo button stopped working properly.
@lionel-oai yes, essentially after codex completed changes, I wanted to revert the most recent change, and attempted to do so by clicking the "undo" button that appears when you expand the diffs of different files shown when codex completes a task. After clicking, I get a red toast that says "failed to revert changes" (image attached here). (and the changes are not reverted). Of course I can still manually revert because I am able to see the diff, but it would be pretty valuable to be able to do this with the click of a button instead. Also, unlike @kaizhuanren, I've experienced this issue on changes spanning only a few lines, so I don't think it's a truncation issue.
<img width="231" height="47" alt="Image" src="https://github.com/user-attachments/assets/47677ad2-fcb6-4fcf-8956-817cc239c6cf" />
(I have the same exact setup, ide, platform as the original poster here, but I am on Pro, not business. Also, I have encountered this issue with all models on codex going back to august, and it occurs whether or not my project is on git. My hunch is it has something to do with platform, because I saw a previous issue that had been closed where only specific Mac users were still reporting the issue)
I’d like to add a bit more context. In my Mac, Codex extension’s ↩️ button in VS Code doesn’t work properly in other situations either .
Codex can still revert files correctly by using apply_patch after my instruction, but the issue I first ran into was actually a more troublesome scenario.
Same for me in Windows vscode ide codex
same for me in vscode extension
never worked for me
<img width="259" height="89" alt="Image" src="https://github.com/user-attachments/assets/b0b29d77-2b44-48ca-b10f-db017b37f9ed" />
yes i experienced this too.
Still having issues
Issue #2997 was closed as "resolved" with no actual fix, please leave this one open as this is clearly an ongoing issue.
Still got this issue?
No, because they removed the "undo" button. Would be a great feature to have if it actually worked though.
https://github.com/user-attachments/assets/5bc8f909-bdac-4c68-8803-459081ede16a
seems like it still doesn't work and haven't been removed now.
This feels like quite a big bug, as Codex is able to destroy an entire codebase (or at least break the code) - and does semi-regularly. Every other coding agent I've used has this function working.
Exactly
same with windsurf and Codex – OpenAI’s coding agent
<img width="227" height="49" alt="Image" src="https://github.com/user-attachments/assets/6e6dbffc-4379-4dde-b973-730b3c494b07" />
+1
Same here...
same here and it's quite frustrating! considering alternatives for codex
Seems to work for me now.
Same here
same here, it's just so annoying
<img width="424" height="181" alt="Image" src="https://github.com/user-attachments/assets/e41f9fc0-d346-4538-9b5e-f4bf959bf0fb" />
Same thing, fix please
Same issue
Same issue here
i figured it out. You need to use the git to record every step(commit), so the codex can help you to revert to any stage.
same issue
So i just need to commit everytime codex finishes a prompt? In order to for to go back? But this doesnt solve the revert changes you just go one commit behind using git.
<img width="533" height="571" alt="Image" src="https://github.com/user-attachments/assets/8a10ed77-ad80-4a81-95ee-3fcad60cee0a" />
codex vs code extension still have this revert error
is there really 0 solution to this 3 months after? come on
The issue seems to be (at least for me) caused by using the Run Codex In Windows Subsystem For Linux. It is off by default, but the docs recommend enabling it. Turning it off allows undo to work (sometimes), but it then causes a separate bug #9062
So turning WSL on breaks undo, and turning it off breaks PowerShell. I decided to enable WSL since "I can't undo the changes" is at least better than "The agent can't even run commands."
I will add that "being able to undo" and "being able to use PowerShell" are very basic things that every paid agent platform should do, and it is shocking that it is STILL not working. Especially considering that VSCode Copilot works fine and is open source.
I have that setting off and I still have the issue
I was able to fix it. My git repository was initialized but had no commits. Once I did an initial commit, it started to work. You don't need to have everything commited up to the point you want to revert like someone else said.
Hope this fixes it for someone else too.
We have an entire development team running into the same issue, even trying with their personal accounts to debug. Tried updating VS Code, updating Codex, using hte codex prerelease, looking through the docs and including hte "undo" feature. No results for any of this.
Pretty poor form for a paid product, we are switching as a team to Claude as a result of this.
The most basic attempt at UX would at least allow us to see what the error is behind the scenes rather than a "whoopsie sorry" generic message, this is designed for programmers after all right?
Same problem and it is not fixed till now...
I am experiencing an issue with the Codex extension in VS Code where the Revert Changes functionality does not work correctly.
When I click Revert Changes, the extension displays the following message:
<img width="445" height="275" alt="Image" src="https://github.com/user-attachments/assets/e7b86a43-0074-4f8f-8326-b9de17c810d0" />
The affected files are listed under the “Skipped” section.
Steps to Reproduce
Actual Behavior
Expected Behavior
Environment
Same problem on Windows machine with VS Code and Codex extension.
same issue
Still an issue.
Thanks for the update. From what I can see, I would not consider this fully fixed yet.
There seems to be some backend work around rollback, for example
thread/rollback, but that appears to only roll back the agent/thread context. The actual file restore is still left to the IDE/client side. So if the VS Code extension loses the diff/snapshot state or cannot map the previous file contents correctly, users can still end up with “Failed to revert changes” or with uncommitted work at risk.For me the important part is not only “rollback conversation history”, but a reliable, atomic restore of the exact Codex-applied file changes.
A safe fix would probably need something like:
Until that exists, I think the practical workaround is still to commit/stash manually before using Codex on important code, or use a separate worktree/branch. But that is a workaround, not a fix for the extension’s Revert button.