authorgravatar for cursoragent@cursor.comCursor Agent <cursoragent@cursor.com> 2026-02-19 04:19:44+00:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-02-18 21:59:17-08:00
logbb9371d3c9500bf035b7df5da0969b82aac5a1fc
treec0696a92b446648cf4d38805bb5ac1fc4e14bd56
parentbd1c7e1d9ae77e1c047e19ef895c089c00d87aa5

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

3 files changed, 15 insertions(+), 3 deletions(-)

apps/server/src/codexAppServerManager.ts+1-1
......@@ -201,7 +201,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
201201 const normalizedModel = normalizeCodexModelSlug(input.model);
202202 const sessionOverrides = {
203203 model: normalizedModel ?? null,
204 cwd: resolvedCwd,
204 cwd: input.cwd ?? null,
205205 approvalPolicy: input.approvalPolicy,
206206 sandbox: input.sandboxMode,
207207 };
apps/web/src/session-logic.test.ts+12
......@@ -614,6 +614,18 @@ describe("deriveTurnDiffFilesFromUnifiedDiff", () => {
614614 expect(files).toHaveLength(1);
615615 expect(files[0]?.path).toBe("subdir b/example.ts");
616616 });
617
618 it("parses git header fallback for binary diffs with ` b/` in path", () => {
619 const files = deriveTurnDiffFilesFromUnifiedDiff(
620 [
621 "diff --git a/subdir b/image.png b/subdir b/image.png",
622 "Binary files a/subdir b/image.png and b/subdir b/image.png differ",
623 ].join("\n"),
624 );
625
626 expect(files).toHaveLength(1);
627 expect(files[0]?.path).toBe("subdir b/image.png");
628 });
617629});
618630
619631describe("derivePendingApprovals", () => {
apps/web/src/session-logic.ts+2-2
......@@ -522,8 +522,8 @@ function parsePathFromDiff(diff: string): string | undefined {
522522 const normalized = diff.replace(/\r\n/g, "\n");
523523 const bPath = normalized.match(/^\+\+\+ b\/(.+)$/m);
524524 if (bPath && bPath[1]) return bPath[1];
525 const gitHeader = normalized.match(/^diff --git a\/(.+) b\/(.+)$/m);
526 if (gitHeader && gitHeader[2]) return gitHeader[2];
525 const gitHeader = normalized.match(/^diff --git a\/(.+) b\/\1$/m);
526 if (gitHeader && gitHeader[1]) return gitHeader[1];
527527 const direct = normalized.match(/^\+\+\+ (.+)$/m);
528528 if (!direct || !direct[1] || direct[1] === "/dev/null") {
529529 return undefined;