The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 09:45 UTC
fix(server): reading t3.json from a cleaned-up worktree no longer logs an error (#37747)
Co-authored-by: Martin Bergo <14320143+mInrOz@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Martin Bergo committed
Nov 16, 2026 at 21:32 UTC
50717b8167766d0fc913cb6865cd35c5a637922b
2 files changed
+37
-1
apps/server/src/workspace/WorkspaceFileSystem.test.ts
+26
@@ -258,6 +258,32 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
258
}),
259
);
260
261
+ it.effect("reports an optional file as absent when the workspace root was removed", () =>
262
+ Effect.gen(function* () {
263
+ const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
264
+ const path = yield* Path.Path;
265
+ const cwd = path.join(yield* makeTempDir, "removed-worktree");
266
+
267
+ const result = yield* workspaceFileSystem.readFile({
268
+ cwd,
269
+ relativePath: "t3.json",
270
+ allowMissing: true,
271
+ });
272
+ expect(result).toEqual({
273
+ relativePath: "t3.json",
274
+ contents: "",
275
+ byteLength: 0,
276
+ truncated: false,
277
+ exists: false,
278
+ });
279
+
280
+ const error = yield* workspaceFileSystem
281
+ .readFile({ cwd, relativePath: "t3.json" })
282
+ .pipe(Effect.flip);
283
+ expect(error).toMatchObject({ operation: "realpath-workspace-root" });
284
+ }),
285
+ );
286
+
287
it.effect("finishes short reads before decoding UTF-8 text", () =>
288
Effect.gen(function* () {
289
const files = yield* WorkspaceFileSystem.WorkspaceFileSystem;
apps/server/src/workspace/WorkspaceFileSystem.ts
+11
-1
@@ -315,7 +315,17 @@ export const make = Effect.gen(function* () {
315
operation: "realpath-workspace-root",
316
cause,
317
}),
318
- });
318
+ }).pipe(
319
+ // Storage cleanup removes idle worktrees but keeps their path, so nothing below them exists.
320
+ Effect.catchIf(
321
+ (error) =>
322
+ input.allowMissing === true && (error.cause as NodeJS.ErrnoException).code === "ENOENT",
323
+ () => Effect.succeed(null),
324
+ ),
325
+ );
326
+ if (realWorkspaceRoot === null) {
327
+ return { relativePath: target.relativePath, realTargetPath: null };
328
+ }
329
const resolved = yield* Effect.tryPromise({
330
try: async () => {
331
let candidate = target.absolutePath;