GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(codex): Open diff shows every file of a multi-file patch (#40874) · AIdoesmyjob/t3code@f0f29d6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/orchestration-v2/Adapters
    • CodexAdapterV2.test.ts
    • CodexAdapterV2.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12710,6 +12710,28 @@ describe("CodexAdapterV2 post-settle continuation", () => {
1271012710
{ operation: "delete", path: "/w/e.ts" },
1271112711
{ operation: "add", path: "/w/a.ts" },
1271212712
]);
12713+
assert.equal(
12714+
fileChanges[0]?.diffStr,
12715+
[
12716+
'diff --git "a//w/c.ts" "b//w/d.ts"',
12717+
'--- "a//w/c.ts"',
12718+
'+++ "b//w/d.ts"',
12719+
"@@",
12720+
'diff --git "a//w/e.ts" "b//w/e.ts"',
12721+
'--- "a//w/e.ts"',
12722+
"+++ /dev/null",
12723+
"@@ -1,1 +0,0 @@",
12724+
"-gone",
12725+
"\\ No newline at end of file",
12726+
'diff --git "a//w/a.ts" "b//w/a.ts"',
12727+
"--- /dev/null",
12728+
'+++ "b//w/a.ts"',
12729+
"@@ -0,0 +1,1 @@",
12730+
"+export {};",
12731+
"\\ No newline at end of file",
12732+
"",
12733+
].join("\n"),
12734+
);
1271312735
}).pipe(
1271412736
Effect.scoped,
1271512737
Effect.provide(
Collapse file

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+31-1Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,35 @@ type CodexFileChangeKinds = Readonly<
174174
Record<string, CodexSchema.V2ItemStartedNotification__PatchChangeKind>
175175
>;
176176

177+
// Diff parsers split at Git headers once one exists, so each file of a multi-file patch needs its own.
178+
function codexMultiFilePatch(
179+
changes: ReadonlyArray<CodexSchema.V2ItemCompletedNotification__FileUpdateChange>,
180+
): string {
181+
return changes
182+
.map(({ path, kind, diff }) => {
183+
const oldPath = path;
184+
const newPath = (kind.type === "update" && kind.move_path) || path;
185+
const git = `diff --git ${JSON.stringify(`a/${oldPath}`)} ${JSON.stringify(`b/${newPath}`)}\n`;
186+
if (kind.type === "update" && diff.startsWith("diff --git ")) return diff;
187+
if (kind.type === "update" && diff.startsWith("--- ")) return `${git}${diff}`;
188+
let hunks = diff;
189+
// Codex records added and deleted files as their raw contents.
190+
if (kind.type !== "update") {
191+
const lines = diff.split("\n");
192+
const hasFinalNewline = diff.endsWith("\n");
193+
if (hasFinalNewline) lines.pop();
194+
const added = kind.type === "add";
195+
const range = `1,${lines.length}`;
196+
hunks = `@@ -${added ? "0,0" : range} +${added ? range : "0,0"} @@\n${lines.map((line) => `${added ? "+" : "-"}${line}`).join("\n")}\n${hasFinalNewline ? "" : "\\ No newline at end of file\n"}`;
197+
}
198+
const before = kind.type === "add" ? "/dev/null" : JSON.stringify(`a/${oldPath}`);
199+
const after = kind.type === "delete" ? "/dev/null" : JSON.stringify(`b/${newPath}`);
200+
return `${git}--- ${before}\n+++ ${after}\n${hunks}`;
201+
})
202+
.map((section) => (section.endsWith("\n") ? section : `${section}\n`))
203+
.join("");
204+
}
205+
177206
function codexFileChangeApprovalPrompt(input: {
178207
readonly reason?: string | null;
179208
readonly grantRoot?: string | null;
@@ -4249,7 +4278,8 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
42494278
updatedAt,
42504279
type: "file_change",
42514280
fileName: firstChange.path,
4252-
diffStr: firstChange.diff,
4281+
diffStr:
4282+
item.changes.length > 1 ? codexMultiFilePatch(item.changes) : firstChange.diff,
42534283
changes: item.changes.map((change) => {
42544284
const movePath = change.kind.type === "update" ? change.kind.move_path : undefined;
42554285
return movePath

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.