{"draft":null,"from":152,"to":318,"files":[{"path":"worker/project/queue.ts","added":28,"removed":9,"diff":"--- a/worker/project/queue.ts\n+++ b/worker/project/queue.ts\n@@ -2,9 +2,11 @@\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 { autoSettledOf } from \"./autosettle.ts\";\n import type { Pair } from \"./collisions.ts\";\n import { definedTwice } from \"./definitions.ts\";\n-import { keptOf, lostLines } from \"./markers.ts\";\n+import { heldMessage, keptOf, lostLines } from \"./markers.ts\";\n import { clip } from \"./news.ts\";\n import { ProjectError } from \"./project-error.ts\";\n import { projectFileIn } from \"./project-helpers.ts\";\n@@ -28,6 +30,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@@ -49,6 +53,7 @@\n \t\ttime: number,\n \t\tcollisions: Collision[],\n \t\tentries: Entry[],\n+\t\tmessage?: string,\n \t): { ok: false; collisions: Collision[] };\n \tcurrentChange(agent: AgentState, time: number): number | undefined;\n \tnextAt(): number;\n@@ -116,11 +121,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@@ -149,19 +156,24 @@\n \t\t\t\t});\n \t\t\t}\n \t\t}\n-\t\tif (collisions.length > 0) return host.refuse(agent, space, \"publish\", time, collisions, entries);\n+\t\tif (collisions.length > 0) return host.refuse(agent, space, \"publish\", time, collisions, entries, message);\n \t}\n \tconst view = host.agentView(agent);\n+\tconst auto = autoSettledOf(message);\n \tconst settled: Settled[] = agent.marked\n \t\t.filter((r) => r.space === SHARED)\n \t\t.map((r) => {\n \t\t\tconst lines = view.hasFile(r.file) ? view.lines(r.file).map((l) => l.text) : [];\n \t\t\tconst lost = lostLines(lines, r);\n+\t\t\tconst held = heldMessage(agent, r.file);\n+\t\t\tconst by = auto.get(r.file);\n \t\t\treturn {\n \t\t\t\tfile: r.file,\n \t\t\t\tkept: keptOf(lines, r),\n \t\t\t\ttheirs: { agent: r.agent, version: r.version },\n \t\t\t\t...(lost.length > 0 ? { lost } : {}),\n+\t\t\t\t...(held ? { held } : {}),\n+\t\t\t\t...(by ? { auto: by } : {}),\n \t\t\t};\n \t\t});\n \tconst id = host.queuedId() + 1;\n@@ -228,7 +240,13 @@\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 =\n+\t\tchanges.length === 0\n+\t\t\t? host.sharedView()\n+\t\t\t: host.sharedOverlay\n+\t\t\t\t? host.sharedOverlay(changes)\n+\t\t\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@@ -247,8 +265,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":[]}