fix(webui): admit history without dropping live output (NAN-311)

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-22 01:22:49 +08:00
1 parent df63526ddf
commit b37a23698d
21 files changed
+3026 -1607

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { expect, it } from "vitest";
import { MemoryLruCache } from "@/lib/memory-lru-cache";
it.each([
{ collection: "Map keys", small: new Map([["turn", "source"]]), large: new Map([["x".repeat(64), "source"]]) },
{ collection: "Map values", small: new Map([["turn", "source"]]), large: new Map([["turn", "x".repeat(64)]]) },
{ collection: "Set members", small: new Set(["turn"]), large: new Set(["x".repeat(64)]) },
])("counts nested $collection toward the byte budget", ({ small, large }) => {
const cache = new MemoryLruCache<{ members: typeof large }>(160, 2);
const snapshot = { members: small };
cache.set("small", snapshot);
expect(cache.get("small")).toBe(snapshot);
cache.set("large", { members: large });
expect(cache.get("large")).toBeUndefined();
cache.set("small", snapshot);
expect(cache.get("small")).toBe(snapshot);
});