import { describe, expect, test, vi } from "vitest"; import { HEARTBEAT_PROMPT } from "../auto-reply/heartbeat.js"; import { buildSessionHistorySnapshot, SessionHistorySseState } from "./session-history-state.js"; import * as sessionUtils from "./session-utils.js";
describe("SessionHistorySseState", () => {
test("uses the initial raw snapshot for both first history and seq seeding", () => { const readSpy = vi.spyOn(sessionUtils, "readSessionMessages").mockReturnValue([
{
role: "assistant",
content: [{ type: "text", text: "stale disk message" }],
__openclaw: { seq: 1 },
},
]); try { const state = SessionHistorySseState.fromRawSnapshot({
target: { sessionId: "sess-main" },
rawMessages: [
{
role: "assistant",
content: [{ type: "text", text: "fresh snapshot message" }],
__openclaw: { seq: 2 },
},
],
});
expect(state.snapshot().messages).toHaveLength(1);
expect(
(
state.snapshot().messages[0] as {
content?: Array<{ text?: string }>;
__openclaw?: { seq?: number };
}
).content?.[0]?.text,
).toBe("fresh snapshot message");
expect(
(
state.snapshot().messages[0] as {
__openclaw?: { seq?: number };
}
).__openclaw?.seq,
).toBe(2);
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.8Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.