fix(canvas): 画布 - 防止旧内容覆盖并支持版本历史恢复

This commit is contained in:
kinoko
2026-09-17 18:40:42 +08:00
parent b6bae4f957
commit 35ebed3097
69 changed files with 3575 additions and 294 deletions

View File

@@ -71,3 +71,14 @@ test("fallback snapshots obey the configured minimum refresh interval", async ()
expect(times).toHaveLength(2);
expect(times[1] - times[0]).toBeGreaterThanOrEqual(100);
});
test("a full invalidation and undo still refresh after delta support was detected", async () => {
const refresh = mock(async () => {});
const sync = createAgentCanvasSync({ canvasId: "canvas", applyPatches: async () => {}, refresh, onError: () => {}, batchMs: 0, refreshIntervalMs: 0 });
sync.receive(delta); await sleep();
sync.receive(event("canvas_updated", { canvasId: "canvas", requiresRefresh: true })); await sleep();
expect(refresh).toHaveBeenCalledTimes(1);
sync.receive(event("canvas_undone", { canvasId: "canvas" })); await sleep();
expect(refresh).toHaveBeenCalledTimes(2);
sync.dispose();
});