The best way to control Claude Code, Codex and more from any computer or phone
fix(cli): t3 project remove finds a deleted project by a relative or trailing-slash path (#30562)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
MarcoDotIO committed
Nov 5, 2026 at 23:32 UTC
31096388aa48523db6fb8e6f31bf318cede889a5
2 files changed
+27
-21
apps/server/src/cli/project.test.ts
+20
-17
@@ -389,23 +389,26 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))(
389
it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))(
390
"project lookup with unavailable workspaces",
391
(it) => {
392
- it.effect.each(["id", "stored path"] as const)(
393
- "removes an empty project by %s after its directory is gone",
394
- (identifier) =>
395
- Effect.gen(function* () {
396
- const fs = yield* FileSystem.FileSystem;
397
- const { baseDir, workspaceRoot, project } = yield* makeProjectLookupFixture();
398
- yield* fs.rename(workspaceRoot, `${workspaceRoot}-removed`);
399
- yield* runCli([
400
- "project",
401
- "remove",
402
- identifier === "id" ? project.id : workspaceRoot,
403
- "--base-dir",
404
- baseDir,
405
- ]);
406
- assert.deepEqual((yield* readProjects(baseDir)).projects, []);
407
- assert.isFalse(yield* fs.exists(workspaceRoot));
408
- }),
392
+ it.effect.each([
393
+ "id",
394
+ "stored path",
395
+ "relative path",
396
+ "path with a trailing separator",
397
+ ] as const)("removes an empty project by %s after its directory is gone", (identifier) =>
398
+ Effect.gen(function* () {
399
+ const fs = yield* FileSystem.FileSystem;
400
+ const { baseDir, workspaceRoot, project } = yield* makeProjectLookupFixture();
401
+ yield* fs.rename(workspaceRoot, `${workspaceRoot}-removed`);
402
+ const target = {
403
+ id: project.id,
404
+ "stored path": workspaceRoot,
405
+ "relative path": NodePath.relative(process.cwd(), workspaceRoot),
406
+ "path with a trailing separator": `${workspaceRoot}${NodePath.sep}`,
407
+ }[identifier];
408
+ yield* runCli(["project", "remove", target, "--base-dir", baseDir]);
409
+ assert.deepEqual((yield* readProjects(baseDir)).projects, []);
410
+ assert.isFalse(yield* fs.exists(workspaceRoot));
411
+ }),
412
);
413
414
it.effect("does not resolve another environment's project ID in an empty database", () =>
apps/server/src/cli/project.ts
+7
-4
@@ -292,12 +292,15 @@ const findActiveProjectTarget = Effect.fn("findActiveProjectTarget")(function* (
292
const normalizedWorkspaceRootResult = yield* Effect.result(
293
normalizeWorkspaceRootForProjectCommand(trimmedIdentifier),
294
);
295
+ // A stored workspace path still identifies its project after the directory is gone, so a
296
+ // relative or trailing-slash path resolves the same way it would while the directory exists.
297
const normalizedWorkspaceRoot =
296
- normalizedWorkspaceRootResult._tag === "Success" ? normalizedWorkspaceRootResult.success : null;
298
+ normalizedWorkspaceRootResult._tag === "Success"
299
+ ? normalizedWorkspaceRootResult.success
300
+ : normalizedWorkspaceRootResult.failure.normalizedWorkspaceRoot;
301
298
- // A stored workspace path still identifies its project after the directory is gone.
302
const exactWorkspaceMatch = activeProjects.find(
300
- (project) => project.workspaceRoot === (normalizedWorkspaceRoot ?? trimmedIdentifier),
303
+ (project) => project.workspaceRoot === normalizedWorkspaceRoot,
304
);
305
306
const resolved = exactWorkspaceMatch;
@@ -306,7 +309,7 @@ const findActiveProjectTarget = Effect.fn("findActiveProjectTarget")(function* (
309
operation: "resolveProjectTarget",
310
identifier: trimmedIdentifier,
311
activeProjectCount: activeProjects.length,
309
- ...(normalizedWorkspaceRoot === null ? {} : { normalizedWorkspaceRoot }),
312
+ normalizedWorkspaceRoot,
313
...(normalizedWorkspaceRootResult._tag === "Failure"
314
? { cause: normalizedWorkspaceRootResult.failure }
315
: {}),