Skip to content

Fix stale file read after patch causing empty diff content#178

Open
SteffenDE wants to merge 2 commits into
agentclientprotocol:mainfrom
SteffenDE:sd-edit-fix
Open

Fix stale file read after patch causing empty diff content#178
SteffenDE wants to merge 2 commits into
agentclientprotocol:mainfrom
SteffenDE:sd-edit-fix

Conversation

@SteffenDE
Copy link
Copy Markdown
Contributor

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:

const oldContent = await readFileContent(change.path);
if (oldContent !== null) {
const patchedContent = applyPatch(oldContent, unifiedDiff);
if (patchedContent === false) return null;

Additionally, because each event was processed individually, the await readFile could cause the item/completed event to be processed and sent as tool_call_update via ACP before the initial tool_call was sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant