@cueloop/daemon 0.1.0-alpha.92 → 0.1.0-alpha.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cueloop/daemon",
3
- "version": "0.1.0-alpha.92",
3
+ "version": "0.1.0-alpha.93",
4
4
  "description": "The cueloop session daemon and its client: socket protocol, atomic store, resumable waits",
5
5
  "homepage": "https://github.com/mmurakaru/cueloop#readme",
6
6
  "bugs": {
@@ -39,8 +39,8 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@cueloop/extension-api": "0.1.0-alpha.92",
43
- "@cueloop/schema": "0.1.0-alpha.92",
42
+ "@cueloop/extension-api": "0.1.0-alpha.93",
43
+ "@cueloop/schema": "0.1.0-alpha.93",
44
44
  "@pierre/diffs": "^1.4.1",
45
45
  "effect": "^4.0.0-rc.116",
46
46
  "smol-toml": "^1.8.0",
@@ -163,6 +163,9 @@ export class DiffWatcher {
163
163
  if (isRefChange(filename)) this.scheduleRepoRefresh(repoRoot);
164
164
  });
165
165
  }
166
+
167
+ // Reconcile changes made while the platform activates its new watch.
168
+ this.scheduleRepoRefresh(repoRoot);
166
169
  }
167
170
 
168
171
  private startJjPoll(repoWatch: RepoWatch, repoRoot: string, sessionId: string): void {
@@ -41,6 +41,16 @@ describe("listProjectFiles", () => {
41
41
  expect(files).toEqual(["a.ts", "m.ts", "z.ts"]);
42
42
  });
43
43
 
44
+ test("omits a tracked file deleted from the working tree", async () => {
45
+ writeFileSync(join(repo, "keep.ts"), "export const keep = true;\n");
46
+ writeFileSync(join(repo, "gone.ts"), "export const gone = true;\n");
47
+ git(["add", "."], repo);
48
+ git(["commit", "-qm", "init"], repo);
49
+ rmSync(join(repo, "gone.ts"));
50
+
51
+ expect(await listProjectFiles(repo)).toEqual(["keep.ts"]);
52
+ });
53
+
44
54
  test("returns [] for a directory that is not a git repo", async () => {
45
55
  // Given a plain directory with a file but no git repo
46
56
  const plain = mkdtempSync(join(tmpdir(), "cueloop-project-files-plain-"));
@@ -8,20 +8,32 @@ const MAX_FILES = 5000;
8
8
  /** Ceiling on a served file; the panel renders source, not multi-megabyte blobs. */
9
9
  const MAX_FILE_BYTES = 1024 * 1024;
10
10
 
11
- /** Tracked, repo-relative paths from `git ls-files`, sorted ascending and capped; [] on any failure or non-repo. */
11
+ async function gitFileList(repoRoot: string, args: string[]): Promise<string[] | null> {
12
+ const gitProcess = Bun.spawn(["git", "-C", repoRoot, "ls-files", "-z", ...args], {
13
+ stdout: "pipe",
14
+ stderr: "ignore",
15
+ });
16
+ const stdout = await new Response(gitProcess.stdout).text();
17
+
18
+ return (await gitProcess.exited) === 0 ? stdout.split("\0").filter(Boolean) : null;
19
+ }
20
+
21
+ /** Existing tracked paths, sorted ascending and capped; [] on failure or a non-repo. */
12
22
  export async function listProjectFiles(repoRoot: string | undefined): Promise<string[]> {
13
23
  if (repoRoot === undefined || repoRoot.length === 0) return [];
14
24
  try {
15
- const gitProcess = Bun.spawn(["git", "-C", repoRoot, "ls-files", "-z"], {
16
- stdout: "pipe",
17
- stderr: "ignore",
18
- });
19
- const stdout = await new Response(gitProcess.stdout).text();
25
+ const [tracked, deleted] = await Promise.all([
26
+ gitFileList(repoRoot, ["--cached"]),
27
+ gitFileList(repoRoot, ["--deleted"]),
28
+ ]);
20
29
 
21
- if ((await gitProcess.exited) !== 0) return [];
22
- const paths = stdout.split("\0").filter((path) => path.length > 0);
30
+ if (tracked === null || deleted === null) return [];
31
+ const missing = new Set(deleted);
23
32
 
24
- return paths.toSorted().slice(0, MAX_FILES);
33
+ return tracked
34
+ .filter((path) => !missing.has(path))
35
+ .toSorted()
36
+ .slice(0, MAX_FILES);
25
37
  } catch {
26
38
  return [];
27
39
  }