Skip to content

Commit e29a770

Browse files
committed
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
1 parent 4c98219 commit e29a770

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎apps/server/src/codexAppServerManager.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

619631
describe("derivePendingApprovals", () => {

‎apps/web/src/session-logic.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

0 commit comments

Comments
 (0)