Fix stale file read after patch causing empty diff content#178
Open
SteffenDE wants to merge 2 commits into
Open
Fix stale file read after patch causing empty diff content#178SteffenDE wants to merge 2 commits into
SteffenDE wants to merge 2 commits into
Conversation
Also ensure events are always handled in order.
SteffenDE
commented
Jun 8, 2026
Comment on lines
+297
to
+308
| if (patchedContent === false) { | ||
| // If Codex runs in full access mode, the file might already be patched. | ||
| // we can verify this by checking if the reverted patch applies. | ||
| const revertedPatch = revertPatch(unifiedDiff); | ||
| if (revertedPatch) { | ||
| const revertedContent = applyPatch(oldContent, revertedPatch); | ||
| if (revertedContent !== false) { | ||
| return createUpdateDiffContent(change.path, revertedContent, oldContent); | ||
| } | ||
| } | ||
| return null; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This one handles the empty content. The other changes are all for ensuring correct message order.
SteffenDE
commented
Jun 8, 2026
| "sessionId": "test-session-id", | ||
| "update": { | ||
| "sessionUpdate": "tool_call_update", | ||
| "sessionUpdate": "tool_call", |
Contributor
Author
There was a problem hiding this comment.
Those test fixtures actually encoded the bad order.
AlexandrSuhinin
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also ensure events are always handled in order.
#167 fixed some diff errors, but there was still a race condition when using codex in full access mode, where the file was already updated when codex-acp read it, making the patch fail to apply and returning empty content:
codex-acp/src/CodexToolCallMapper.ts
Lines 294 to 297 in e698674
Additionally, because each event was processed individually, the
await readFilecould cause theitem/completedevent to be processed and sent astool_call_updatevia ACP before the initialtool_callwas sent.