From af0fa15bbfe1fdc92a9b1fdf39aacec836de679d Mon Sep 17 00:00:00 2001 From: Onkarj012 Date: Tue, 20 Oct 2026 23:02:35 +0530 Subject: [PATCH] fix(web): the ~ breadcrumb opens the home folder A home path like ~/.claude/CLAUDE.md gave its first crumb the path "~", which is not a host path, so the crumb rendered as plain text. Name the home folder "~/" instead, the same way a bare drive becomes "C:\". Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/files/filePath.test.ts | 10 ++++++++-- apps/web/src/components/files/filePath.ts | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/files/filePath.test.ts b/apps/web/src/components/files/filePath.test.ts index 9dc20199aab12..d8ed9e97c9537 100644 --- a/apps/web/src/components/files/filePath.test.ts +++ b/apps/web/src/components/files/filePath.test.ts @@ -48,14 +48,19 @@ describe("fileBreadcrumbs", () => { ]); }); - it("builds home-relative breadcrumbs with navigable child folders", () => { + it("builds home-relative breadcrumbs with navigable folders", () => { expect(fileBreadcrumbs("t3code", "~/.claude/CLAUDE.md")).toEqual([ - { label: "~", path: "~", kind: "directory" }, + { label: "~", path: "~/", kind: "directory" }, { label: ".claude", path: "~/.claude", kind: "directory" }, { label: "CLAUDE.md", path: "~/.claude/CLAUDE.md", kind: "file" }, ]); + expect(isListableHostFolder("~/")).toBe(true); expect(isListableHostFolder("~/.claude")).toBe(true); }); + + it("keeps a project folder named ~ inside the project", () => { + expect(fileBreadcrumbs("t3code", "~").map((crumb) => crumb.path)).toEqual(["", "~"]); + }); }); describe("breadcrumbPathOf", () => { @@ -69,6 +74,7 @@ describe("breadcrumbPathOf", () => { ["C:\\Users\\me\\", "C:\\Users\\me"], ["C:\\", "C:\\"], ["\\\\server\\share\\", "\\\\server\\share"], + ["~/", "~/"], ])("writes %j as its crumb names it", (path, expected) => { expect(breadcrumbPathOf(path)).toBe(expected); }); diff --git a/apps/web/src/components/files/filePath.ts b/apps/web/src/components/files/filePath.ts index 9891cef28fab0..7f078946b0202 100644 --- a/apps/web/src/components/files/filePath.ts +++ b/apps/web/src/components/files/filePath.ts @@ -23,7 +23,8 @@ export function fileBreadcrumbs(projectName: string, relativePath: string): File return { label: part, // A bare drive (`C:`) means the drive's current directory; its root is `C:\`. - path: /^[A-Za-z]:$/.test(path) ? `${path}\\` : path, + // A bare `~` is not a host path; the home folder is `~/`. + path: /^[A-Za-z]:$/.test(path) ? `${path}\\` : hostPath && path === "~" ? "~/" : path, kind: index === parts.length - 1 ? ("file" as const) : ("directory" as const), }; }),