Lines 2–8 at 163 (were 2–7 at 162)
22// Writes go through QueueHost; today the host is Project. 44import { type AtomId, buildAtom, type Graph, type ReadView } from "../../src/engine/index.ts"; 5+import { unionOverlay } from "../../src/engine/state-source.ts"; 56import type { Pair } from "./collisions.ts"; 67import { definedTwice } from "./definitions.ts"; 78import { heldMessage, keptOf, lostLines } from "./markers.ts"; Lines 29–36 at 163 (were 28–33 at 162)
2829 readonly graph: Graph; 2930 checkerReady(): boolean; 3031 sharedView(): ReadView; 32+ sharedOverlay?(atoms: readonly AtomId[]): ReadView; 33+ sharedAgentOverlay?(agent: AgentState, atoms: readonly AtomId[]): ReadView; 3134 queued(): readonly QueuedPublish[]; 3336 checkingHas(id: number): boolean; Lines 120–132 at 163 (were 117–127 at 162)
117120 const ahead = queuedAtoms(host, agent.name); 118121 const now = host.setOf(space); 119122 if (ahead.size > 0) { 120− const landed = new Set([...now, ...ahead]);
121− const theirsView = host.view(landed);
122− const yoursView = host.view(new Set([...landed, ...host.agentSet(agent)]));
123+ const landed = unionOverlay(now, ahead); 124+ const theirsView = host.sharedOverlay ? host.sharedOverlay([...ahead]) : host.view(landed); 125+ const yoursView = host.sharedAgentOverlay 126+ ? host.sharedAgentOverlay(agent, [...ahead]) 127+ : host.view(unionOverlay(landed, host.agentSet(agent))); 123128 const queuedBy = (id: AtomId) => host.queued().find((q) => q.changes.includes(id)); 124− const collisions: Collision[] = host.pairs(changes, ahead, new Set([...landed, ...changes])).map((p) => {
129+ const collisions: Collision[] = host.pairs(changes, ahead, unionOverlay(landed, changes)).map((p) => { 125130 const c = host.describe(p, host.agentView(agent), theirsView, agent.space); 126131 const q = queuedBy(p.theirs); 127132 return q ? { ...c, theirs: { ...c.theirs, agent: q.agent, message: q.message, queued: q.id } } : c; Lines 236–245 at 163 (were 231–237 at 162)
233238 const items = host.queued().slice(0, Math.max(0, n)); 234− const view = host.view(new Set([...host.setOf(host.shared()), ...items.flatMap((q) => q.changes)]));
239+ const changes = items.flatMap((q) => q.changes); 240+ const view = host.sharedOverlay 241+ ? host.sharedOverlay(changes) 242+ : host.view(unionOverlay(host.setOf(host.shared()), changes)); 235243 const files = view.files(); 236244 const modes = modesOf(view); 237245 const blobs = view.blobs(); Lines 258–266 at 163 (were 250–257 at 162)
250258 for (const q of host.queued().slice(0, Math.max(0, n))) { 251259 const agent = host.agentOf(q.agent); 252260 const space = host.shared(); 253− const union = new Set([...host.setOf(space), ...q.changes]);
254− const tie = buildAtom(host.view(union), {
261+ const union = unionOverlay(host.setOf(space), q.changes); 262+ const view = host.sharedOverlay ? host.sharedOverlay(q.changes) : host.view(union); 263+ const tie = buildAtom(view, { 256265 message: q.message,