[BUG] Undo/redo often fails in native Windows environment when apply_patch edits are tracked as full-file rewrites

Open 💬 1 comment Opened Apr 28, 2026 by Alkacid

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?

  1. Run Codex in the native Windows environment, not WSL.
  2. Tell Codex to create a file such as hello.txt with initial content:

``txt
hello
``

  1. Tell Codex to append several lines to the file.
  2. Check how Codex displays the resulting diff for the file.
  3. Try using undo and redo.

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 +5 or -1 +3.
  • When the change is recorded as delete-and-rewrite, undo / redo frequently fails.

Control comparison:

  1. Repeat the same workflow in WSL.
  2. The diff and undo / redo behavior 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_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗