diff --git a/src/auto-reply/reply/commands-export-session.test.ts b/src/auto-reply/reply/commands-export-session.test.ts index 6da09b40c50d..42fa7db3050a 100644 --- a/src/auto-reply/reply/commands-export-session.test.ts +++ b/src/auto-reply/reply/commands-export-session.test.ts @@ -615,6 +615,30 @@ describe("buildExportSessionReply", () => { ); }); + it("marks the skipped-row list as truncated when more than 20 rows are invalid", async () => { + hoisted.sessionTranscriptEvents = [ + ...Array.from({ length: 25 }, (_, index) => ({ + type: "message", + id: `bad-${index + 1}`, + timestamp: `2026-05-16T00:00:${String(index).padStart(2, "0")}.000Z`, + message: { content: "missing role" }, + })), + { + type: "message", + id: "entry-valid", + timestamp: "2026-05-16T00:01:00.000Z", + message: { role: "assistant", content: "valid assistant" }, + }, + ]; + + const reply = await buildExportSessionReply(makeParams()); + + const expectedRows = Array.from({ length: 20 }, (_, index) => index + 1).join(", "); + expect(reply.text).toContain( + `⚠️ Skipped 25 malformed transcript rows that were not session entries. rows ${expectedRows}, …`, + ); + }); + it("warns when the session only contains user messages (backend-delegated transcript)", async () => { hoisted.loadSessionStoreMock.mockReturnValue({ "agent:target:session": { diff --git a/src/auto-reply/reply/commands-export-session.ts b/src/auto-reply/reply/commands-export-session.ts index 9ec499ba5947..83669c666a8b 100644 --- a/src/auto-reply/reply/commands-export-session.ts +++ b/src/auto-reply/reply/commands-export-session.ts @@ -256,7 +256,10 @@ function formatSkippedRows(count: number): string { } function formatSessionExportWarning(summary: SessionExportWarningSummary): string { - const rows = summary.rows.length > 0 ? ` rows ${summary.rows.join(", ")}` : ""; + const rows = + summary.rows.length > 0 + ? ` rows ${summary.rows.join(", ")}${summary.count > summary.rows.length ? ", …" : ""}` + : ""; const verb = summary.count === 1 ? "was" : "were"; switch (summary.code) { case "invalid-session-json":