Lines 1–7 at 318 (were 1–7 at 116)
11// The files whose text in the agent's view differs from before, and its open 22// collisions. Reads go through ChangesSinceHost; today the host is Project. 4−import type { AtomId, View } from "../../src/engine/index.ts";
4+import type { AtomId, ReadView } from "../../src/engine/index.ts"; 55import type { Pair } from "./collisions.ts"; 66import { sortKeys } from "./project-helpers.ts"; 77import type { AgentState, Blobs, Collision, Files, Modes, SyncAnswer } from "./project-types.ts"; Lines 9–16 at 318 (were 9–16 at 116)
1010/** What a changes-since read needs from a project. */ 1111export interface ChangesSinceHost { 12− agentView(agent: AgentState): View;
13− touchedFiles(ids: Iterable<AtomId>, views: readonly View[]): Set<string>;
12+ agentView(agent: AgentState): ReadView; 13+ touchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>; 1414 openPairs(agent: AgentState): Pair[]; 1515 collision(agent: AgentState, pair: Pair): Collision; 1616 duplicates(agent: AgentState): Collision[]; Lines 18–24 at 318 (were 18–24 at 116)
2020/** The files whose text in the agent's view differs from `before`, and its open collisions. */ 21−export function changesSince(host: ChangesSinceHost, agent: AgentState, before: View): SyncAnswer {
21+export function changesSince(host: ChangesSinceHost, agent: AgentState, before: ReadView): SyncAnswer { 2222 const after = host.agentView(agent); 2323 // Only files that an atom in one view but not the other touches can differ. 2424 const touched = new Set<string>(); Lines 26–35 at 318 (were 26–36 at 116)
2626 [before.set, after.set], 2727 [after.set, before.set], 29− for (const file of host.touchedFiles(
30− [...a].filter((id) => !b.has(id)),
31− [before, after],
32− ))
33− touched.add(file);
29+ const changed = function* () { 30+ for (const id of a) if (!b.has(id)) yield id; 32+ for (const file of host.touchedFiles(changed(), [before, after])) touched.add(file); 3534 const files: Files = {}; 3635 const modes: Modes = {};