From bb9371d3c9500bf035b7df5da0969b82aac5a1fc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Feb 2026 04:19:44 +0000 Subject: [PATCH] Fix CWD override semantics and greedy regex in diff path parsing - Restore null CWD in sessionOverrides for thread/start and thread/resume so the Codex app server can distinguish 'no override' from an explicit path (e.g., to reuse a resumed thread's original CWD). - Use backreference in diff --git fallback regex to correctly parse paths containing ' b/' (e.g., binary diffs without +++ b/ lines). - Add test exercising the git header fallback for binary diffs with ' b/' in the path. Applied via @cursor push command --- apps/server/src/codexAppServerManager.ts | 2 +- apps/web/src/session-logic.test.ts | 12 ++++++++++++ apps/web/src/session-logic.ts | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/server/src/codexAppServerManager.ts b/apps/server/src/codexAppServerManager.ts index 406a41a082b7a2ba28aef99ea97be1ffe3c248ad..6122ec601f61e1415abcba35662c7a831c1ffebd 100644 --- a/apps/server/src/codexAppServerManager.ts +++ b/apps/server/src/codexAppServerManager.ts @@ -201,7 +201,7 @@ export class CodexAppServerManager extends EventEmitter { expect(files).toHaveLength(1); expect(files[0]?.path).toBe("subdir b/example.ts"); }); + + it("parses git header fallback for binary diffs with ` b/` in path", () => { + const files = deriveTurnDiffFilesFromUnifiedDiff( + [ + "diff --git a/subdir b/image.png b/subdir b/image.png", + "Binary files a/subdir b/image.png and b/subdir b/image.png differ", + ].join("\n"), + ); + + expect(files).toHaveLength(1); + expect(files[0]?.path).toBe("subdir b/image.png"); + }); }); describe("derivePendingApprovals", () => { diff --git a/apps/web/src/session-logic.ts b/apps/web/src/session-logic.ts index 224d5f12919f7669f98d9ae75aa7bc846c0d71de..c3fb155589a33a52a72354fae1bf0515a337ecea 100644 --- a/apps/web/src/session-logic.ts +++ b/apps/web/src/session-logic.ts @@ -522,8 +522,8 @@ function parsePathFromDiff(diff: string): string | undefined { const normalized = diff.replace(/\r\n/g, "\n"); const bPath = normalized.match(/^\+\+\+ b\/(.+)$/m); if (bPath && bPath[1]) return bPath[1]; - const gitHeader = normalized.match(/^diff --git a\/(.+) b\/(.+)$/m); - if (gitHeader && gitHeader[2]) return gitHeader[2]; + const gitHeader = normalized.match(/^diff --git a\/(.+) b\/\1$/m); + if (gitHeader && gitHeader[1]) return gitHeader[1]; const direct = normalized.match(/^\+\+\+ (.+)$/m); if (!direct || !direct[1] || direct[1] === "/dev/null") { return undefined; -- 2.54.0