diff --git a/packages/coding-agent/src/debug/report-bundle.ts b/packages/coding-agent/src/debug/report-bundle.ts index c99e046d5..4329c0954 100644 --- a/packages/coding-agent/src/debug/report-bundle.ts +++ b/packages/coding-agent/src/debug/report-bundle.ts @@ -277,7 +277,7 @@ async function collectSameDayLogs(linesPerFile: number): Promise { return chunks.join("\n\n"); } -const LOG_FILE_PATTERN = new RegExp(`^${APP_NAME}\\.(\\d{4}-\\d{2}-\\d{2})\\.\\d+\\.log$`); +const LOG_FILE_PATTERN = new RegExp(`^${APP_NAME}\\.(\\d{4}-\\d{2}-\\d{2})\\.\\d+\\.log(?:\\.\\d+)?$`); export async function createDebugLogSource(): Promise { const logsDir = getLogsDir(); diff --git a/packages/coding-agent/test/debug/report-bundle-logs.test.ts b/packages/coding-agent/test/debug/report-bundle-logs.test.ts index 2f2ba3dea..532a3a7b3 100644 --- a/packages/coding-agent/test/debug/report-bundle-logs.test.ts +++ b/packages/coding-agent/test/debug/report-bundle-logs.test.ts @@ -40,9 +40,12 @@ describe("report bundle logs", () => { await fs.mkdir(logsDir, { recursive: true }); const today = new Date().toISOString().slice(0, 10); const crashedName = `omp.${today}.4242.log`; + const rotatedName = `${crashedName}.1`; const currentName = `omp.${today}.${process.pid}.log`; await Bun.write(path.join(logsDir, crashedName), '{"pid":4242,"message":"fatal in crashed pid"}\n'); await fs.utimes(path.join(logsDir, crashedName), 1, 1); + await Bun.write(path.join(logsDir, rotatedName), '{"pid":4242,"message":"earlier rotated crash output"}\n'); + await fs.utimes(path.join(logsDir, rotatedName), 0, 0); await Bun.write(path.join(logsDir, currentName), '{"pid":0,"message":"later invocation"}\n'); await fs.utimes(path.join(logsDir, currentName), 2, 2); @@ -54,6 +57,8 @@ describe("report bundle logs", () => { const logsText = (await files.get("logs.txt")?.text()) ?? ""; expect(logsText).toContain(crashedName); expect(logsText).toContain("fatal in crashed pid"); + expect(logsText).toContain(rotatedName); + expect(logsText).toContain("earlier rotated crash output"); expect(logsText).toContain(currentName); expect(logsText).toContain("later invocation"); expect(logsText.indexOf(crashedName)).toBeLessThan(logsText.indexOf(currentName));