Skip to content

Commit 6bff4ed

Browse files
committed
fix(codex): narrow missing history proof
1 parent 1c559d7 commit 6bff4ed

2 files changed

Lines changed: 2 additions & 29 deletions

File tree

‎extensions/codex/src/app-server/attempt-context.test.ts‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,6 @@ describe("Codex app-server attempt context", () => {
4141
}
4242
});
4343

44-
it("keeps malformed mirrored session history on the hook warning path", async () => {
45-
const warn = vi.spyOn(embeddedAgentLog, "warn").mockImplementation(() => undefined);
46-
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "codex-attempt-context-history-"));
47-
const sessionFile = path.join(dir, "session.jsonl");
48-
try {
49-
await fs.writeFile(sessionFile, JSON.stringify({ type: "message", id: "orphan" }) + "\n");
50-
51-
await expect(
52-
readMirroredSessionHistoryMessages({
53-
sessionFile,
54-
sessionId: "codex-session",
55-
sessionKey: "codex-session",
56-
}),
57-
).resolves.toBeUndefined();
58-
expect(warn).toHaveBeenCalledWith(
59-
"failed to read mirrored session history for codex harness hooks",
60-
{ sessionFile },
61-
);
62-
} finally {
63-
await fs.rm(dir, { recursive: true, force: true });
64-
}
65-
});
66-
6744
it("returns a run context report without deferred Codex dynamic tool schemas", () => {
6845
const tools = [
6946
{

‎extensions/codex/src/app-server/session-history.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ import {
1717
import { sanitizeCodexHistoryImagePayloads } from "./image-payload-sanitizer.js";
1818

1919
function isMissingFileError(error: unknown): boolean {
20-
return Boolean(
21-
error &&
22-
typeof error === "object" &&
23-
"code" in error &&
24-
(error as { code?: unknown }).code === "ENOENT",
25-
);
20+
return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
2621
}
2722

2823
export type CodexMirroredSessionHistoryTarget = {
@@ -61,6 +56,7 @@ export async function readCodexMirroredSessionHistoryMessages(
6156
"codex mirrored history",
6257
);
6358
} catch (error) {
59+
// A new Codex session can be read before its transcript exists; other failures still warn.
6460
if (isMissingFileError(error)) {
6561
return [];
6662
}

0 commit comments

Comments
 (0)