The best way to control Claude Code, Codex and more from any computer or phone
fix(server): No project behind a symlinked scratch folder stays No project (#34487)
Julius Marminge committed
Nov 11, 2026 at 15:54 UTC
50952becccb0226dbd91f913f81f416cb6472f60
3 files changed
+52
-4
apps/server/src/project/ManagedProjectFolders.test.ts
+25
@@ -307,6 +307,31 @@ it.effect("leaves threads in other projects alone", () =>
307
),
308
);
309
310
+it.effect("still knows No project when its folder is the target of a symlinked Scratch", () =>
311
+ withScratch(({ baseDir }) =>
312
+ Effect.gen(function* () {
313
+ const scratch = yield* ManagedProjectFolders.ManagedProjectFolders;
314
+ const projects = yield* ProjectService.ProjectService;
315
+ const fileSystem = yield* FileSystem.FileSystem;
316
+ const path = yield* Path.Path;
317
+ const root = yield* requireRoot;
318
+ const target = path.join(baseDir, "visible-chats");
319
+ yield* fileSystem.makeDirectory(target);
320
+ yield* fileSystem.symlink(target, root);
321
+ const { projectId } = yield* scratch.ensureScratchProject;
322
+ yield* projects.update({
323
+ commandId: CommandId.make("command:point-at-target"),
324
+ projectId,
325
+ workspaceRoot: target,
326
+ });
327
+
328
+ assert.isTrue(yield* scratch.isScratchProject(projectId));
329
+ assert.equal((yield* scratch.ensureScratchProject).projectId, projectId);
330
+ assert.deepStrictEqual(yield* scratch.scratchRoot, Option.some(target));
331
+ }),
332
+ ),
333
+);
334
+
335
const GIT_IDENTITY_KEYS = [
336
"GIT_AUTHOR_NAME",
337
"GIT_AUTHOR_EMAIL",
apps/server/src/project/ManagedProjectFolders.ts
+22
-3
@@ -273,7 +273,25 @@ const make = Effect.gen(function* () {
273
Duration.infinity,
274
);
275
const scratchProbe = probe.pipe(Effect.onInterrupt(() => invalidate));
276
- const scratchRoot = scratchProbe.pipe(Effect.map(Result.getSuccess));
276
+ // A symlinked scratch folder lets the No project live at either the link or its target.
277
+ const scratchProjectRoot = (root: string) =>
278
+ fileSystem.realPath(root).pipe(
279
+ Effect.flatMap((target) =>
280
+ target === root
281
+ ? Effect.succeed(root)
282
+ : projects
283
+ .getByWorkspaceRoot(target)
284
+ .pipe(Effect.map((project) => (Option.isSome(project) ? target : root))),
285
+ ),
286
+ Effect.orElseSucceed(() => root),
287
+ );
288
+ const scratchRoot = scratchProbe.pipe(
289
+ Effect.flatMap((probed) =>
290
+ Result.isSuccess(probed)
291
+ ? scratchProjectRoot(probed.success).pipe(Effect.asSome)
292
+ : Effect.succeedNone,
293
+ ),
294
+ );
295
296
const makeScratchFolder = (folder: string) =>
297
fileSystem
@@ -282,8 +300,9 @@ const make = Effect.gen(function* () {
300
301
const ensureScratchProject: ManagedProjectFolders["Service"]["ensureScratchProject"] = Effect.gen(
302
function* () {
285
- const workspaceRoot = yield* scratchProbe.pipe(Effect.flatMap(Effect.fromResult));
286
- yield* makeScratchFolder(workspaceRoot);
303
+ const probedRoot = yield* scratchProbe.pipe(Effect.flatMap(Effect.fromResult));
304
+ yield* makeScratchFolder(probedRoot);
305
+ const workspaceRoot = yield* scratchProjectRoot(probedRoot);
306
const id = yield* random
307
.uuidV4()
308
.pipe(Effect.mapError((cause) => new ScratchProjectError({ workspaceRoot, cause })));
apps/server/src/project/ScratchThreadPromotion.ts
+5
-1
@@ -7,6 +7,7 @@ import {
7
import * as Context from "effect/Context";
8
import * as SecureRandom from "effect/crypto/SecureRandom";
9
import * as Effect from "effect/Effect";
10
+import * as FileSystem from "effect/FileSystem";
11
import * as Layer from "effect/Layer";
12
import * as Option from "effect/Option";
13
import * as Path from "effect/Path";
@@ -50,6 +51,9 @@ const make = Effect.gen(function* () {
51
const scheduledTasks = yield* ScheduledTaskService.ScheduledTaskService;
52
const random = yield* SecureRandom.SecureRandom;
53
const path = yield* Path.Path;
54
+ const fileSystem = yield* FileSystem.FileSystem;
55
+ const realPath = (folder: string) =>
56
+ fileSystem.realPath(folder).pipe(Effect.orElseSucceed(() => folder));
57
58
const fail = (reason: string) => (cause: unknown) =>
59
new ScratchThreadPromotionError({ reason, cause });
@@ -76,7 +80,7 @@ const make = Effect.gen(function* () {
80
if (
81
folder === undefined ||
82
scratchRoot === undefined ||
79
- path.dirname(folder) !== scratchRoot ||
83
+ (yield* realPath(path.dirname(folder))) !== (yield* realPath(scratchRoot)) ||
84
!(isScratch || alreadyPromoted)
85
) {
86
return yield* new ScratchThreadPromotionError({