fix(codex): await patch notifications before approval

Approval requests bypass the session's notification conversion queue. Drain earlier notifications before reading the patch preview so an approval in the same stdout batch receives its matching file and diff.

Co-authored-by: Okan YILDIRIM <63511519+ragokan@users.noreply.github.com>
This commit is contained in:
paseo-bot[bot]
2026-11-02 18:12:28 +00:00
co-authored by Okan YILDIRIM
parent bc501bd1a4
commit 83071e1be8
2 changed files with 3 additions and 4 deletions
@@ -228,7 +228,7 @@ function deferred<T>() {
}
describe("Codex file-change approvals", () => {
test("file-change approval includes the matching started patch", async () => {
test("file-change approval includes the matching patch when notifications are still queued", async () => {
const appServer = createFakeCodexAppServer();
const { session } = await startPublicSteeringSession(appServer);
try {
@@ -236,7 +236,6 @@ describe("Codex file-change approvals", () => {
["file-alpha", "/workspace/project/alpha.txt", "@@ -1 +1 @@\n-blue\n+green\n"],
["file-beta", "/workspace/project/beta.txt", "@@ -1 +1 @@\n-small\n+large\n"],
]) {
const started = waitForTimelineToolCall(session, id);
appServer.child.stdout.write(
`${JSON.stringify({
method: "item/started",
@@ -252,7 +251,6 @@ describe("Codex file-change approvals", () => {
},
})}\n`,
);
await started;
}
const permission = waitForNextPermission(session);
appServer.requestFileChangeApproval({
@@ -7262,7 +7262,8 @@ export class CodexAppServerAgentSession implements AgentSession {
});
}
private handleFileChangeApprovalRequest(params: unknown): Promise<unknown> {
private async handleFileChangeApprovalRequest(params: unknown): Promise<unknown> {
await this.pendingNotifications;
const parsed = z
.object({
itemId: z.string(),