{"draft":null,"from":3,"to":318,"files":[{"path":"worker/project/sync.ts","added":17,"removed":11,"diff":"--- a/worker/project/sync.ts\n+++ b/worker/project/sync.ts\n@@ -1,7 +1,8 @@\n+import { View } from \"../../src/engine/index.ts\";\n // Move the agent's base to its space's newest version. Writes go through\n // SyncHost; today the host is Project.\n \n-import { type AtomId, type Graph, View } from \"../../src/engine/index.ts\";\n+import type { AtomId, Graph, ReadView } from \"../../src/engine/index.ts\";\n import { ProjectError } from \"./project-error.ts\";\n import type { AgentState, Entry, MergedLine, SyncAnswer } from \"./project-types.ts\";\n import { last, SHARED, type Space } from \"./spaces.ts\";\n@@ -12,7 +13,8 @@\n \treadonly labels: ReadonlyMap<string, readonly number[]>;\n \tagent(name: string, entries: Entry[]): AgentState;\n \tspaceOf(agent: AgentState): Space;\n-\tagentView(agent: AgentState): View;\n+\tagentView(agent: AgentState): ReadView;\n+\tcaptureAgentView?(agent: AgentState): () => ReadView;\n \tat(space: Space, version: number): ReadonlySet<AtomId>;\n \tdraft(agent: AgentState): AtomId[];\n \tstrandedFiles(draft: readonly AtomId[], set: ReadonlySet<AtomId>): string[];\n@@ -20,13 +22,13 @@\n \tflush(entries: Entry[]): void;\n \tmergeIdentical(\n \t\tagent: AgentState,\n-\t\tbefore: View,\n+\t\tbefore: ReadView,\n \t\toldBase: ReadonlySet<AtomId>,\n \t\toldVersion: number,\n \t\ttime: number,\n \t\tentries: Entry[],\n \t): MergedLine[];\n-\tchangesSince(agent: AgentState, before: View): SyncAnswer;\n+\tchangesSince(agent: AgentState, before: ReadView): SyncAnswer;\n }\n \n /**\n@@ -49,6 +51,7 @@\n \t\t\tthrow new ProjectError(\"bad-request\", `no version of shared has the label ${JSON.stringify(options.label)}`);\n \t\ttarget = versions[versions.length - 1]!;\n \t}\n+\tconst reopenBefore = agent.synced ? host.captureAgentView?.(agent) : undefined;\n \tconst before = agent.synced ? host.agentView(agent) : new View(host.graph, []);\n \tconst set = host.at(space, target);\n \tconst stranded = host.strandedFiles(host.draft(agent), set);\n@@ -57,10 +60,10 @@\n \t\tthrow new ProjectError(\n \t\t\t\"conflict\",\n \t\t\ttarget === last(space)\n-\t\t\t\t? `your unpublished changes to ${stranded.join(\", \")} build on lines a drop took out of shared; ` +\n-\t\t\t\t\t\t`restore those files (abso restore ${stranded.join(\" \")}) and sync again`\n-\t\t\t\t: `your unpublished changes to ${stranded.join(\", \")} build on lines version ${target} doesn't have yet; ` +\n-\t\t\t\t\t\t`publish or restore them before following label ${options.label}`,\n+\t\t\t\t? `your unpushed changes to ${stranded.join(\", \")} build on lines a drop took out of shared; ` +\n+\t\t\t\t\t\t`restore those files (abso restore ${stranded.join(\" \")}) and pull again`\n+\t\t\t\t: `your unpushed changes to ${stranded.join(\", \")} build on lines version ${target} doesn't have yet; ` +\n+\t\t\t\t\t\t`push or restore them before following label ${options.label}`,\n \t\t);\n \t}\n \t// Moving back to a labeled version: the agent's own newer published work must not build on what that version lacks.\n@@ -70,7 +73,7 @@\n \t\thost.flush(entries);\n \t\tthrow new ProjectError(\n \t\t\t\"conflict\",\n-\t\t\t`your published changes to ${lacking.join(\", \")} build on versions after ${target}, so you can't move back to it`,\n+\t\t\t`your pushed changes to ${lacking.join(\", \")} build on versions after ${target}, so you can't move back to it`,\n \t\t);\n \t}\n \tconst oldBase = host.at(space, agent.base);\n@@ -84,8 +87,11 @@\n \t\thost.apply(heard);\n \t}\n \tconst merged = host.mergeIdentical(agent, before, oldBase, oldVersion, Date.now(), entries);\n-\t// full (#37, Artist 1's partial join): every file in the view, as for a first sync, whatever the folder had.\n-\tconst answer = host.changesSince(agent, options.full ? new View(host.graph, []) : before);\n+\t// full (#37, a partial join): every file in the view, as for a first sync, whatever the folder had.\n+\tconst answer = host.changesSince(\n+\t\tagent,\n+\t\toptions.full ? new View(host.graph, []) : reopenBefore ? reopenBefore() : before,\n+\t);\n \thost.flush(entries);\n \treturn merged.length > 0 ? { ...answer, merged } : answer;\n }"}],"unmatched":[]}