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

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

fix(server): Git Bash drive paths load images and files on Windows (#38104)

Julius Marminge committed Nov 17, 2026 at 04:37 UTC ecb295516fb1a7a606e31778b14bf2c58dd4cc41
5 files changed +67 -8
apps/server/src/assets/AssetAccess.test.ts
+27
@@ -627,6 +627,33 @@ describe("AssetAccess", () => {
627 }).pipe(Effect.provide(layerTest)),
628 );
629
630 + // Agents on Windows copy paths from Git Bash, which prints `C:\x` as `/c/x`.
631 + it.effect.runIf(HostProcess.Platform.defaultValue() === "win32")(
632 + "resolves a Git Bash drive media path on Windows",
633 + () =>
634 + Effect.gen(function* () {
635 + const fs = yield* FileSystem.FileSystem;
636 + const path = yield* Path.Path;
637 + const workspaceRoot = yield* fs.makeTempDirectoryScoped({ prefix: "t3-media-gitbash-" });
638 + const canonicalFile = path.join(yield* fs.realPath(workspaceRoot), "shot.png");
639 + yield* fs.writeFile(canonicalFile, screenshotPng);
640 + const gitBashPath = `/${canonicalFile[0]!.toLowerCase()}${canonicalFile.slice(2).replaceAll("\\", "/")}`;
641 +
642 + for (const resource of [
643 + { _tag: "media-file", threadId: ThreadId.make("thread-1"), path: gitBashPath },
644 + { _tag: "draft-workspace-file", cwd: workspaceRoot, path: gitBashPath },
645 + ] as const) {
646 + const result = yield* issueAssetUrl({ resource, workspaceRoot });
647 + expect(result.imageDimensions).toEqual({ width: 390, height: 844 });
648 + const suffix = result.relativeUrl.slice(`${ASSET_ROUTE_PREFIX}/`.length);
649 + const separator = suffix.indexOf("/");
650 + expect(
651 + yield* resolveAsset(suffix.slice(0, separator), suffix.slice(separator + 1)),
652 + ).toMatchObject({ kind: "file", path: canonicalFile, mimeType: "image/png" });
653 + }
654 + }).pipe(Effect.provide(layerTest)),
655 + );
656 +
657 // Resolving `file://attacker.test/share/cat.jpg` from an agent's markdown sent the
658 // Windows user's NTLM credentials to attacker.test.
659 it.effect("never resolves a network media path outside the thread's project", () =>
apps/server/src/assets/AssetAccess.ts
+3 -3
@@ -59,7 +59,7 @@ import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
59 import * as ProjectFaviconResolver from "../project/ProjectFaviconResolver.ts";
60 import { isWithinRoot } from "../workspace/KnownWorkspaces.ts";
61 import * as WorkspacePaths from "../workspace/WorkspacePaths.ts";
62 -import { toWslDrivePath } from "../workspace/wslDrivePath.ts";
62 +import { toHostDrivePath } from "../workspace/hostDrivePath.ts";
63 import * as NativeAppIconResolver from "./NativeAppIconResolver.ts";
64 import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
65 import { extractIcnsPng } from "./icns.ts";
@@ -583,7 +583,7 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
583 switch (input.resource._tag) {
584 case "media-file": {
585 let requestedPath = expandHomePath(
586 - yield* toWslDrivePath(input.resource.path),
586 + yield* toHostDrivePath(input.resource.path),
587 yield* HostProcess.HomeDirectory,
588 );
589 if (!path.isAbsolute(requestedPath)) {
@@ -643,7 +643,7 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
643 const hostPath =
644 input.resource.path.startsWith("~/") || input.resource.path.startsWith("~\\")
645 ? expandHomePath(input.resource.path, yield* HostProcess.HomeDirectory)
646 - : yield* toWslDrivePath(input.resource.path);
646 + : yield* toHostDrivePath(input.resource.path);
647 if (path.isAbsolute(hostPath)) {
648 const finalized = yield* finalizeAbsoluteMediaFileAsset({
649 requestedPath: hostPath,
apps/server/src/workspace/WorkspaceFileSystem.test.ts
+21
@@ -443,6 +443,27 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
443 }),
444 );
445
446 + // Agents on Windows copy paths from Git Bash, which prints `C:\x` as `/c/x`.
447 + it.effect.runIf(HostProcess.Platform.defaultValue() === "win32")(
448 + "reads a Git Bash drive path on Windows",
449 + () =>
450 + Effect.gen(function* () {
451 + const service = yield* WorkspaceFileSystem.WorkspaceFileSystem;
452 + const fs = yield* FileSystem.FileSystem;
453 + const path = yield* Path.Path;
454 + const cwd = yield* makeTempDir;
455 + const filePath = path.join(yield* fs.realPath(yield* makeTempDir), "notes.md");
456 + yield* fs.writeFileString(filePath, "# Notes\n");
457 + const gitBashPath = `/${filePath[0]!.toLowerCase()}${filePath.slice(2).replaceAll("\\", "/")}`;
458 +
459 + expect((yield* service.getMetadata({ paths: [gitBashPath] })).entries).toEqual([
460 + { kind: "file", byteLength: 8 },
461 + ]);
462 + const result = yield* service.readFile({ cwd, relativePath: gitBashPath });
463 + expect(result).toMatchObject({ contents: "# Notes\n", truncated: false });
464 + }),
465 + );
466 +
467 it.effect("refuses a network path outside the workspace", () =>
468 Effect.gen(function* () {
469 const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
apps/server/src/workspace/WorkspaceFileSystem.ts
+2 -2
@@ -27,7 +27,7 @@ import * as KnownWorkspaces from "./KnownWorkspaces.ts";
27 import * as WorkspaceEntries from "./WorkspaceEntries.ts";
28 import * as WorkspacePaths from "./WorkspacePaths.ts";
29 import { fileHeaderMimeType } from "./fileHeaderMimeType.ts";
30 -import { toWslDrivePath } from "./wslDrivePath.ts";
30 +import { toHostDrivePath } from "./hostDrivePath.ts";
31
32 const PROJECT_READ_FILE_MAX_BYTES = 1024 * 1024;
33
@@ -167,7 +167,7 @@ export const make = Effect.gen(function* () {
167 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
168
169 const toHostPath = (requestedPath: string) =>
170 - toWslDrivePath(requestedPath).pipe(
170 + toHostDrivePath(requestedPath).pipe(
171 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
172 );
173
apps/server/src/workspace/hostDrivePath.ts renamed
+14 -3
@@ -4,13 +4,24 @@ import * as Effect from "effect/Effect";
4 import * as ChildProcess from "effect/process/ChildProcess";
5 import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
6
7 +// Git Bash, which runs Claude Code's Bash tool on Windows, prints `C:\x` as `/c/x`.
8 +const GIT_BASH_DRIVE_PATTERN = /^\/([a-zA-Z])(?:\/|$)/;
9 +
10 +// Maps a drive path written for the other side of a Windows host to this host's form.
11 // WSL mounts Windows drives under a configurable automount root, so only wslpath knows where.
12 // No WSL env check: servers started by systemd lack WSL_DISTRO_NAME, and off WSL the spawn just fails.
9 -// Untraced: it runs for every chip path, and only drive paths on Linux do any work.
10 -export const toWslDrivePath = Effect.fnUntraced(function* (requestedPath: string) {
13 +// Untraced: it runs for every chip path, and only drive paths on Linux spawn anything.
14 +export const toHostDrivePath = Effect.fnUntraced(function* (requestedPath: string) {
15 + const platform = yield* HostProcess.Platform;
16 + if (platform === "win32") {
17 + return requestedPath.replace(
18 + GIT_BASH_DRIVE_PATTERN,
19 + (_, drive: string) => `${drive.toUpperCase()}:/`,
20 + );
21 + }
22 // spawn throws on a NUL byte instead of failing.
23 if (!isWindowsDrivePath(requestedPath) || requestedPath.includes("\0")) return requestedPath;
13 - if ((yield* HostProcess.Platform) !== "linux") return requestedPath;
24 + if (platform !== "linux") return requestedPath;
25 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
26 const output = yield* spawner
27 .string(