{"draft":null,"from":162,"to":163,"files":[{"path":"worker/project/queue.ts","added":16,"removed":7,"diff":"--- a/worker/project/queue.ts\n+++ b/worker/project/queue.ts\n@@ -2,6 +2,7 @@\n // Writes go through QueueHost; today the host is Project.\n \n import { type AtomId, buildAtom, type Graph, type ReadView } from \"../../src/engine/index.ts\";\n+import { unionOverlay } from \"../../src/engine/state-source.ts\";\n import type { Pair } from \"./collisions.ts\";\n import { definedTwice } from \"./definitions.ts\";\n import { heldMessage, keptOf, lostLines } from \"./markers.ts\";\n@@ -28,6 +29,8 @@\n \treadonly graph: Graph;\n \tcheckerReady(): boolean;\n \tsharedView(): ReadView;\n+\tsharedOverlay?(atoms: readonly AtomId[]): ReadView;\n+\tsharedAgentOverlay?(agent: AgentState, atoms: readonly AtomId[]): ReadView;\n \tqueued(): readonly QueuedPublish[];\n \tqueuedId(): number;\n \tcheckingHas(id: number): boolean;\n@@ -117,11 +120,13 @@\n \tconst ahead = queuedAtoms(host, agent.name);\n \tconst now = host.setOf(space);\n \tif (ahead.size > 0) {\n-\t\tconst landed = new Set([...now, ...ahead]);\n-\t\tconst theirsView = host.view(landed);\n-\t\tconst yoursView = host.view(new Set([...landed, ...host.agentSet(agent)]));\n+\t\tconst landed = unionOverlay(now, ahead);\n+\t\tconst theirsView = host.sharedOverlay ? host.sharedOverlay([...ahead]) : host.view(landed);\n+\t\tconst yoursView = host.sharedAgentOverlay\n+\t\t\t? host.sharedAgentOverlay(agent, [...ahead])\n+\t\t\t: host.view(unionOverlay(landed, host.agentSet(agent)));\n \t\tconst queuedBy = (id: AtomId) => host.queued().find((q) => q.changes.includes(id));\n-\t\tconst collisions: Collision[] = host.pairs(changes, ahead, new Set([...landed, ...changes])).map((p) => {\n+\t\tconst collisions: Collision[] = host.pairs(changes, ahead, unionOverlay(landed, changes)).map((p) => {\n \t\t\tconst c = host.describe(p, host.agentView(agent), theirsView, agent.space);\n \t\t\tconst q = queuedBy(p.theirs);\n \t\t\treturn q ? { ...c, theirs: { ...c.theirs, agent: q.agent, message: q.message, queued: q.id } } : c;\n@@ -231,7 +236,10 @@\n } {\n \thost.needInit();\n \tconst items = host.queued().slice(0, Math.max(0, n));\n-\tconst view = host.view(new Set([...host.setOf(host.shared()), ...items.flatMap((q) => q.changes)]));\n+\tconst changes = items.flatMap((q) => q.changes);\n+\tconst view = host.sharedOverlay\n+\t\t? host.sharedOverlay(changes)\n+\t\t: host.view(unionOverlay(host.setOf(host.shared()), changes));\n \tconst files = view.files();\n \tconst modes = modesOf(view);\n \tconst blobs = view.blobs();\n@@ -250,8 +258,9 @@\n \t\tfor (const q of host.queued().slice(0, Math.max(0, n))) {\n \t\t\tconst agent = host.agentOf(q.agent);\n \t\t\tconst space = host.shared();\n-\t\t\tconst union = new Set([...host.setOf(space), ...q.changes]);\n-\t\t\tconst tie = buildAtom(host.view(union), {\n+\t\t\tconst union = unionOverlay(host.setOf(space), q.changes);\n+\t\t\tconst view = host.sharedOverlay ? host.sharedOverlay(q.changes) : host.view(union);\n+\t\t\tconst tie = buildAtom(view, {\n \t\t\t\tauthor: q.agent,\n \t\t\t\tmessage: q.message,\n \t\t\t\ttime,"}],"unmatched":[]}