mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
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:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user