@devries-cameron20 / t3code Mirror · read-only / commits / bc6621d73a
Fork 0

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, 06:00 UTC

fix(server): Windows backend refuses projects on a WSL share (#39068)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

James C committed Nov 19, 2026 at 11:40 UTC bc6621d73ade6ad8be7547745299e840d2237eda
4 files changed +85
apps/server/src/project/ProjectService.test.ts
+48
@@ -6,6 +6,7 @@ import { assert, it } from "@effect/vitest";
6 import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
7 import * as NodeServices from "@effect/platform-node/NodeServices";
8 import { CommandId, type Project, ProjectId, ProviderInstanceId } from "@t3tools/contracts";
9 +import * as HostProcess from "@t3tools/shared/HostProcess";
10 import * as Deferred from "effect/Deferred";
11 import * as Effect from "effect/Effect";
12 import * as Fiber from "effect/Fiber";
@@ -512,6 +513,53 @@ it.layer(layerTest)("ProjectService", (it) => {
513 }),
514 );
515
516 + it.effect("refuses a WSL share path on Windows and allows it elsewhere", () =>
517 + Effect.gen(function* () {
518 + const service = yield* ProjectService.ProjectService;
519 + const onWindows = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
520 + effect.pipe(Effect.provideService(HostProcess.Platform, "win32"));
521 + const projectId = ProjectId.make("project:wsl-share");
522 + const refused = yield* onWindows(
523 + service.create({
524 + commandId: CommandId.make("command:wsl-share"),
525 + projectId,
526 + title: "WSL",
527 + workspaceRoot: "\\\\wsl$\\Ubuntu\\home\\ubuntu\\repo",
528 + }),
529 + ).pipe(Effect.flip);
530 + assert.equal(refused._tag, "ProjectInvalidError");
531 + assert.isTrue(Option.isNone(yield* service.getById(projectId)));
532 +
533 + const mover = ProjectId.make("project:wsl-share:mover");
534 + yield* onWindows(
535 + service.create({
536 + commandId: CommandId.make("command:wsl-share:mover"),
537 + projectId: mover,
538 + title: "Mover",
539 + workspaceRoot: "C:\\work\\wsl-share-mover",
540 + }),
541 + );
542 + const move = yield* onWindows(
543 + service.update({
544 + commandId: CommandId.make("command:wsl-share:move"),
545 + projectId: mover,
546 + workspaceRoot: "\\\\wsl.localhost\\Ubuntu\\home\\ubuntu\\repo",
547 + }),
548 + ).pipe(Effect.flip);
549 + assert.equal(move._tag, "ProjectInvalidError");
550 +
551 + const linux = yield* service
552 + .create({
553 + commandId: CommandId.make("command:wsl-share:linux"),
554 + projectId: ProjectId.make("project:wsl-share:linux"),
555 + title: "Linux",
556 + workspaceRoot: "\\\\wsl.localhost\\Ubuntu\\home\\ubuntu\\repo",
557 + })
558 + .pipe(Effect.provideService(HostProcess.Platform, "linux"));
559 + assert.equal(linux.title, "Linux");
560 + }),
561 + );
562 +
563 it.effect("replays a workspace conflict after the workspace frees up", () =>
564 Effect.gen(function* () {
565 const service = yield* ProjectService.ProjectService;
apps/server/src/project/ProjectService.ts
+19
@@ -8,7 +8,9 @@ import {
8 type ProjectSnapshot,
9 type ThreadId,
10 } from "@t3tools/contracts";
11 +import * as HostProcess from "@t3tools/shared/HostProcess";
12 import * as KeyedLock from "@t3tools/shared/KeyedLock";
13 +import { isWslSharePath } from "@t3tools/shared/path";
14 import * as Context from "effect/Context";
15 import * as DateTime from "effect/DateTime";
16 import * as Effect from "effect/Effect";
@@ -261,6 +263,19 @@ export const make = Effect.gen(function* () {
263 });
264 });
265
266 + // Git for Windows can't trust an index written inside the distro and rereads every file across the
267 + // share, so git status can hit its timeout. Checked before normalizing, which already stats the share.
268 + const rejectWslSharePath = Effect.fn("ProjectService.rejectWslSharePath")(function* (
269 + projectId: ProjectId,
270 + workspaceRoot: string,
271 + ) {
272 + if (!isWslSharePath(workspaceRoot) || !(yield* HostProcess.isWindows)) return;
273 + return yield* new ProjectInvalidError({
274 + projectId,
275 + detail: `${workspaceRoot.trim()} is inside WSL. Add it to the WSL backend instead of the Windows one.`,
276 + });
277 + });
278 +
279 const commit = Effect.fn("ProjectService.commit")(function* (command: ProjectCommand) {
280 const { projectId } = command;
281 const dispatchError = (cause: unknown) =>
@@ -395,6 +410,7 @@ export const make = Effect.gen(function* () {
410
411 const create: ProjectService["Service"]["create"] = Effect.fn("ProjectService.create")(
412 function* (input) {
413 + yield* rejectWslSharePath(input.projectId, input.workspaceRoot);
414 const workspaceRoot = yield* normalizeWorkspaceRoot({
415 projectId: input.projectId,
416 workspaceRoot: input.workspaceRoot,
@@ -421,6 +437,9 @@ export const make = Effect.gen(function* () {
437 return yield* new ProjectNotFoundError({ projectId: input.projectId });
438 }
439 const previousRoot = existing.value.workspaceRoot;
440 + if (input.workspaceRoot !== undefined && input.workspaceRoot !== previousRoot) {
441 + yield* rejectWslSharePath(input.projectId, input.workspaceRoot);
442 + }
443 const workspaceRoot =
444 input.workspaceRoot === undefined
445 ? previousRoot
packages/shared/src/path.test.ts
+13
@@ -1,5 +1,6 @@
1 import { describe, expect, it } from "vite-plus/test";
2 import {
3 + isWslSharePath,
4 workspaceRelativeFilePath,
5 newProjectFolderName,
6 normalizeProjectPathForComparison,
@@ -9,6 +10,18 @@ import {
10 } from "./path.ts";
11
12 describe("path helpers", () => {
13 + it("recognizes WSL shares and nothing else", () => {
14 + expect(isWslSharePath("\\\\wsl.localhost\\Ubuntu\\home")).toBe(true);
15 + expect(isWslSharePath("\\\\wsl$\\Ubuntu")).toBe(true);
16 + expect(isWslSharePath(" //WSL.LOCALHOST/Ubuntu/home")).toBe(true);
17 + expect(isWslSharePath("\\\\?\\UNC\\wsl.localhost\\Ubuntu\\repo")).toBe(true);
18 + expect(isWslSharePath("\\\\.\\UNC\\wsl$\\Ubuntu\\repo")).toBe(true);
19 + expect(isWslSharePath("\\\\?\\C:\\work\\repo")).toBe(false);
20 + expect(isWslSharePath("\\\\wslserver\\share")).toBe(false);
21 + expect(isWslSharePath("\\\\fileserver\\wsl.localhost")).toBe(false);
22 + expect(isWslSharePath("C:\\work\\repo")).toBe(false);
23 + });
24 +
25 // regression: #17923 literal colons in names are kept, not parsed as positions
26 it.each([
27 ["report:123", "/workspace", "/workspace/report:123"],
packages/shared/src/path.ts
+5
@@ -15,6 +15,11 @@ export function isNetworkPath(value: string): boolean {
15 return /^[\\/]{2}/.test(value);
16 }
17
18 +/** A `\\wsl.localhost\<distro>` or `\\wsl$\<distro>` share: a WSL distro's files seen from Windows over 9P. */
19 +export function isWslSharePath(value: string): boolean {
20 + return /^[\\/]{2}(?:[?.][\\/]UNC[\\/])?wsl(?:\.localhost|\$)[\\/]/i.test(value.trim());
21 +}
22 +
23 export function isWindowsAbsolutePath(value: string): boolean {
24 return isUncPath(value) || isWindowsDrivePath(value);
25 }