feat(workbench): refine dynamic task collaboration

This commit is contained in:
2026-09-24 16:36:12 +08:00
parent b64d2b78bb
commit 87cc7785da
25 changed files with 1216 additions and 470 deletions
@@ -0,0 +1,31 @@
import { describe, expect, it } from "vitest";
import { shouldApplyWorkbenchSnapshot } from "./use-workbench-sync";
describe("workbench snapshot ordering", () => {
it("rejects an older concurrent response even when its cursor is valid", () => {
expect(shouldApplyWorkbenchSnapshot({
requestGeneration: 1,
latestRequestGeneration: 2,
eventCursor: 120,
currentCursor: 100
})).toBe(false);
});
it("rejects a snapshot whose cursor trails already consumed events", () => {
expect(shouldApplyWorkbenchSnapshot({
requestGeneration: 2,
latestRequestGeneration: 2,
eventCursor: 99,
currentCursor: 100
})).toBe(false);
});
it("accepts only the latest response without cursor rollback", () => {
expect(shouldApplyWorkbenchSnapshot({
requestGeneration: 2,
latestRequestGeneration: 2,
eventCursor: 100,
currentCursor: 100
})).toBe(true);
});
});