[BUG] Undo/redo often fails in native Windows environment when apply_patch edits are tracked as full-file rewrites
What version of the Codex App are you using (From “About Codex” dialog)?
codex 26.422.30944
What subscription do you have?
GPT pro (with GPT 5.4)
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What issue are you seeing?
On the Codex Windows app running in the native Windows environment, undo / redo is unreliable and often fails after file edits made via apply_patch.
The problem appears related to how the app records file changes. In some cases, an edit that should be tracked as a simple append is instead recorded as a full-file replacement.
Example of an append patch: (reported by gpt after apply_patch)
*** Begin Patch
*** Update File: hellohello.txt
@@
hello
line2
line3
+line4
+line5
*** End Patch
Expected diff shape after this patch is -0 +2, but Codex sometimes shows it as -3 +5, as if the entire previous file was deleted and rewritten. When this happens, undo / redo fails at a very high rate.
There is a similar inconsistency with smaller edits such as( reported by gpt after apply_patch):
*** Begin Patch
*** Update File: hellohello.txt
@@
hello
+line2
+line3
*** End Patch
After this patch, Codex sometimes shows -1 +3, and sometimes -0 +2. In the -0 +2 case, undo / redo usually works normally. In the -1 +3 case, it is much more likely to fail.
The same workflows behave much more normally in WSL. Since Codex appears to rely on system Git for file change tracking, this may be related to differences in Git behavior on native Windows versus WSL.
What steps can reproduce the bug?
- Run Codex in the native Windows environment, not WSL.
- Tell Codex to create a file such as
hello.txtwith initial content:
``txt``
hello
- Tell Codex to append several lines to the file.
- Check how Codex displays the resulting diff for the file.
- Try using
undoandredo.
Observed behavior:
- Sometimes the diff is shown as a normal append like
-0 +2. - Sometimes the same kind of change is shown as delete-and-rewrite, such as
-3 +5or-1 +3. - When the change is recorded as delete-and-rewrite,
undo/redofrequently fails.
Control comparison:
- Repeat the same workflow in WSL.
- The diff and
undo/redobehavior are much more stable there.
What is the expected behavior?
apply_patch appends should be tracked as minimal line additions when the surrounding file content is unchanged.
For example, this patch:
*** Begin Patch
*** Update File: hellohello.txt
@@
hello
line2
line3
+line4
+line5
*** End Patch
should be represented as -0 +2, not as a full-file rewrite like -3 +5.
Undo and redo should work reliably after these edits in the native Windows environment, with behavior matching WSL.
Additional information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗