Compare commits

...
@@ -4,6 +4,7 @@ import { describe, expect, test } from "vitest";
import type { AgentTimelineRow } from "./agent-manager.js";
import {
projectTimelineRows,
TimelineProjection,
selectTimelineWindowByProjectedLimit,
} from "./timeline-projection.js";
@@ -990,3 +991,31 @@ describe("selectProjectedTimelinePage", () => {
expect(page.endSeq).toBe(501);
});
});
test("returns the whole last assistant message when a notification arrives mid-reply", () => {
const opening = "| Name | Value |\n| --- | --- |\n| Switch | permanent";
const ending = " LAN address |";
const first: AgentTimelineRow["item"] = {
type: "assistant_message",
text: opening,
messageId: "m1",
};
const last = { ...first, text: ending };
const replyWith = (...items: AgentTimelineRow["item"][]) => {
const projection = new TimelineProjection();
for (const [index, item] of items.entries()) {
projection.append({
seq: index + 1,
timestamp: new Date(index).toISOString(),
turnId: "t1",
item,
});
}
return projection.getLastAssistantMessage();
};
expect(replyWith(first, last)).toBe(opening + ending);
expect(replyWith(first, { type: "notification", level: "info", message: "Done" }, last)).toBe(
opening + ending,
);
});