From f608d2e2f84bd99552a233636a17d685641a8780 Mon Sep 17 00:00:00 2001 From: wanyongstar Date: Thu, 6 Aug 2026 11:53:40 +0800 Subject: [PATCH] fix(auto-reply): mark truncated row lists in export-session warnings (#119230) The skipped malformed transcript row warning prints the total count followed by a row-number sample capped at 20, with no indication the list is partial, so messages like "Skipped 25 ... rows 1, ..., 20" read as if every skipped row were listed. Append an ellipsis when the count exceeds the retained sample. --- .../reply/commands-export-session.test.ts | 24 +++++++++++++++++++ .../reply/commands-export-session.ts | 5 +++- 2 files changed, 28 insertions(+), 1 deletion(-) 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":