Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions sdk/typescript/src/scan-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export async function readScanLogs(options: ScanLogOptions) {
}
}
}
const completedBoundary =
options.completedAt === undefined || options.completedAt === null
? Number.NaN
: Date.parse(options.completedAt);
const events: Record<string, unknown>[] = [];
for (const session of sessions) {
let replaying = false;
Expand All @@ -91,6 +95,15 @@ export async function readScanLogs(options: ScanLogOptions) {
}
replaying = false;
}
if (
Number.isFinite(completedBoundary) &&
typeof event["timestamp"] === "string"
) {
const eventTime = Date.parse(event["timestamp"]);
if (Number.isFinite(eventTime) && eventTime > completedBoundary) {
continue;
}
}
events.push({ threadId: session.threadId, event });
}
}
Expand Down
32 changes: 32 additions & 0 deletions sdk/typescript/tests-ts/scan-logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,38 @@ describe("saved scan logs", () => {
expect(JSON.stringify(result)).not.toContain("PRIVATE PRE-SCAN");
});

test("excludes logs after completed time", async () => {
const home = await temporaryHome();
await writeSession(
home,
"parent",
[
commandEvent(
"DURING scan event",
"call-during",
"2026-08-21T12:01:00.000Z",
),
commandEvent(
"AFTER hours event",
"call-after",
"2026-08-21T12:03:00.000Z",
),
],
undefined,
"2026-08-21T12:00:00.000Z",
);

const result = await readScanLogs({
scanId: "scan-1",
threadId: "parent",
codexHome: home,
completedAt: "2026-08-21T12:02:00.000Z",
});

expect(JSON.stringify(result)).toContain("DURING scan event");
expect(JSON.stringify(result)).not.toContain("AFTER hours event");
});

test("includes independent Deep workers without crossing scan boundaries", async () => {
const home = await temporaryHome();
const scanDirectory = join(home, "scans", "current");
Expand Down