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, 14:45 UTC
fix(server): expand Windows home-relative file paths consistently (#29378)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
luke committed
Nov 14, 2026 at 14:38 UTC
f52e5c19198b744229d5aa193f55d4802b04cbfd
4 files changed
+73
-66
apps/server/src/assets/AssetAccess.test.ts
+46
-43
@@ -525,50 +525,53 @@ describe("AssetAccess", () => {
525
}).pipe(Effect.provide(layerTest)),
526
);
527
528
- it.effect("resolves home-relative media paths independently of the workspace", () =>
529
- Effect.gen(function* () {
530
- const fs = yield* FileSystem.FileSystem;
531
- const path = yield* Path.Path;
532
- const directory = yield* fs.makeTempDirectoryScoped({ prefix: "t3-media-home-" });
533
- const home = path.join(directory, "var", "home", "alice");
534
- const filePath = path.join(home, "Downloads", "repro.mp4");
535
- yield* fs.makeDirectory(path.dirname(filePath), { recursive: true });
536
- yield* fs.writeFileString(filePath, "recording bytes");
537
- const canonicalFile = yield* fs.realPath(filePath);
538
- yield* Effect.gen(function* () {
539
- for (const workspaceRoot of [
540
- path.join(home, "project"),
541
- path.join(directory, "srv", "project"),
542
- undefined,
543
- ]) {
544
- if (workspaceRoot) yield* fs.makeDirectory(workspaceRoot, { recursive: true });
545
- for (const requestedPath of ["~/Downloads/repro.mp4", "~\\Downloads/repro.mp4"]) {
546
- const result = yield* issueAssetUrl({
547
- resource: {
548
- _tag: "media-file",
549
- threadId: ThreadId.make("thread-1"),
550
- path: requestedPath,
551
- },
552
- ...(workspaceRoot ? { workspaceRoot } : {}),
553
- });
554
- const suffix = result.relativeUrl.slice(`${ASSET_ROUTE_PREFIX}/`.length);
555
- const separator = suffix.indexOf("/");
556
- const asset = yield* resolveAsset(
557
- suffix.slice(0, separator),
558
- suffix.slice(separator + 1),
559
- );
560
- expect(asset).toMatchObject({
561
- kind: "file",
562
- path: canonicalFile,
563
- mimeType: "video/mp4",
564
- });
565
- if (asset?.kind !== "file") throw new Error("Expected a resolved home media file");
566
- const response = HttpServerResponse.toWeb(yield* assetFileResponse(asset));
567
- expect(yield* Effect.promise(() => response.text())).toBe("recording bytes");
528
+ it.effect.each(["media-file", "draft-workspace-file"] as const)(
529
+ "resolves home-relative %s paths independently of the workspace",
530
+ (tag) =>
531
+ Effect.gen(function* () {
532
+ const fs = yield* FileSystem.FileSystem;
533
+ const path = yield* Path.Path;
534
+ const directory = yield* fs.makeTempDirectoryScoped({ prefix: "t3-media-home-" });
535
+ const home = path.join(directory, "var", "home", "alice");
536
+ const filePath = path.join(home, "Downloads", "repro.mp4");
537
+ yield* fs.makeDirectory(path.dirname(filePath), { recursive: true });
538
+ yield* fs.writeFileString(filePath, "recording bytes");
539
+ const canonicalFile = yield* fs.realPath(filePath);
540
+ yield* Effect.gen(function* () {
541
+ for (const workspaceRoot of [
542
+ path.join(home, "project"),
543
+ path.join(directory, "srv", "project"),
544
+ undefined,
545
+ ]) {
546
+ if (workspaceRoot) yield* fs.makeDirectory(workspaceRoot, { recursive: true });
547
+ for (const requestedPath of ["~/Downloads/repro.mp4", "~\\Downloads/repro.mp4"]) {
548
+ const result = yield* issueAssetUrl({
549
+ resource: {
550
+ ...(tag === "media-file"
551
+ ? { _tag: tag, threadId: ThreadId.make("thread-1") }
552
+ : { _tag: tag, cwd: workspaceRoot ?? directory }),
553
+ path: requestedPath,
554
+ },
555
+ ...(workspaceRoot ? { workspaceRoot } : {}),
556
+ });
557
+ const suffix = result.relativeUrl.slice(`${ASSET_ROUTE_PREFIX}/`.length);
558
+ const separator = suffix.indexOf("/");
559
+ const asset = yield* resolveAsset(
560
+ suffix.slice(0, separator),
561
+ suffix.slice(separator + 1),
562
+ );
563
+ expect(asset).toMatchObject({
564
+ kind: "file",
565
+ path: canonicalFile,
566
+ mimeType: "video/mp4",
567
+ });
568
+ if (asset?.kind !== "file") throw new Error("Expected a resolved home media file");
569
+ const response = HttpServerResponse.toWeb(yield* assetFileResponse(asset));
570
+ expect(yield* Effect.promise(() => response.text())).toBe("recording bytes");
571
+ }
572
}
569
- }
570
- }).pipe(Effect.provideService(HostProcess.HomeDirectory, home));
571
- }).pipe(Effect.provide(layerTest)),
573
+ }).pipe(Effect.provideService(HostProcess.HomeDirectory, home));
574
+ }).pipe(Effect.provide(layerTest)),
575
);
576
577
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
apps/server/src/assets/AssetAccess.ts
+4
-3
@@ -607,9 +607,10 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
607
}
608
case "draft-workspace-file": {
609
const draftWorkspaceRoot = input.workspaceRoot ?? input.resource.cwd;
610
- const hostPath = input.resource.path.startsWith("~/")
611
- ? expandHomePath(input.resource.path, yield* HostProcess.HomeDirectory)
612
- : yield* toWslDrivePath(input.resource.path);
610
+ const hostPath =
611
+ input.resource.path.startsWith("~/") || input.resource.path.startsWith("~\\")
612
+ ? expandHomePath(input.resource.path, yield* HostProcess.HomeDirectory)
613
+ : yield* toWslDrivePath(input.resource.path);
614
if (path.isAbsolute(hostPath)) {
615
const finalized = yield* finalizeAbsoluteMediaFileAsset({
616
requestedPath: hostPath,
apps/server/src/workspace/WorkspaceFileSystem.test.ts
+19
-17
@@ -320,25 +320,27 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
320
}),
321
);
322
323
- it.effect("reads ~/ paths from the server home outside the workspace", () =>
324
- Effect.gen(function* () {
325
- const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
326
- const cwd = yield* makeTempDir;
327
- const home = yield* makeTempDir;
328
- yield* writeTextFile(home, ".claude/CLAUDE.md", "# Notes\n");
329
- yield* writeTextFile(cwd, "~/.claude/CLAUDE.md", "Workspace decoy\n");
323
+ it.effect.each(["~/.claude/CLAUDE.md", "~\\.claude/CLAUDE.md"])(
324
+ "reads %s from the server home outside the workspace",
325
+ (relativePath) =>
326
+ Effect.gen(function* () {
327
+ const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
328
+ const cwd = yield* makeTempDir;
329
+ const home = yield* makeTempDir;
330
+ yield* writeTextFile(home, ".claude/CLAUDE.md", "# Notes\n");
331
+ yield* writeTextFile(cwd, "~/.claude/CLAUDE.md", "Workspace decoy\n");
332
331
- const result = yield* workspaceFileSystem
332
- .readFile({ cwd, relativePath: "~/.claude/CLAUDE.md" })
333
- .pipe(Effect.provideService(HostProcess.HomeDirectory, home));
333
+ const result = yield* workspaceFileSystem
334
+ .readFile({ cwd, relativePath })
335
+ .pipe(Effect.provideService(HostProcess.HomeDirectory, home));
336
335
- expect(result).toEqual({
336
- relativePath: "~/.claude/CLAUDE.md",
337
- contents: "# Notes\n",
338
- byteLength: 8,
339
- truncated: false,
340
- });
341
- }),
337
+ expect(result).toEqual({
338
+ relativePath,
339
+ contents: "# Notes\n",
340
+ byteLength: 8,
341
+ truncated: false,
342
+ });
343
+ }),
344
);
345
346
it.effect("does not read server state files", () =>
apps/server/src/workspace/WorkspaceFileSystem.ts
+4
-3
@@ -260,9 +260,10 @@ export const make = Effect.gen(function* () {
260
input: ProjectReadFileInput,
261
) {
262
const requestedPath = input.relativePath;
263
- const hostPath = requestedPath.startsWith("~/")
264
- ? expandHomePath(requestedPath, yield* HostProcess.HomeDirectory)
265
- : yield* toHostPath(requestedPath);
263
+ const hostPath =
264
+ requestedPath.startsWith("~/") || requestedPath.startsWith("~\\")
265
+ ? expandHomePath(requestedPath, yield* HostProcess.HomeDirectory)
266
+ : yield* toHostPath(requestedPath);
267
if (
268
isNetworkPath(hostPath) &&
269
!KnownWorkspaces.isWithinRoot(path, path.resolve(hostPath), path.resolve(input.cwd))