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.
This commit is contained in:
wanyongstar
2026-08-06 11:53:40 +08:00
committed by GitHub
parent 793f602f80
commit f608d2e2f8
2 changed files with 28 additions and 1 deletions
@@ -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": {
@@ -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":