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...@@ -201,7 +201,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
201 const normalizedModel = normalizeCodexModelSlug(input.model);201 const normalizedModel = normalizeCodexModelSlug(input.model);
202 const sessionOverrides = {202 const sessionOverrides = {
203 model: normalizedModel ?? null,203 model: normalizedModel ?? null,
204 cwd: resolvedCwd,204 cwd: input.cwd ?? null,
205 approvalPolicy: input.approvalPolicy,205 approvalPolicy: input.approvalPolicy,
206 sandbox: input.sandboxMode,206 sandbox: input.sandboxMode,
207 };207 };
apps/web/src/session-logic.test.ts+12
...@@ -614,6 +614,18 @@ describe("deriveTurnDiffFilesFromUnifiedDiff", () => {...@@ -614,6 +614,18 @@ describe("deriveTurnDiffFilesFromUnifiedDiff", () => {
614 expect(files).toHaveLength(1);614 expect(files).toHaveLength(1);
615 expect(files[0]?.path).toBe("subdir b/example.ts");615 expect(files[0]?.path).toBe("subdir b/example.ts");
616 });616 });
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 });
617});629});
618630
619describe("derivePendingApprovals", () => {631describe("derivePendingApprovals", () => {
apps/web/src/session-logic.ts+2-2
...@@ -522,8 +522,8 @@ function parsePathFromDiff(diff: string): string | undefined {...@@ -522,8 +522,8 @@ function parsePathFromDiff(diff: string): string | undefined {
522 const normalized = diff.replace(/\r\n/g, "\n");522 const normalized = diff.replace(/\r\n/g, "\n");
523 const bPath = normalized.match(/^\+\+\+ b\/(.+)$/m);523 const bPath = normalized.match(/^\+\+\+ b\/(.+)$/m);
524 if (bPath && bPath[1]) return bPath[1];524 if (bPath && bPath[1]) return bPath[1];
525 const gitHeader = normalized.match(/^diff --git a\/(.+) b\/(.+)$/m);525 const gitHeader = normalized.match(/^diff --git a\/(.+) b\/\1$/m);
526 if (gitHeader && gitHeader[2]) return gitHeader[2];526 if (gitHeader && gitHeader[1]) return gitHeader[1];
527 const direct = normalized.match(/^\+\+\+ (.+)$/m);527 const direct = normalized.match(/^\+\+\+ (.+)$/m);
528 if (!direct || !direct[1] || direct[1] === "/dev/null") {528 if (!direct || !direct[1] || direct[1] === "/dev/null") {
529 return undefined;529 return undefined;