feat: make context compaction visible in channels (#5656)

* feat: surface context compaction lifecycle

* fix: complete and simplify context compaction notifications
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-05 20:21:54 +08:00
1 parent 455533169d
commit 5229989f28
52 files changed
+1849 -140

No files matched your search

@@ -66,6 +66,26 @@ describe("normalizeLegacyLongTaskMessages", () => {
});
describe("projectWebuiThreadMessages", () => {
it("marks only fixed replies belonging to a compact command turn", () => {
const rows = [
message("user", { content: " /COMPACT ", turnId: "compact" }),
message("assistant", { content: "Nothing to compact.", turnId: "compact" }),
message("assistant", {
content: "Unable to compact context. Check the logs and try again.", turnId: "compact",
}),
message("assistant", { content: "Nothing to compact.", turnId: "unrelated" }),
message("assistant", { content: "Nothing to compact." }),
message("assistant", { content: "Nothing to compact.", turnId: "compact", isStreaming: true }),
message("assistant", { content: "Quoted: Nothing to compact.", turnId: "compact" }),
];
const projected = projectWebuiThreadMessages(rows);
expect(projected.map(({ compactReply }) => compactReply)).toEqual([
undefined, "empty", "failed", undefined, undefined, undefined, undefined,
]);
expect(projected.map(({ content }) => content)).toEqual(rows.map(({ content }) => content));
expect(projectWebuiThreadMessages(projected)).toEqual(projected);
});
it("derives replayed completion time from the matching user turn", () => {
const firstOutputAt = STARTED_AT + 5_000;
const latencyMs = 13_000;