Lines 2–12 at 318 (were 2–10 at 157)
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"; 6+import { autoSettledOf } from "./autosettle.ts"; 57import type { Pair } from "./collisions.ts"; 68import { definedTwice } from "./definitions.ts"; 7−import { keptOf, lostLines } from "./markers.ts";
9+import { heldMessage, keptOf, lostLines } from "./markers.ts"; 810import { clip } from "./news.ts"; 911import { ProjectError } from "./project-error.ts"; 1012import { projectFileIn } from "./project-helpers.ts"; Lines 30–37 at 318 (were 28–33 at 157)
2830 readonly graph: Graph; 2931 checkerReady(): boolean; 3032 sharedView(): ReadView; 33+ sharedOverlay?(atoms: readonly AtomId[]): ReadView; 34+ sharedAgentOverlay?(agent: AgentState, atoms: readonly AtomId[]): ReadView; 3135 queued(): readonly QueuedPublish[]; 3337 checkingHas(id: number): boolean; Lines 53–59 at 318 (were 49–54 at 157)
5054 collisions: Collision[], 5257 ): { ok: false; collisions: Collision[] }; 5358 currentChange(agent: AgentState, time: number): number | undefined; Lines 121–133 at 318 (were 116–126 at 157)
116121 const ahead = queuedAtoms(host, agent.name); 117122 const now = host.setOf(space); 118123 if (ahead.size > 0) { 119− const landed = new Set([...now, ...ahead]);
120− const theirsView = host.view(landed);
121− const yoursView = host.view(new Set([...landed, ...host.agentSet(agent)]));
124+ const landed = unionOverlay(now, ahead); 125+ const theirsView = host.sharedOverlay ? host.sharedOverlay([...ahead]) : host.view(landed); 126+ const yoursView = host.sharedAgentOverlay 127+ ? host.sharedAgentOverlay(agent, [...ahead]) 128+ : host.view(unionOverlay(landed, host.agentSet(agent))); 122129 const queuedBy = (id: AtomId) => host.queued().find((q) => q.changes.includes(id)); 123− const collisions: Collision[] = host.pairs(changes, ahead, new Set([...landed, ...changes])).map((p) => {
130+ const collisions: Collision[] = host.pairs(changes, ahead, unionOverlay(landed, changes)).map((p) => { 124131 const c = host.describe(p, host.agentView(agent), theirsView, agent.space); 125132 const q = queuedBy(p.theirs); 126133 return q ? { ...c, theirs: { ...c.theirs, agent: q.agent, message: q.message, queued: q.id } } : c; Lines 156–179 at 318 (were 149–167 at 157)
152− if (collisions.length > 0) return host.refuse(agent, space, "publish", time, collisions, entries);
159+ if (collisions.length > 0) return host.refuse(agent, space, "publish", time, collisions, entries, message); 154161 const view = host.agentView(agent); 162+ const auto = autoSettledOf(message); 155163 const settled: Settled[] = agent.marked 156164 .filter((r) => r.space === SHARED) 158166 const lines = view.hasFile(r.file) ? view.lines(r.file).map((l) => l.text) : []; 159167 const lost = lostLines(lines, r); 168+ const held = heldMessage(agent, r.file); 169+ const by = auto.get(r.file); 162172 kept: keptOf(lines, r), 163173 theirs: { agent: r.agent, version: r.version }, 164174 ...(lost.length > 0 ? { lost } : {}), 175+ ...(held ? { held } : {}), 176+ ...(by ? { auto: by } : {}), 167179 const id = host.queuedId() + 1; Lines 240–252 at 318 (were 228–234 at 157)
230242 const items = host.queued().slice(0, Math.max(0, n)); 231− const view = host.view(new Set([...host.setOf(host.shared()), ...items.flatMap((q) => q.changes)]));
243+ const changes = items.flatMap((q) => q.changes); 245+ changes.length === 0 247+ : host.sharedOverlay 248+ ? host.sharedOverlay(changes) 249+ : host.view(unionOverlay(host.setOf(host.shared()), changes)); 232250 const files = view.files(); 233251 const modes = modesOf(view); 234252 const blobs = view.blobs(); Lines 265–273 at 318 (were 247–254 at 157)
247265 for (const q of host.queued().slice(0, Math.max(0, n))) { 248266 const agent = host.agentOf(q.agent); 249267 const space = host.shared(); 250− const union = new Set([...host.setOf(space), ...q.changes]);
251− const tie = buildAtom(host.view(union), {
268+ const union = unionOverlay(host.setOf(space), q.changes); 269+ const view = host.sharedOverlay ? host.sharedOverlay(q.changes) : host.view(union); 270+ const tie = buildAtom(view, { 253272 message: q.message,