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

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

fix(web): a ~\ home path opens as a read-only home file, not as a project file (#38510)

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

Fuksss committed Nov 18, 2026 at 11:13 UTC 0d405f664a2720a73ad2491529597317c6bd5945
5 files changed +26 -8
apps/web/src/components/files/filePath.test.ts
+5
@@ -33,6 +33,11 @@ describe("fileBreadcrumbs", () => {
33 { label: ".claude", path: "~/.claude", kind: "directory" },
34 { label: "CLAUDE.md", path: "~/.claude/CLAUDE.md", kind: "file" },
35 ]);
36 + expect(fileBreadcrumbs("t3code", "~\\.claude/CLAUDE.md")).toEqual([
37 + { label: "~", path: "~/", kind: "directory" },
38 + { label: ".claude", path: "~/.claude", kind: "directory" },
39 + { label: "CLAUDE.md", path: "~/.claude/CLAUDE.md", kind: "file" },
40 + ]);
41 expect(isListableHostFolder("~/")).toBe(true);
42 expect(isListableHostFolder("~/.claude")).toBe(true);
43 });
apps/web/src/components/files/filePath.ts
+3 -1
@@ -16,7 +16,9 @@ export function fileBreadcrumbs(projectName: string, relativePath: string): File
16 const windowsPath = isWindowsAbsolutePath(relativePath);
17 const separator = windowsPath ? "\\" : "/";
18 // `\` is a legal filename character outside Windows paths.
19 - const parts = relativePath.split(windowsPath ? /[\\/]/ : "/").filter(Boolean);
19 + // The server reads `~\` as home; the rest keeps the usual relative-path spelling.
20 + const homePath = relativePath.startsWith("~\\") ? `~/${relativePath.slice(2)}` : relativePath;
21 + const parts = homePath.split(windowsPath ? /[\\/]/ : "/").filter(Boolean);
22 const root = relativePath.startsWith("\\\\") ? "\\\\" : relativePath.startsWith("/") ? "/" : "";
23 return [
24 ...(hostPath ? [] : [{ label: projectName, path: "", kind: "project" as const }]),
packages/client-runtime/src/operations/projects.ts
+8 -3
@@ -11,7 +11,7 @@ import type {
11 } from "@t3tools/contracts";
12 import { SourceControlProviderKind } from "@t3tools/contracts";
13 import { cloneUrlRepositoryPath } from "@t3tools/shared/cloneUrl";
14 -import { isExplicitRelativePath, isHostPath, newProjectFolderName } from "@t3tools/shared/path";
14 +import { isAbsolutePath, isExplicitRelativePath, newProjectFolderName } from "@t3tools/shared/path";
15 import * as Arr from "effect/Array";
16 import * as Option from "effect/Option";
17 import * as Order from "effect/Order";
@@ -222,8 +222,13 @@ export function buildAddProjectRemoteSourceReadiness(
222 export function getAddProjectInitialQuery(baseDirectory: string | null | undefined): string {
223 const trimmed = baseDirectory?.trim() ?? "";
224 if (trimmed.length === 0) return "~/";
225 - // A bare relative setting such as `Desktop/dev` means a folder under home.
226 - const isAnchored = trimmed === "~" || isHostPath(trimmed) || isExplicitRelativePath(trimmed);
225 + // A bare relative setting such as `Desktop/dev` means a folder under home. The browser
226 + // navigates `~/` but not `~\` home paths.
227 + const isAnchored =
228 + trimmed === "~" ||
229 + isAbsolutePath(trimmed) ||
230 + trimmed.startsWith("~/") ||
231 + isExplicitRelativePath(trimmed);
232 return ensureBrowseDirectoryPath(isAnchored ? trimmed : `~/${trimmed}`);
233 }
234
packages/shared/src/path.test.ts
+1
@@ -59,6 +59,7 @@ describe("resolvePastedPath", () => {
59 ["over a selection", "/Users/me/old", "'/Users/me/My Code'", "/Users/me/My Code"],
60 ["after a prefilled folder", "~/", "~/'/Users/me/My Code'", "/Users/me/My Code"],
61 ["plain, after a prefilled folder", "~/", "~//Users/me/code", "/Users/me/code"],
62 + ["backslash home, after a folder", "~/", "~/~\\folder\\ child", "~/~\\folder\\ child"],
63 ["after a Windows folder", "C:\\Users\\", 'C:\\Users\\"D:\\My Code"', "D:\\My Code"],
64 ["a shell's quoted apostrophe", "", "'/Users/me/Bob'\\''s Work'", "/Users/me/Bob's Work"],
65 ["after a clone destination", "~/code/repo", "~/code/repo'/a b'", "/a b"],
packages/shared/src/path.ts
+9 -4
@@ -134,15 +134,20 @@ export function isAbsolutePath(value: string): boolean {
134 return value.startsWith("/") || isWindowsAbsolutePath(value);
135 }
136
137 -/** Home-relative host paths are expanded by the destination server. */
137 +/** Both ~/ and ~\ home prefixes are expanded by the destination server. */
138 export function isHostPath(value: string): boolean {
139 - return isAbsolutePath(value) || value.startsWith("~/");
139 + return isAbsolutePath(value) || value.startsWith("~/") || value.startsWith("~\\");
140 }
141
142 // Finder and Explorer copy a path ready for a shell: `'/a b'`, `/a\'s\ b`, or `"C:\a b"`.
143 const QUOTED_PATH_AT_END = /(?:'((?:[^']|'\\'')+)'|"([^"]+)")\s*$/;
144 const SHELL_ESCAPE = /\\([\s'"\\()[\]{}<>|&;$`!*?#~^=])/g;
145
146 +// Folder browsers only navigate `~/` home paths, so a pasted `~\` path is not a replacement.
147 +function isPastedFolderPath(value: string): boolean {
148 + return isAbsolutePath(value) || value.startsWith("~/");
149 +}
150 +
151 /**
152 * What a folder box holds after a change. A full path pasted into it replaces the box, even after
153 * the text already there, because `~/'/a b'` would create that nested folder.
@@ -157,13 +162,13 @@ export function resolvePastedPath(previous: string, next: string): string {
162 // Text before the quote that wasn't in the box is a search, not a folder to paste after.
163 if (match && previous.startsWith(next.slice(0, match.index).trimEnd())) {
164 const quoted = match[1]?.replaceAll("'\\''", "'") ?? match[2] ?? "";
160 - if (isHostPath(quoted)) return quoted;
165 + if (isPastedFolderPath(quoted)) return quoted;
166 }
167
168 // Without a trailing separator, `/a` then `/a/b` is a longer path, not one pasted after a folder.
169 const afterFolder = /[/\\]$/.test(previous) && next.startsWith(previous);
170 const path = afterFolder ? next.slice(previous.length) : next;
166 - if (!isHostPath(path)) return next;
171 + if (!isPastedFolderPath(path)) return next;
172 // `\` separates folders in Windows paths, so it only escapes in `/` and `~/` paths.
173 return isWindowsAbsolutePath(path) ? path : path.replace(SHELL_ESCAPE, "$1");
174 }