Skip to content
TypeScript

fix(codex): keep every path of a multi-file patch (#22541)

Victor Vogelaacd1ee33779
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
index bc69f75d37e..5f00beb2fbc 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
@@ -6098,5 +6098,34 @@ describe("CodexAdapterV2 post-settle continuation", () => {
),
),
);
+
+ it.effect("keeps every path of a completed multi-file patch", () =>
+ Effect.gen(function* () {
+ const { harness } = yield* startApprovalTurn("file-change-multi-path", [
+ fileChange("started", nativeTurnId, "patch-a", [renameC, deleteE, addA]),
+ fileChange("completed", nativeTurnId, "patch-a", [renameC, deleteE, addA]),
+ turnCompleted(nativeTurnId),
+ ]);
+ yield* harness.firstTerminal;
+
+ const fileChanges = harness.events.flatMap((event) =>
+ event.type === "turn_item.updated" && event.turnItem.type === "file_change"
+ ? [event.turnItem]
+ : [],
+ );
+ assert.lengthOf(fileChanges, 1);
+ assert.equal(fileChanges[0]?.fileName, "/w/c.ts");
+ assert.deepEqual(fileChanges[0]?.changes, [
+ { operation: "update", path: "/w/d.ts", oldPath: "/w/c.ts" },
+ { operation: "delete", path: "/w/e.ts" },
+ { operation: "add", path: "/w/a.ts" },
+ ]);
+ }).pipe(
+ Effect.scoped,
+ Effect.provide(
+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
+ ),
+ ),
+ );
});
});
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
index b809f065686..5c4df98d310 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
@@ -3635,6 +3635,12 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
type: "file_change",
fileName: firstChange.path,
diffStr: firstChange.diff,
+ changes: item.changes.map((change) => {
+ const movePath = change.kind.type === "update" ? change.kind.move_path : undefined;
+ return movePath
+ ? { operation: change.kind.type, path: movePath, oldPath: change.path }
+ : { operation: change.kind.type, path: change.path };
+ }),
};
return { node, turnItem };
},