fix(webui): retain system context graph after compaction (#6608)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-09 13:20:46 +08:00
1 parent d789e1bfc7
commit 4212ad726d
25 files changed
+748 -102

No files matched your search

+18
View File
@@ -257,3 +257,21 @@ it.each(["failed", "cancelled", "completed"] as const)("does not borrow previous
expect(frames[0].usage).toEqual(usage(1));
expect(frames[1].usage).toBeUndefined();
});
it.each([false, true])("shows the active system graph immediately after compaction (persisted=%s)", (persisted) => {
const transcript = new ThreadTranscript();
const oldGraph = { nodes: [{ path: "/before.py", name: "before.py", state: "loaded" as const, tokens: 50 }], edges: [] };
const systemGraph = { nodes: [{ path: "/SOUL.md", name: "SOUL.md", state: "loaded" as const, tokens: 40 }], edges: [] };
project(transcript, request(1, { request_id: "active", context_graph: oldGraph }), persisted);
const event = parseWebuiThreadPayload({ schemaVersion: 3, projection: "events", events: [{ ...envelope,
event: "context_compaction", compaction_id: "boundary", phase: "succeeded", turn_seq: 2, context_graph: systemGraph,
}] }).events[0];
project(transcript, event, persisted);
expect(composerContextSnapshots(transcript.messages, transcript.modelRequests)).toEqual([
{ id: "compaction-boundary", graph: systemGraph },
]);
project(transcript, request(3, { request_id: "active", phase: "completed", context_graph: systemGraph }), persisted);
expect(composerContextSnapshots(transcript.messages, transcript.modelRequests).map((snapshot) => snapshot.graph))
.toEqual([systemGraph, systemGraph]);
});
+1
View File
@@ -43,6 +43,7 @@ describe("tab reload cache", () => {
const body = parseWebuiThreadPayload({ schemaVersion: 3, sessionKey: "websocket:growing", revision: "growing-50",
projection: "events", active_turn_id: null, page: { before_cursor: "older", has_more_before: true },
events: [{ event: "context_compaction", chat_id: "growing", compaction_id: "checkpoint", phase: "succeeded",
...(format === "inline" ? { context_graph: structuredClone(graphs[0]) } : { context_graph_ref: "0" }),
context_snapshot: { estimated_tokens: 100, context_window_tokens: 100000,
...(format === "inline" ? { graph: structuredClone(graphs[0]) } : { graph_ref: "0" }) } }, ...events],
...(format === "references" ? { context_graphs: table, context_graph_nodes: nodes, context_graph_edges: edges } : {}),