@devries-cameron20 / t3code-1 / commits / 1fed70cd19
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): say why threads without a project are unavailable (#32342)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 10, 2026 at 10:00 UTC 1fed70cd19998cee7907f6fde3b4d4290ba99cfc
3 files changed +53 -25
apps/server/src/git/GitWorkflowService.ts
+4 -4
@@ -37,7 +37,7 @@ import { withWorkspaceLease } from "../workspace/workspaceLease.ts";
37 export class GitWorkflowService extends Context.Service<
38 GitWorkflowService,
39 {
40 - readonly isRepository: (cwd: string) => Effect.Effect<boolean, GitManagerServiceError>;
40 + readonly repositoryRoot: (cwd: string) => Effect.Effect<string | null, GitManagerServiceError>;
41 readonly hasCommit: (input: {
42 readonly cwd: string;
43 readonly refName: string;
@@ -271,13 +271,13 @@ export const make = Effect.gen(function* () {
271 ensureGit(operation, input.cwd).pipe(Effect.andThen(run(input)));
272
273 return GitWorkflowService.of({
274 - isRepository: Effect.fn("GitWorkflowService.isRepository")(function (cwd) {
274 + repositoryRoot: Effect.fn("GitWorkflowService.repositoryRoot")(function (cwd) {
275 return registry.detect({ cwd }).pipe(
276 - Effect.map((handle) => handle?.kind === "git"),
276 + Effect.map((handle) => (handle?.kind === "git" ? handle.repository.rootPath : null)),
277 Effect.mapError(
278 (cause) =>
279 new GitManagerError({
280 - operation: "GitWorkflowService.isRepository",
280 + operation: "GitWorkflowService.repositoryRoot",
281 cwd,
282 detail: "Failed to detect a VCS repository for this Git workflow.",
283 cause,
apps/server/src/project/ManagedProjectFolders.test.ts
+21 -5
@@ -8,6 +8,7 @@ import * as Effect from "effect/Effect";
8 import * as Fiber from "effect/Fiber";
9 import * as FileSystem from "effect/FileSystem";
10 import * as Layer from "effect/Layer";
11 +import * as Logger from "effect/Logger";
12 import * as Option from "effect/Option";
13 import * as Path from "effect/Path";
14 import * as PlatformError from "effect/PlatformError";
@@ -111,23 +112,38 @@ const requireRoot = Effect.gen(function* () {
112 return Option.getOrThrow(yield* scratch.scratchRoot);
113 });
114
114 -it.effect("offers nothing when the data dir sits inside a Git checkout", () =>
115 - Effect.gen(function* () {
115 +it.effect("offers nothing, and says why once, when the data dir sits inside a Git checkout", () => {
116 + const warnings: string[] = [];
117 + const logger = Logger.make(({ logLevel, message }) => {
118 + if (logLevel === "Warn") warnings.push(String(message));
119 + });
120 + return Effect.gen(function* () {
121 const fileSystem = yield* FileSystem.FileSystem;
122 const path = yield* Path.Path;
123 const checkout = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-scratch-repo-" });
124 yield* git(checkout, ["init", "--quiet"]);
125 const baseDir = path.join(checkout, ".t3");
126 yield* fileSystem.makeDirectory(baseDir);
127 + const repositoryRoot = (yield* git(baseDir, ["rev-parse", "--show-toplevel"])).stdout.trim();
128 yield* Effect.gen(function* () {
129 const scratch = yield* ManagedProjectFolders.ManagedProjectFolders;
130 assert.isTrue(Option.isNone(yield* scratch.scratchRoot));
131 assert.isFalse(yield* scratch.isScratchProject(ProjectId.make("project:any")));
132 const failure = yield* Effect.flip(scratch.ensureScratchProject);
133 assert.equal(failure._tag, "ScratchUnavailableError");
128 - }).pipe(Effect.provide(layer(baseDir)));
129 - }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
130 -);
134 + assert.include(failure.message, baseDir);
135 + // The root prefixes the data dir, so it must appear on its own.
136 + assert.include(failure.message.replaceAll(baseDir, ""), repositoryRoot);
137 + yield* Effect.flip(scratch.ensureScratchProject);
138 + }).pipe(
139 + Effect.provide(
140 + Layer.mergeAll(layer(baseDir), Logger.layer([logger], { mergeWithExisting: false })),
141 + ),
142 + );
143 + assert.equal(warnings.length, 1);
144 + assert.include(warnings[0], baseDir);
145 + }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)));
146 +});
147
148 it.effect("offers a Scratch folder when Git is not installed", () =>
149 withScratch(
apps/server/src/project/ManagedProjectFolders.ts
+28 -16
@@ -18,6 +18,7 @@ import * as Layer from "effect/Layer";
18 import * as Option from "effect/Option";
19 import * as Path from "effect/Path";
20 import * as PlatformError from "effect/PlatformError";
21 +import * as Result from "effect/Result";
22 import * as Schema from "effect/Schema";
23
24 import * as ServerConfig from "../config.ts";
@@ -27,10 +28,16 @@ import * as ProjectService from "./ProjectService.ts";
28
29 export class ScratchUnavailableError extends Schema.TaggedError<ScratchUnavailableError>()(
30 "ScratchUnavailableError",
30 - {},
31 + {
32 + baseDir: Schema.String,
33 + repositoryRoot: Schema.optional(Schema.String),
34 + },
35 ) {
36 override get message(): string {
33 - return "Threads without a project are not available on this environment.";
37 + if (this.repositoryRoot === undefined) {
38 + return "Threads without a project are not available on this environment.";
39 + }
40 + return `Threads without a project are off because the T3 home ${this.baseDir} is inside the Git repository ${this.repositoryRoot}. If that repository was created by mistake, move ${this.repositoryRoot}/.git out of the way; otherwise point T3CODE_HOME (or --base-dir) at a folder outside it. Then restart T3 Code.`;
41 }
42 }
43
@@ -232,18 +239,30 @@ const make = Effect.gen(function* () {
239
240 // Scratch inside a checkout would inherit its git status and checkpoints; require a data dir outside work trees.
241 const [probe, invalidate] = yield* Effect.cachedInvalidateWithTTL(
235 - gitWorkflow.isRepository(config.baseDir).pipe(
236 - Effect.catchIf(isGitMissing, () => Effect.succeed(false)),
237 - Effect.map((isRepository) =>
238 - isRepository ? Option.none<string>() : Option.some(path.resolve(config.baseDir, "scratch")),
242 + gitWorkflow.repositoryRoot(config.baseDir).pipe(
243 + Effect.catchIf(isGitMissing, () => Effect.succeed(null)),
244 + Effect.flatMap(
245 + (repositoryRoot): Effect.Effect<Result.Result<string, ScratchUnavailableError>> => {
246 + if (repositoryRoot === null) {
247 + return Effect.succeed(Result.succeed(path.resolve(config.baseDir, "scratch")));
248 + }
249 + const unavailable = new ScratchUnavailableError({
250 + baseDir: config.baseDir,
251 + repositoryRoot,
252 + });
253 + return Effect.logWarning(unavailable.message).pipe(Effect.as(Result.fail(unavailable)));
254 + },
255 ),
256 Effect.catchCause((cause) =>
241 - Cause.hasInterrupts(cause) ? Effect.interrupt : Effect.succeed(Option.none<string>()),
257 + Cause.hasInterrupts(cause)
258 + ? Effect.interrupt
259 + : Effect.succeed(Result.fail(new ScratchUnavailableError({ baseDir: config.baseDir }))),
260 ),
261 ),
262 Duration.infinity,
263 );
246 - const scratchRoot = probe.pipe(Effect.onInterrupt(() => invalidate));
264 + const scratchProbe = probe.pipe(Effect.onInterrupt(() => invalidate));
265 + const scratchRoot = scratchProbe.pipe(Effect.map(Result.getSuccess));
266
267 const makeScratchFolder = (folder: string) =>
268 fileSystem
@@ -252,14 +271,7 @@ const make = Effect.gen(function* () {
271
272 const ensureScratchProject: ManagedProjectFolders["Service"]["ensureScratchProject"] = Effect.gen(
273 function* () {
255 - const workspaceRoot = yield* scratchRoot.pipe(
256 - Effect.flatMap(
257 - Option.match({
258 - onNone: () => Effect.fail(new ScratchUnavailableError()),
259 - onSome: Effect.succeed,
260 - }),
261 - ),
262 - );
274 + const workspaceRoot = yield* scratchProbe.pipe(Effect.flatMap(Effect.fromResult));
275 yield* makeScratchFolder(workspaceRoot);
276 const id = yield* random
277 .uuidV4()