{"draft":null,"from":161,"to":318,"files":[{"path":"worker/project/sync.ts","added":7,"removed":3,"diff":"--- a/worker/project/sync.ts\n+++ b/worker/project/sync.ts\n@@ -3,7 +3,6 @@\n // SyncHost; today the host is Project.\n \n import type { AtomId, Graph, ReadView } from \"../../src/engine/index.ts\";\n-import { outlastsSync } from \"./news.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@@ -15,6 +14,7 @@\n \tagent(name: string, entries: Entry[]): AgentState;\n \tspaceOf(agent: AgentState): Space;\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@@ -51,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@@ -80,14 +81,17 @@\n \tentries.push({ type: \"sync\", agent: agent.name, version: target });\n \thost.apply(entries[entries.length - 1]!);\n \t// News about versions the agent has now synced past is moot: the sync answer lists what's still open (#37).\n-\tif (agent.news.some((t) => !outlastsSync(t))) {\n+\tif (agent.news.some((t) => !t.startsWith(\"Announcement from \"))) {\n \t\tconst heard: Entry = { type: \"heard\", agent: agent.name, stale: true };\n \t\tentries.push(heard);\n \t\thost.apply(heard);\n \t}\n \tconst merged = host.mergeIdentical(agent, before, oldBase, oldVersion, Date.now(), entries);\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(agent, options.full ? new View(host.graph, []) : before);\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":[]}