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 22, 12:00 UTC
fix(server): list folders named with a backslash on Linux and macOS (#23398)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Oct 30, 2026 at 15:46 UTC
e92981dcf3f79c13aff01f975d68ea80bf4b2770
2 files changed
+26
-5
apps/server/src/workspace/WorkspacePaths.test.ts
+22
@@ -5,6 +5,8 @@ import * as FileSystem from "effect/FileSystem";
5
import * as Layer from "effect/Layer";
6
import * as Path from "effect/Path";
7
8
+import * as HostProcess from "@t3tools/shared/HostProcess";
9
+
10
import * as WorkspacePaths from "./WorkspacePaths.ts";
11
12
const layerTest = Layer.empty.pipe(
@@ -58,5 +60,25 @@ it.layer(layerTest)("WorkspacePathsLive", (it) => {
60
);
61
}),
62
);
63
+
64
+ // On Windows `\` is a separator, so these names cannot exist there.
65
+ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
66
+ "keeps a backslash in a name as part of the name",
67
+ () =>
68
+ Effect.gen(function* () {
69
+ const workspacePaths = yield* WorkspacePaths.WorkspacePaths;
70
+ const path = yield* Path.Path;
71
+ const cwd = yield* makeTempDir();
72
+
73
+ for (const relativePath of ["weird\\name.txt", "..\\..\\etc"]) {
74
+ expect(
75
+ yield* workspacePaths.resolveRelativePathWithinRoot({
76
+ workspaceRoot: cwd,
77
+ relativePath,
78
+ }),
79
+ ).toEqual({ absolutePath: path.join(cwd, relativePath), relativePath });
80
+ }
81
+ }),
82
+ );
83
});
84
});
apps/server/src/workspace/WorkspacePaths.ts
+4
-5
@@ -103,10 +103,6 @@ export class WorkspacePaths extends Context.Service<
103
}
104
>()("t3/workspace/WorkspacePaths") {}
105
106
-function toPosixRelativePath(input: string): string {
107
- return input.replaceAll("\\", "/");
108
-}
109
-
106
const make = Effect.gen(function* () {
107
const fileSystem = yield* FileSystem.FileSystem;
108
const path = yield* Path.Path;
@@ -188,7 +184,10 @@ const make = Effect.gen(function* () {
184
}
185
186
const absolutePath = path.resolve(input.workspaceRoot, normalizedInputPath);
191
- const relativeToRoot = toPosixRelativePath(path.relative(input.workspaceRoot, absolutePath));
187
+ // Only the host separator becomes `/`: on POSIX `\` is a file name character.
188
+ const relativeToRoot = path
189
+ .relative(input.workspaceRoot, absolutePath)
190
+ .replaceAll(path.sep, "/");
191
if (
192
relativeToRoot.length === 0 ||
193
relativeToRoot === "." ||