Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(ui): one shared FilePath that never cuts the filename (#4161)
Raghav Chamadiyaefc77a20f19d
diff --git a/packages/ui/__tests__/dead-code/findings-table.test.tsx b/packages/ui/__tests__/dead-code/findings-table.test.tsxindex 4ffd17946..84f090964 100644--- a/packages/ui/__tests__/dead-code/findings-table.test.tsx+++ b/packages/ui/__tests__/dead-code/findings-table.test.tsx@@ -192,7 +192,7 @@ describe("FindingsTable sort and search", () => {return inTable().getAllByRole("row").slice(1)- .map((r) => r.querySelector("a,span[title]")?.getAttribute("title"))+ .map((r) => r.querySelector("[data-path]")?.getAttribute("data-path")).filter(Boolean);}diff --git a/packages/ui/__tests__/decisions/decision-governance.test.tsx b/packages/ui/__tests__/decisions/decision-governance.test.tsxindex 7eac24878..c68d6e652 100644--- a/packages/ui/__tests__/decisions/decision-governance.test.tsx+++ b/packages/ui/__tests__/decisions/decision-governance.test.tsx@@ -171,7 +171,7 @@ describe("GovernedFiles", () => {]}/>,);- expect(screen.getByText("src/api.ts").className).toContain("font-mono");+ expect(screen.getByText("src/api.ts").closest(".font-mono")).not.toBeNull();expect(screen.getByText("12").className).toContain("tabular-nums");// The bar is proportional to the leader, not to an arbitrary ceiling.const bars = container.querySelectorAll('[style*="width"]');diff --git a/packages/ui/__tests__/doc-drift/doc-drift-view.test.tsx b/packages/ui/__tests__/doc-drift/doc-drift-view.test.tsxindex 5a0f0a369..4ed3a469c 100644--- a/packages/ui/__tests__/doc-drift/doc-drift-view.test.tsx+++ b/packages/ui/__tests__/doc-drift/doc-drift-view.test.tsx@@ -461,7 +461,7 @@ describe("DocDriftView", () => {const table = await screen.findByRole("table", TABLE);const headings = screen.getAllByRole("heading", { level: 3 })- .map((h) => h.textContent);+ .map((h) => h.querySelector("[data-path]")?.getAttribute("data-path"));expect(headings).toEqual(["docs/architecture.md", "docs/cli.md"]);expect(screen.getByText("2 findings")).toBeTruthy();expect(screen.getByText("1 finding")).toBeTruthy();diff --git a/packages/ui/__tests__/graph/node-id.test.ts b/packages/ui/__tests__/graph/node-id.test.tsnew file mode 100644index 000000000..bed6f21e6--- /dev/null+++ b/packages/ui/__tests__/graph/node-id.test.ts@@ -0,0 +1,10 @@+import { describe, expect, it } from "vitest";+import { isFileNodeId } from "../../src/graph/node-id";++describe("isFileNodeId", () => {+ it("accepts a bare file path only", () => {+ expect(isFileNodeId("src/a.ts")).toBe(true);+ expect(isFileNodeId("src/a.ts::load")).toBe(false);+ expect(isFileNodeId("external:react")).toBe(false);+ });+});diff --git a/packages/ui/__tests__/lib/path-parts.test.ts b/packages/ui/__tests__/lib/path-parts.test.tsnew file mode 100644index 000000000..268743802--- /dev/null+++ b/packages/ui/__tests__/lib/path-parts.test.ts@@ -0,0 +1,56 @@+import { describe, expect, it } from "vitest";+import { foldPackagePrefix, pathWithLine, splitDirTail, splitPath } from "../../src/lib/path-parts";++describe("splitPath", () => {+ it("splits at the last slash", () => {+ expect(splitPath("src/a/b.ts")).toEqual({ dir: "src/a", name: "b.ts" });+ });+ it("keeps a top-level file whole", () => {+ expect(splitPath("README.md")).toEqual({ dir: "", name: "README.md" });+ });+});++describe("foldPackagePrefix", () => {+ it("folds the root, src and a namespace that repeats the package", () => {+ expect(foldPackagePrefix("packages/server/src/repowise/server/mcp_server/tool.py")).toEqual({+ pkg: "server",+ rest: "mcp_server/tool.py",+ });+ });+ it("drops a directory named after the package", () => {+ expect(foldPackagePrefix("apps/web/src/web/page.tsx")).toEqual({ pkg: "web", rest: "page.tsx" });+ });+ it("treats hyphen and underscore spellings as one package", () => {+ expect(foldPackagePrefix("packages/api-client/src/api_client/x.ts")).toEqual({+ pkg: "api-client",+ rest: "x.ts",+ });+ });+ it("keeps paths outside a package root unchanged", () => {+ expect(foldPackagePrefix("src/packages/a.ts")).toEqual({ pkg: null, rest: "src/packages/a.ts" });+ expect(foldPackagePrefix("packages/README.md")).toEqual({ pkg: null, rest: "packages/README.md" });+ });+ it("never folds away the file name", () => {+ expect(foldPackagePrefix("packages/ui/src")).toEqual({ pkg: "ui", rest: "src" });+ expect(foldPackagePrefix("packages/ui/ui")).toEqual({ pkg: "ui", rest: "ui" });+ });+});++describe("splitDirTail", () => {+ it("keeps the last folder whole", () => {+ expect(splitDirTail("a/b/c")).toEqual({ head: "a/b", tail: "c" });+ expect(splitDirTail("a/b/c", 2)).toEqual({ head: "a", tail: "b/c" });+ });+ it("has no head for a single folder", () => {+ expect(splitDirTail("a")).toEqual({ head: "", tail: "a" });+ expect(splitDirTail("")).toEqual({ head: "", tail: "" });+ });+});++describe("pathWithLine", () => {+ it("adds a line or range when known", () => {+ expect(pathWithLine("a.ts", 4)).toBe("a.ts:4");+ expect(pathWithLine("a.ts", "4-9")).toBe("a.ts:4-9");+ expect(pathWithLine("a.ts", null)).toBe("a.ts");+ });+});diff --git a/packages/ui/__tests__/security/security.test.tsx b/packages/ui/__tests__/security/security.test.tsxindex 19944970e..fdf3f3419 100644--- a/packages/ui/__tests__/security/security.test.tsx+++ b/packages/ui/__tests__/security/security.test.tsx@@ -102,12 +102,11 @@ describe("SecurityFindingsTable", () => {expect(rows[2]!.textContent).toContain("test");});- it("wraps the path instead of truncating it", () => {+ it("leads with the file name and keeps the whole path as its name", () => {render(<SecurityFindingsTable findings={FINDINGS} />);- const path = screen.getByText("src/app/server.py");- expect(path.className).not.toContain("break-all");- expect(path.querySelectorAll("wbr").length).toBeGreaterThan(1);- expect(path.className).not.toContain("truncate");+ const name = screen.getByText("server.py");+ expect(name.closest("[aria-hidden]")?.textContent?.startsWith("server.py")).toBe(true);+ expect(screen.getByText(/^src\/app\/server\.py(:\d+)?$/).className).toContain("sr-only");});it("keeps every severity option and its unfiltered count when one is picked", () => {diff --git a/packages/ui/__tests__/shared/file-path.test.tsx b/packages/ui/__tests__/shared/file-path.test.tsxnew file mode 100644index 000000000..c910c8583--- /dev/null+++ b/packages/ui/__tests__/shared/file-path.test.tsx@@ -0,0 +1,136 @@+import { describe, expect, it, vi } from "vitest";+import { act, fireEvent, render, screen } from "@testing-library/react";+import manifest from "../../package.json" with { type: "json" };+import { FilePath } from "../../src/shared/file-path";+import { disambiguateBasenames } from "../../src/lib/format";++const LONG = "packages/server/src/repowise/server/mcp_server/tool_dependency.py";++describe("FilePath", () => {+ it("name-first puts the file name before the directory and keeps the full path as the name", () => {+ render(+ <a href="/f">+ <FilePath path={LONG} line={12} />+ </a>,+ );+ expect(screen.getByRole("link", { name: `${LONG}:12` })).toBeTruthy();+ const visual = screen.getByText("tool_dependency.py").closest("[aria-hidden]");+ expect(visual?.textContent?.startsWith("tool_dependency.py:12")).toBe(true);+ });++ it("folds the package prefix only when asked", () => {+ const { rerender } = render(<FilePath path={LONG} fold />);+ expect(screen.getByText("server")).toBeTruthy();+ expect(screen.getByText("mcp_server")).toBeTruthy();+ const visual = screen.getByText("tool_dependency.py").closest("[aria-hidden]");+ expect(visual?.textContent).not.toContain("repowise");+ rerender(<FilePath path={LONG} />);+ expect(screen.queryByText("server")).toBeNull();+ });++ it("distinguishing prints the shortest unique suffix", () => {+ const labels = disambiguateBasenames(["src/css/mod.rs", "src/text/mod.rs"]);+ render(<FilePath path="src/css/mod.rs" mode="distinguishing" labels={labels} />);+ const visual = screen.getByText("mod.rs").closest("[aria-hidden]");+ expect(visual?.textContent).toBe("css/mod.rs");+ expect(screen.getByText("src/css/mod.rs").className).toContain("sr-only");+ });++ it("full wraps only after slashes and has no hidden copy", () => {+ const { container } = render(<FilePath path="src/app/server.py" mode="full" />);+ expect(container.textContent).toBe("src/app/server.py");+ expect(container.querySelectorAll("wbr").length).toBe(2);+ expect(container.querySelector(".sr-only")).toBeNull();+ });++ it("does not duplicate a top-level file", () => {+ render(<FilePath path="README.md" />);+ expect(screen.getAllByText("README.md")).toHaveLength(1);+ });++ it("never adds a tab stop of its own", () => {+ const { container } = render(+ <>+ <a href="/x">+ <FilePath path="a/b.ts" />+ </a>+ <FilePath path="c/d.ts" />+ </>,+ );+ const triggers = container.querySelectorAll("[data-path] > span");+ expect(triggers[0]?.getAttribute("tabindex")).toBeNull();+ expect(triggers[1]?.getAttribute("tabindex")).toBeNull();+ });++ it("opens the tooltip when the holding link takes keyboard focus", async () => {+ render(+ <a href="/x">+ <FilePath path="a/b.ts" />+ </a>,+ );+ act(() => {+ screen.getByRole("link").focus();+ });+ expect((await screen.findByRole("tooltip")).textContent).toContain("a/b.ts");+ });++ it("mounts no tooltip machinery until the path is hovered", () => {+ const { container } = render(<FilePath path="a/b.ts" />);+ expect(container.querySelector("[data-state]")).toBeNull();+ fireEvent.pointerEnter(container.querySelector("[data-path] > span")!);+ expect(container.querySelector("[data-state]")).not.toBeNull();+ });++ it("opens on the first hover even when the pointer then stays still", async () => {+ vi.useFakeTimers();+ try {+ const { container } = render(<FilePath path="a/b.ts" />);+ fireEvent.pointerEnter(container.querySelector("[data-path] > span")!);+ await act(async () => {+ vi.advanceTimersByTime(300);+ });+ expect(screen.getByRole("tooltip").textContent).toContain("a/b.ts");+ } finally {+ vi.useRealTimers();+ }+ });++ it("does not open when the first hover leaves before the delay", async () => {+ vi.useFakeTimers();+ try {+ const { container } = render(<FilePath path="a/b.ts" />);+ fireEvent.pointerEnter(container.querySelector("[data-path] > span")!);+ fireEvent.pointerLeave(container.querySelector("[data-path]")!);+ await act(async () => {+ vi.advanceTimersByTime(300);+ });+ expect(screen.queryByRole("tooltip")).toBeNull();+ } finally {+ vi.useRealTimers();+ }+ });++ it.each(["name-first", "middle-ellipsis", "distinguishing"] as const)("never truncates the file name in %s", (mode) => {+ render(<FilePath path={LONG} mode={mode} />);+ expect(screen.getByText("tool_dependency.py").className).not.toMatch(/\btruncate\b/);+ });++ it("keeps an inline mention on one line", () => {+ render(<FilePath path={LONG} mode="middle-ellipsis" />);+ expect(screen.getByText("tool_dependency.py").className).toMatch(/\bwhitespace-nowrap\b/);+ });++ it("copies the path", async () => {+ const writeText = vi.fn().mockResolvedValue(undefined);+ Object.assign(navigator, { clipboard: { writeText } });+ render(<FilePath path="a/b.ts" mode="full" copyable copyLabel="Copy it" />);+ fireEvent.click(screen.getByRole("button", { name: "Copy it" }));+ expect(writeText).toHaveBeenCalledWith("a/b.ts");+ });++ it("is published under the shared and lib subpaths", () => {+ const exports = manifest.exports as Record<string, string>;+ expect(exports["./shared/*"]).toBe("./src/shared/*.tsx");+ expect(exports["./lib/path-parts"]).toBe("./src/lib/path-parts.ts");+ });+});diff --git a/packages/ui/__tests__/workspace/co-change-pair-drawer.test.tsx b/packages/ui/__tests__/workspace/co-change-pair-drawer.test.tsxindex debbe2c99..6578545ef 100644--- a/packages/ui/__tests__/workspace/co-change-pair-drawer.test.tsx+++ b/packages/ui/__tests__/workspace/co-change-pair-drawer.test.tsx@@ -55,9 +55,8 @@ describe("CoChangePairDrawer", () => {expect(screen.getAllByText("Open file page")).toHaveLength(1);expect(screen.getByText(/frontend is not indexed/)).toBeInTheDocument();expect(screen.getByText("commit aaaaaaaa11")).toBeInTheDocument();- // Paths break only after a slash: the directory segments are separate nodes.- expect(screen.getByText("app/")).toBeInTheDocument();- expect(screen.getByText("schemas/")).toBeInTheDocument();+ // Paths break only after a slash.+ expect(document.querySelectorAll("wbr").length).toBeGreaterThan(1);expect(screen.getAllByText("Hotspot")).toHaveLength(2);fireEvent.click(screen.getByRole("button", { name: /AI investigation prompt/ }));expect(onPrompt).toHaveBeenCalled();diff --git a/packages/ui/__tests__/workspace/co-change-table.test.tsx b/packages/ui/__tests__/workspace/co-change-table.test.tsxindex 753d93b80..a1884c7ea 100644--- a/packages/ui/__tests__/workspace/co-change-table.test.tsx+++ b/packages/ui/__tests__/workspace/co-change-table.test.tsx@@ -22,13 +22,11 @@ function cc(}describe("CoChangeTable", () => {- it("renders each file as repo, dim directory and full filename", () => {+ it("renders each file as repo, then the file name ahead of its dim directory", () => {const rows = [cc("api", "api/a.py", "core", "core/b.py", 0.72), cc("ui", "ui/c.tsx", "core", "core/d.py")];render(<CoChangeTable coChanges={rows} />);- expect(screen.getByText("a.py")).toBeInTheDocument();- expect(screen.getAllByText("api/").length).toBe(1);- expect(screen.getByTitle("core/b.py")).toBeInTheDocument();- expect(screen.getAllByText("core").length).toBe(2);+ expect(screen.getByText("a.py").closest("[aria-hidden]")?.textContent).toBe("a.pyapi");+ expect(screen.getByText("core/b.py")).toHaveClass("sr-only");expect(screen.getByText("72%")).toBeInTheDocument();});diff --git a/packages/ui/__tests__/workspace/contract-drawer.test.tsx b/packages/ui/__tests__/workspace/contract-drawer.test.tsxindex 8ea917a29..ecac1c13b 100644--- a/packages/ui/__tests__/workspace/contract-drawer.test.tsx+++ b/packages/ui/__tests__/workspace/contract-drawer.test.tsx@@ -96,10 +96,7 @@ describe("ContractDrawer", () => {expect(screen.getByText("HTTP contract / Provider")).toBeInTheDocument();expect(screen.getByText("users-api")).toBeInTheDocument();// The file reads as a dim directory and its name, with the line after it.- expect(screen.getByText("users.ts").parentElement).toHaveAttribute(- "title",- "src/routes/users.ts:42",- );+ expect(screen.getByText("users.ts").parentElement?.textContent).toBe("src/routes/users.ts:42");expect(screen.getByText("92%")).toBeInTheDocument();expect(screen.getByText("fastapi")).toBeInTheDocument();expect(screen.getByRole("button", { name: "AI prompt" })).toBeInTheDocument();diff --git a/packages/ui/__tests__/workspace/contract-links-table.test.tsx b/packages/ui/__tests__/workspace/contract-links-table.test.tsxindex 886384e15..f9cbe7481 100644--- a/packages/ui/__tests__/workspace/contract-links-table.test.tsx+++ b/packages/ui/__tests__/workspace/contract-links-table.test.tsx@@ -43,10 +43,10 @@ describe("ContractLinksTable", () => {expect(screen.getAllByText("orders-api").length).toBeGreaterThan(0);});- it("splits a file into a dim directory and its name, with the full path on hover", () => {+ it("leads with the file name and keeps the full path as its accessible name", () => {render(<ContractLinksTable links={[link()]} />);- const name = screen.getAllByText("users.ts")[0]!;- expect(name.parentElement).toHaveAttribute("title", "src/routes/users.ts");+ expect(screen.getAllByText("users.ts").length).toBeGreaterThan(0);+ expect(screen.getAllByText("src/routes/users.ts")[0]).toHaveClass("sr-only");expect(screen.getAllByText("users-client.ts").length).toBeGreaterThan(0);});diff --git a/packages/ui/__tests__/workspace/system-map.test.tsx b/packages/ui/__tests__/workspace/system-map.test.tsxindex c2264a47e..891c7b6da 100644--- a/packages/ui/__tests__/workspace/system-map.test.tsx+++ b/packages/ui/__tests__/workspace/system-map.test.tsx@@ -353,8 +353,8 @@ describe("SystemMapDrawer", () => {contractHref={() => "/c"}/>,);- expect(screen.getByText("web/app/services/overview.py")).toBeInTheDocument();- expect(screen.getByText("with api/src/lib/api/types.ts")).toBeInTheDocument();+ expect(document.body.textContent).toContain("web/app/services/overview.py");+ expect(document.body.textContent).toContain("with api/src/lib/api/types.ts");expect(screen.queryByRole("link", { name: /overview\.py/ })).not.toBeInTheDocument();});diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex 3c822277e..a4cdfc17b 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -127,7 +127,8 @@"./lib/errors": "./src/lib/errors.ts","./lib/fix-history": "./src/lib/fix-history.ts","./lib/format": "./src/lib/format.ts",- "./lib/page-types": "./src/lib/page-types.ts"+ "./lib/page-types": "./src/lib/page-types.ts",+ "./lib/path-parts": "./src/lib/path-parts.ts"},"publishConfig": {"registry": "https://npm.pkg.github.com",diff --git a/packages/ui/src/blast-radius/direct-risks-table.tsx b/packages/ui/src/blast-radius/direct-risks-table.tsxindex 8266b6f72..c234c8b8c 100644--- a/packages/ui/src/blast-radius/direct-risks-table.tsx+++ b/packages/ui/src/blast-radius/direct-risks-table.tsx@@ -3,6 +3,7 @@import type { DirectRiskEntry } from "@repowise-dev/types/blast-radius";import { AskAboutThis } from "../chat/ask-about-this";import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";+import { FilePath } from "../shared/file-path";interface DirectRisksTableProps {rows: DirectRiskEntry[];@@ -42,12 +43,7 @@ const COLUMNS: ResponsiveColumn<DisplayDirectRisk>[] = [header: "File",render: (r) => (<span className="flex min-w-0 items-center gap-1">- <span- className="block max-w-[280px] truncate font-mono text-xs text-[var(--color-text-secondary)]"- title={r.path}- >- {r.path}- </span>+ <FilePath path={r.path} fold className="max-w-[280px] text-[var(--color-text-secondary)]" /><AskAboutThiscontext={{kind: "blast-radius",diff --git a/packages/ui/src/blast-radius/impact-view.tsx b/packages/ui/src/blast-radius/impact-view.tsxindex 3021d0ab4..46c825727 100644--- a/packages/ui/src/blast-radius/impact-view.tsx+++ b/packages/ui/src/blast-radius/impact-view.tsx@@ -11,7 +11,7 @@* and hosted render the same view from one source.*/-import { useCallback, useEffect, useRef, useState } from "react";+import { useCallback, useEffect, useMemo, useRef, useState } from "react";import useSWR from "swr";import { Plus, Flame } from "lucide-react";import type { BlastRadiusResponse } from "@repowise-dev/types/blast-radius";@@ -23,6 +23,8 @@ import { FilePathPicker } from "../health/file-path-picker";import { BlastRadiusResults } from "./blast-radius-results";import type { ImpactAdapter } from "./impact-adapter";import { toFriendlyMessage } from "../lib/errors";+import { disambiguateBasenames } from "../lib/format";+import { FilePath } from "../shared/file-path";export function ImpactView({adapter,@@ -54,6 +56,10 @@ export function ImpactView({() => adapter.listHotspots(8),{ revalidateOnFocus: false },);+ const suggestionLabels = useMemo(+ () => disambiguateBasenames((hotspotSuggestions ?? []).map((h) => h.file_path)),+ [hotspotSuggestions],+ );const addPaths = (paths: string[]) => {setSelected((prev) => {@@ -154,11 +160,15 @@ export function ImpactView({type="button"onClick={() => addPaths([h.file_path])}className="inline-flex items-center gap-1 rounded-full border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-2.5 py-1 text-xs font-mono text-[var(--color-text-secondary)] hover:border-[var(--color-accent-primary)] hover:text-[var(--color-text-primary)] transition-colors"- title={h.file_path}aria-label={`Add ${h.file_path} to changed files`}><Flame className="h-3 w-3 text-[var(--color-warning)]" />- <span className="truncate max-w-[260px]">{h.file_path}</span>+ <FilePath+ path={h.file_path}+ mode="distinguishing"+ labels={suggestionLabels}+ className="max-w-[260px]"+ /><Plus className="h-3 w-3 opacity-60" /></button>))}diff --git a/packages/ui/src/blast-radius/transitive-table.tsx b/packages/ui/src/blast-radius/transitive-table.tsxindex c62573c1c..e77d15a74 100644--- a/packages/ui/src/blast-radius/transitive-table.tsx+++ b/packages/ui/src/blast-radius/transitive-table.tsx@@ -2,6 +2,7 @@import type { TransitiveEntry } from "@repowise-dev/types/blast-radius";import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";+import { FilePath } from "../shared/file-path";interface TransitiveTableProps {rows: TransitiveEntry[];@@ -12,9 +13,7 @@ const COLUMNS: ResponsiveColumn<TransitiveEntry>[] = [key: "path",header: "File",render: (r) => (- <span className="font-mono text-xs break-all" title={r.path}>- {r.path}- </span>+ <FilePath path={r.path} fold className="max-w-[28rem]" />),},{diff --git a/packages/ui/src/dashboard/community-summary-grid.tsx b/packages/ui/src/dashboard/community-summary-grid.tsxindex 633c2018c..82dcdd037 100644--- a/packages/ui/src/dashboard/community-summary-grid.tsx+++ b/packages/ui/src/dashboard/community-summary-grid.tsx@@ -6,7 +6,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";import { Badge } from "../ui/badge";import { ScrollArea } from "../ui/scroll-area";import { Skeleton } from "../ui/skeleton";-import { truncatePath } from "../lib/format";+import { FilePath } from "../shared/file-path";import { fileEntityPath } from "../shared/entity/routes";import { cn } from "../lib/cn";import type {@@ -75,18 +75,12 @@ function DetailPanel({ detail, isLoading, onClose, memberHref }: DetailPanelProp{memberHref ? (<ahref={memberHref(m.path)}- className="text-xs font-mono text-[var(--color-text-secondary)] truncate hover:text-[var(--color-accent-primary)] hover:underline"- title={m.path}+ className="flex min-w-0 text-[var(--color-text-secondary)] hover:text-[var(--color-accent-primary)] hover:underline">- {truncatePath(m.path)}+ <FilePath path={m.path} fold /></a>) : (- <span- className="text-xs font-mono text-[var(--color-text-secondary)] truncate"- title={m.path}- >- {truncatePath(m.path)}- </span>+ <FilePath path={m.path} fold className="text-[var(--color-text-secondary)]" />)}<div className="flex items-center gap-1 shrink-0">{m.is_entry_point && (diff --git a/packages/ui/src/dashboard/health-overview-card.tsx b/packages/ui/src/dashboard/health-overview-card.tsxindex b162cf4d6..a86060c88 100644--- a/packages/ui/src/dashboard/health-overview-card.tsx+++ b/packages/ui/src/dashboard/health-overview-card.tsx@@ -12,7 +12,7 @@ import {import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";import { fileEntityPath } from "../shared/entity/routes";import { AllClearStat } from "../shared/empty-state";-import { truncatePath } from "../lib/format";+import { FilePath } from "../shared/file-path";import { healthBand, SEVERITY_LABEL, SEVERITY_SEGMENT, type Severity } from "../health/tokens";import { ProportionBar } from "../shared/proportion-bar";import { formatScore, type HealthBand } from "@repowise-dev/types/health";@@ -353,9 +353,11 @@ export function HealthOverviewCard({<span className="text-[10px] uppercase tracking-wider text-[var(--color-text-tertiary)] shrink-0">Worst file</span>- <span className="truncate font-mono text-xs text-[var(--color-text-secondary)] group-hover:text-[var(--color-accent-primary)] transition-colors">- {truncatePath(data.worst_performer_path, 40)}- </span>+ <FilePath+ path={data.worst_performer_path}+ fold+ className="text-[var(--color-text-secondary)] transition-colors group-hover:text-[var(--color-accent-primary)]"+ /></span><spanclassName="shrink-0 text-xs font-bold tabular-nums"diff --git a/packages/ui/src/dashboard/hotspots-mini.tsx b/packages/ui/src/dashboard/hotspots-mini.tsxindex 616543647..d49d6becf 100644--- a/packages/ui/src/dashboard/hotspots-mini.tsx+++ b/packages/ui/src/dashboard/hotspots-mini.tsx@@ -1,7 +1,7 @@import { Flame } from "lucide-react";import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";import { EmptyState } from "../shared/empty-state";-import { truncatePath } from "../lib/format";+import { FilePath } from "../shared/file-path";import { fileEntityPath } from "../shared/entity/routes";import type { Hotspot } from "@repowise-dev/types/git";@@ -93,9 +93,7 @@ export function HotspotsMini({</div></div><div className="min-w-0 flex-1">- <p className="text-xs font-mono text-[var(--color-text-primary)] truncate">- {truncatePath(h.file_path, 40)}- </p>+ <FilePath path={h.file_path} fold className="flex text-[var(--color-text-primary)]" /></div><div className="flex items-center gap-2 shrink-0 text-[10px] text-[var(--color-text-tertiary)] tabular-nums"><span>{h.commit_count_90d}c/90d</span>diff --git a/packages/ui/src/dead-code/finding-cells.tsx b/packages/ui/src/dead-code/finding-cells.tsxindex df968978c..a5633bc95 100644--- a/packages/ui/src/dead-code/finding-cells.tsx+++ b/packages/ui/src/dead-code/finding-cells.tsx@@ -10,6 +10,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";import { formatConfidence } from "../lib/format";import { toFriendlyMessage } from "../lib/errors";import { cn } from "../lib/cn";+import { FilePath } from "../shared/file-path";import { PreviewBadge } from "../health/preview-badge";import { RowPromptAction } from "../health/row-prompt-action";import {@@ -97,17 +98,13 @@ export function FindingIdentity({ finding, href, onNavigate, mark }: FindingIden<ahref={href}onClick={onLinkClick}- className="block truncate font-mono text-xs text-[var(--color-text-primary)] hover:text-[var(--color-accent-primary)] hover:underline"- title={finding.file_path}+ className="flex min-w-0 text-[var(--color-text-primary)] hover:text-[var(--color-accent-primary)] hover:underline">- {finding.file_path}+ <FilePath path={finding.file_path} fold /></a>) : (- <span- className="block truncate font-mono text-xs text-[var(--color-text-primary)]"- title={finding.file_path}- >- {finding.file_path}+ <span className="flex min-w-0 text-[var(--color-text-primary)]">+ <FilePath path={finding.file_path} fold /></span>)}{finding.symbol_name && (diff --git a/packages/ui/src/dead-code/safe-to-delete-pile.tsx b/packages/ui/src/dead-code/safe-to-delete-pile.tsxindex 00b367ac5..170905002 100644--- a/packages/ui/src/dead-code/safe-to-delete-pile.tsx+++ b/packages/ui/src/dead-code/safe-to-delete-pile.tsx@@ -5,6 +5,7 @@ import { ArrowRight } from "lucide-react";import { AiPromptButton } from "../health/ai-prompt-button";import { OverviewSection } from "../overview/section";import { cn } from "../lib/cn";+import { FilePath } from "../shared/file-path";import { formatNumber } from "../lib/format";export interface SafeToDeletePileFinding {@@ -109,13 +110,10 @@ export function SafeToDeletePile({onSelect && "hover:bg-[var(--color-bg-elevated)]",)}>- <span- className="min-w-0 truncate font-mono text-xs text-[var(--color-text-primary)]"- title={g.file_path}- >- {g.file_path}+ <span className="flex min-w-0 items-baseline text-[var(--color-text-primary)]">+ <FilePath path={g.file_path} fold />{g.finding_count > 1 && (- <span className="ml-1.5 text-[var(--color-text-tertiary)]">+ <span className="ml-1.5 shrink-0 font-mono text-xs text-[var(--color-text-tertiary)]">({formatNumber(g.finding_count)} findings)</span>)}diff --git a/packages/ui/src/decisions/decision-governance.tsx b/packages/ui/src/decisions/decision-governance.tsxindex 209edbbab..2a14f1570 100644--- a/packages/ui/src/decisions/decision-governance.tsx+++ b/packages/ui/src/decisions/decision-governance.tsx@@ -1,4 +1,5 @@import * as React from "react";+import { FilePath } from "../shared/file-path";import type {DecisionGraph,DecisionGraphNode,@@ -211,14 +212,12 @@ export function GovernedFiles({{fileHref ? (<Linkhref={fileHref(f.path)}- className="font-mono text-xs text-[var(--color-text-secondary)] hover:text-[var(--color-accent-primary)] hover:underline"+ className="flex min-w-0 text-[var(--color-text-secondary)] hover:text-[var(--color-accent-primary)] hover:underline">- {f.path}+ <FilePath path={f.path} fold /></Link>) : (- <span className="font-mono text-xs text-[var(--color-text-secondary)]">- {f.path}- </span>+ <FilePath path={f.path} fold className="text-[var(--color-text-secondary)]" />)}</span>{/* Proportion bar steps the accent down toward the inset grounddiff --git a/packages/ui/src/doc-drift/doc-drift-references.tsx b/packages/ui/src/doc-drift/doc-drift-references.tsxindex ddfc2b835..9be0ae45b 100644--- a/packages/ui/src/doc-drift/doc-drift-references.tsx+++ b/packages/ui/src/doc-drift/doc-drift-references.tsx@@ -18,6 +18,7 @@ import type { DocDriftAdapter } from "./doc-drift-adapter";import { docDriftUnavailableCopy } from "./doc-drift-unavailable";import { groupByDocument } from "./group-by-document";import { RouterAnchor } from "./router-anchor";+import { FilePath } from "../shared/file-path";export interface DocDriftReferencesProps {/** Repo-relative path of the file the page is about. */@@ -82,10 +83,9 @@ export function DocDriftReferences({ target, adapter, driftHref }: DocDriftRefer<RouterAnchorhref={documentHref(group.document)}navigate={navigate}- title={group.document}- className="min-w-0 truncate font-mono text-xs text-[var(--color-text-primary)] transition-colors hover:text-[var(--color-accent-primary)]"+ className="flex min-w-0 text-[var(--color-text-primary)] transition-colors hover:text-[var(--color-accent-primary)]">- {group.document}+ <FilePath path={group.document} /></RouterAnchor>{findings ? (driftHref ? (diff --git a/packages/ui/src/doc-drift/drift-findings-table.tsx b/packages/ui/src/doc-drift/drift-findings-table.tsxindex 88aabe8b9..b8af84021 100644--- a/packages/ui/src/doc-drift/drift-findings-table.tsx+++ b/packages/ui/src/doc-drift/drift-findings-table.tsx@@ -30,6 +30,7 @@ import {type ResponsiveColumn,} from "../shared/responsive-table";import { EmptyState } from "../shared/empty-state";+import { FilePath } from "../shared/file-path";import { AiPromptButton } from "../health/ai-prompt-button";import { groupByDocument } from "./group-by-document";@@ -183,11 +184,8 @@ export function DriftFindingsTable({{groups.map((group) => (<section key={group.document} aria-label={group.document}><header className="flex min-w-0 items-baseline justify-between gap-3 bg-[var(--color-bg-elevated)] px-3 py-2">- <h3- className="min-w-0 truncate font-mono text-xs font-medium text-[var(--color-text-primary)]"- title={group.document}- >- {group.document}+ <h3 className="flex min-w-0 text-xs font-medium text-[var(--color-text-primary)]">+ <FilePath path={group.document} /></h3><span className="shrink-0 text-xs tabular-nums text-[var(--color-text-tertiary)]">{group.items.length}{" "}diff --git a/packages/ui/src/files/file-graph-tab.tsx b/packages/ui/src/files/file-graph-tab.tsxindex 47971869f..48d3c37b2 100644--- a/packages/ui/src/files/file-graph-tab.tsx+++ b/packages/ui/src/files/file-graph-tab.tsx@@ -2,6 +2,7 @@ import type { ElementType } from "react";import { Network } from "lucide-react";import { EmptyState } from "../shared/empty-state";import { truncatePath } from "../lib/format";+import { FilePath } from "../shared/file-path";import type { FileDetailGraph, FileGraphNeighbor } from "@repowise-dev/types/files";import { isExternal, nodeKind } from "@repowise-dev/types";import { FileSection, Fig } from "./file-section";@@ -46,20 +47,24 @@ function NeighborList({const href = isSymbol ? symbolHref(n.node_id) : fileHref(n.node_id);const row = (<>- <span- className={`min-w-0 flex-1 truncate font-mono text-xs ${- isExternalNode- ? "text-[var(--color-text-tertiary)]"- : "text-[var(--color-text-primary)]"- }`}- title={- isExternalNode- ? `${n.node_id} (external dependency, not part of this repo)`- : n.node_id- }- >- {truncatePath(n.node_id, 48)}- </span>+ {isExternalNode || isSymbol ? (+ <span+ className={`min-w-0 flex-1 truncate font-mono text-xs ${+ isExternalNode+ ? "text-[var(--color-text-tertiary)]"+ : "text-[var(--color-text-primary)]"+ }`}+ title={+ isExternalNode+ ? `${n.node_id} (external dependency, not part of this repo)`+ : n.node_id+ }+ >+ {truncatePath(n.node_id, 48)}+ </span>+ ) : (+ <FilePath path={n.node_id} fold className="flex-1 text-[var(--color-text-primary)]" />+ )}<span className="shrink-0 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">{n.edge_type}</span>diff --git a/packages/ui/src/files/file-history-tab.tsx b/packages/ui/src/files/file-history-tab.tsxindex 899331811..564cafe95 100644--- a/packages/ui/src/files/file-history-tab.tsx+++ b/packages/ui/src/files/file-history-tab.tsx@@ -12,8 +12,8 @@ import {formatNumber,formatRelativeTime,ordinal,- truncatePath,} from "../lib/format";+import { FilePath } from "../shared/file-path";import type { FileDetailGit } from "@repowise-dev/types/files";import { FileSection, Fig } from "./file-section";import { FileMark } from "./file-marks";@@ -234,12 +234,7 @@ export function FileHistoryTab({href={partnerHref(p.file_path)}className="-mx-2 flex items-baseline justify-between gap-3 rounded px-2 py-2.5 transition-colors hover:bg-[var(--color-bg-elevated)]">- <span- className="min-w-0 truncate font-mono text-xs text-[var(--color-text-primary)]"- title={p.file_path}- >- {truncatePath(p.file_path, 44)}- </span>+ <FilePath path={p.file_path} fold className="text-[var(--color-text-primary)]" /><span className="shrink-0 font-mono text-[11px] tabular-nums text-[var(--color-text-tertiary)]">{p.co_change_count}×</span>diff --git a/packages/ui/src/files/file-overview-tab.tsx b/packages/ui/src/files/file-overview-tab.tsxindex 42fbaec84..8344962c7 100644--- a/packages/ui/src/files/file-overview-tab.tsx+++ b/packages/ui/src/files/file-overview-tab.tsx@@ -4,6 +4,7 @@ import type { FileDetailResponse } from "@repowise-dev/types/files";import { isExternal, nodeKind } from "@repowise-dev/types";import { EmptyState } from "../shared/empty-state";import { formatLOC, truncatePath } from "../lib/format";+import { FilePath } from "../shared/file-path";import { SYMBOL_FIX_TITLE } from "../git/fix-history-badge";import { FileSection, Fig } from "./file-section";@@ -258,10 +259,10 @@ function NeighborColumn({<li key={id} className="min-w-0"><Ahref={symbol ? symbolHref(id) : fileHref(id)}- className="block truncate font-mono text-xs text-[var(--color-text-secondary)] hover:text-[var(--color-accent-primary)]"- title={id}+ className="flex min-w-0 font-mono text-xs text-[var(--color-text-secondary)] hover:text-[var(--color-accent-primary)]"+ title={symbol ? id : undefined}>- {truncatePath(id, 40)}+ {symbol ? <span className="truncate">{truncatePath(id, 40)}</span> : <FilePath path={id} fold />}</A></li>);diff --git a/packages/ui/src/files/files-table.tsx b/packages/ui/src/files/files-table.tsxindex 9df277f69..bbacb3918 100644--- a/packages/ui/src/files/files-table.tsx+++ b/packages/ui/src/files/files-table.tsx@@ -4,7 +4,8 @@ import { useRef, useState } from "react";import { ArrowDown, ArrowUp, FlaskConical, LogIn } from "lucide-react";import type { FileRow } from "@repowise-dev/types/files";import { cn } from "../lib/cn";-import { formatLOC, truncatePath } from "../lib/format";+import { formatLOC } from "../lib/format";+import { FilePath } from "../shared/file-path";import { healthInk } from "../health/tokens";export type SortKey =@@ -171,8 +172,6 @@ export function FilesTable({ files, fileHref, sortKey, sortDir, onSort }: FilesT<div style={{ height: total * ROW_HEIGHT }} className="relative"><div style={{ transform: `translateY(${start * ROW_HEIGHT}px)` }}>{visible.map((f) => {- const name = f.file_path.split("/").pop() ?? f.file_path;- const dir = f.file_path.slice(0, f.file_path.length - name.length);return (<akey={f.file_path}@@ -191,14 +190,11 @@ export function FilesTable({ files, fileHref, sortKey, sortDir, onSort }: FilesT{f.is_test && (<FlaskConical className="h-3.5 w-3.5 shrink-0 text-[var(--color-text-tertiary)]" />)}- <span className="min-w-0 truncate font-mono text-[13px]">- <span className="text-[var(--color-text-tertiary)]">- {truncatePath(dir, 40)}- </span>- <span className="text-[var(--color-text-primary)] underline-offset-2 group-hover:underline">- {name}- </span>- </span>+ <FilePath+ path={f.file_path}+ fold+ className="text-[13px] text-[var(--color-text-primary)] underline-offset-2 group-hover:underline"+ /></span>{/* Dependents. One decimal, not `Math.round`: the serverdiff --git a/packages/ui/src/git/co-change-list.tsx b/packages/ui/src/git/co-change-list.tsxindex 25afb5515..2552017fe 100644--- a/packages/ui/src/git/co-change-list.tsx+++ b/packages/ui/src/git/co-change-list.tsx@@ -1,7 +1,7 @@"use client";import { useState } from "react";-import { truncatePath } from "../lib/format";+import { FilePath } from "../shared/file-path";interface CoChangeListProps {partners: Array<{ file_path: string; co_change_count: number }>;@@ -28,9 +28,7 @@ export function CoChangeList({ partners, previewCount = 5 }: CoChangeListProps){visible.map((p) => (<div key={p.file_path} className="space-y-0.5"><div className="flex items-center justify-between text-xs">- <span className="font-mono text-[var(--color-text-secondary)] truncate flex-1 min-w-0" title={p.file_path}>- {truncatePath(p.file_path, 45)}- </span>+ <FilePath path={p.file_path} fold className="flex-1 text-[var(--color-text-secondary)]" /><span className="text-[var(--color-text-tertiary)] tabular-nums shrink-0 ml-1">{p.co_change_count}×</span>diff --git a/packages/ui/src/git/hotspot-trend-strip.tsx b/packages/ui/src/git/hotspot-trend-strip.tsxindex 0d2124a4d..de06a6485 100644--- a/packages/ui/src/git/hotspot-trend-strip.tsx+++ b/packages/ui/src/git/hotspot-trend-strip.tsx@@ -3,6 +3,7 @@import * as React from "react";import { TrendingUp, TrendingDown, Minus } from "lucide-react";import { cn } from "../lib/cn";+import { FilePath } from "../shared/file-path";export interface TrendStripHotspot {file_path: string;@@ -82,12 +83,7 @@ export function HotspotTrendStrip({)}><TrendBadge trend={trend} />- <span- className="flex-1 truncate font-mono text-xs text-[var(--color-text-primary)]"- title={h.file_path}- >- {h.file_path}- </span>+ <FilePath path={h.file_path} fold className="flex-1 text-[var(--color-text-primary)]" /><span className="shrink-0 tabular-nums text-[var(--color-text-tertiary)]">{Math.round(h.churn_percentile)}th %ile</span>diff --git a/packages/ui/src/graph/centrality-leaderboard.tsx b/packages/ui/src/graph/centrality-leaderboard.tsxindex 5ea234026..a6aab7b88 100644--- a/packages/ui/src/graph/centrality-leaderboard.tsx+++ b/packages/ui/src/graph/centrality-leaderboard.tsx@@ -4,6 +4,8 @@ import { useState } from "react";import { ChevronLeft, ChevronRight, Crown, Info } from "lucide-react";import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";import { cn } from "../lib/cn";+import { FilePath } from "../shared/file-path";+import { isFileNodeId } from "./node-id";export interface CentralityNode {node_id: string;@@ -46,6 +48,16 @@ function score(node: CentralityNode, metric: "pagerank" | "betweenness" | "degrereturn (node.in_degree ?? 0) + (node.out_degree ?? 0);}+/** A node's label when it has one; a bare file id reads as a path. */+function NodeLabel({ nodeId, label }: { nodeId: string; label?: string | null | undefined }) {+ if (label || !isFileNodeId(nodeId)) {+ return (+ <p className="text-xs font-mono text-[var(--color-text-primary)] truncate">{label ?? nodeId}</p>+ );+ }+ return <FilePath path={nodeId} fold className="flex text-[var(--color-text-primary)]" />;+}+export function CentralityLeaderboard({nodes,metric: initialMetric = "pagerank",@@ -149,9 +161,7 @@ export function CentralityLeaderboard({{i + 1}</span><div className="min-w-0 flex-1">- <p className="text-xs font-mono text-[var(--color-text-primary)] truncate">- {n.label ?? n.node_id}- </p>+ <NodeLabel nodeId={n.node_id} label={n.label} /><div className="mt-0.5 h-1 rounded-full bg-[var(--color-bg-inset)] overflow-hidden"><divclassName="h-full bg-[var(--color-accent-primary)]"diff --git a/packages/ui/src/graph/node-id.ts b/packages/ui/src/graph/node-id.tsnew file mode 100644index 000000000..527027618--- /dev/null+++ b/packages/ui/src/graph/node-id.ts@@ -0,0 +1,6 @@+import { nodeKind } from "@repowise-dev/types";++/** A bare graph node id that names a repository file: no `::symbol`, no `external:` style prefix. */+export function isFileNodeId(id: string): boolean {+ return nodeKind(id) === "path";+}diff --git a/packages/ui/src/graph/path-finder-panel.tsx b/packages/ui/src/graph/path-finder-panel.tsxindex 0091a34e4..765b498f9 100644--- a/packages/ui/src/graph/path-finder-panel.tsx+++ b/packages/ui/src/graph/path-finder-panel.tsx@@ -1,10 +1,13 @@"use client";-import { useState, useEffect, useRef, useCallback } from "react";+import { useState, useEffect, useRef, useCallback, useMemo } from "react";import { Route, X, ArrowRight, Search, ChevronDown } from "lucide-react";import { Spinner } from "../ui/spinner";import { Button } from "../ui/button";import { useDebounce } from "../hooks/use-debounce";+import { disambiguateBasenames } from "../lib/format";+import { FilePath } from "../shared/file-path";+import { isFileNodeId } from "./node-id";import type { GraphPath, NodeSearchResult } from "@repowise-dev/types/graph";export interface PathFinderPanelProps {@@ -109,9 +112,11 @@ function NodeAutocomplete({className="w-full px-3 py-1.5 text-left text-xs hover:bg-[var(--color-bg-elevated)] transition-colors flex items-center gap-2"onMouseDown={() => handleSelect(r.node_id)}>- <span className="font-mono text-[var(--color-text-primary)] truncate flex-1">- {r.node_id}- </span>+ {isFileNodeId(r.node_id) ? (+ <FilePath path={r.node_id} fold className="flex-1 text-[var(--color-text-primary)]" />+ ) : (+ <span className="flex-1 truncate font-mono text-[var(--color-text-primary)]">{r.node_id}</span>+ )}<span className="text-[10px] text-[var(--color-text-tertiary)] capitalize shrink-0 tabular-nums">{r.language}</span>@@ -136,6 +141,7 @@ export function PathFinderPanel({const [to, setTo] = useState(initialTo);const [loading, setLoading] = useState(false);const [result, setResult] = useState<GraphPath | null>(null);+ const hopLabels = useMemo(() => disambiguateBasenames(result?.path ?? []), [result]);const [error, setError] = useState<string | null>(null);// Sync initial values when they change from context menu@@ -254,18 +260,26 @@ export function PathFinderPanel({</p><div className="space-y-0.5 max-h-28 overflow-auto">{result.path.map((nodeName, i) => {- const shortName = nodeName.split("/").pop() ?? nodeName;return (<div key={i} className="flex items-center gap-1">{i > 0 && (<ArrowRight className="w-2.5 h-2.5 text-[var(--color-accent-graph)] shrink-0" />)}- <span- className="text-[10px] font-mono text-[var(--color-text-secondary)] truncate"- title={nodeName}- >- {shortName}- </span>+ {isFileNodeId(nodeName) ? (+ <FilePath+ path={nodeName}+ mode="distinguishing"+ labels={hopLabels}+ className="text-[10px] text-[var(--color-text-secondary)]"+ />+ ) : (+ <span+ className="truncate font-mono text-[10px] text-[var(--color-text-secondary)]"+ title={nodeName}+ >+ {nodeName}+ </span>+ )}</div>);})}diff --git a/packages/ui/src/health/refactoring-card.tsx b/packages/ui/src/health/refactoring-card.tsxindex 0ee1ce5b8..fa126ae15 100644--- a/packages/ui/src/health/refactoring-card.tsx+++ b/packages/ui/src/health/refactoring-card.tsx@@ -3,6 +3,7 @@import { useState } from "react";import { ArrowUpRight, ChevronDown, ChevronRight, Sparkles } from "lucide-react";import { InfoTip } from "../shared/info-tip";+import { FilePath } from "../shared/file-path";import {biomarkerInfo,biomarkerLabel,@@ -240,10 +241,10 @@ export function HealthWorkItemCard({disabled={!onSelect}title={onSelect ? "Open file health drawer" : undefined}>- <p className="min-w-0 flex-1 text-sm font-mono text-[var(--color-text-primary)] truncate group-hover/file:text-[var(--color-accent-primary)]">- {target.file_path}+ <p className="flex min-w-0 flex-1 items-baseline font-mono text-sm text-[var(--color-text-primary)] group-hover/file:text-[var(--color-accent-primary)]">+ <FilePath path={target.file_path} fold className="text-sm" />{target.primary_function ? (- <span className="text-[var(--color-text-secondary)]">+ <span className="min-w-0 truncate whitespace-pre text-[var(--color-text-secondary)]">{" :: "}{target.primary_function}</span>diff --git a/packages/ui/src/health/untested-hotspot-warning.tsx b/packages/ui/src/health/untested-hotspot-warning.tsxindex cd65b8b63..252aa369c 100644--- a/packages/ui/src/health/untested-hotspot-warning.tsx+++ b/packages/ui/src/health/untested-hotspot-warning.tsx@@ -1,6 +1,7 @@import { ArrowUpRight } from "lucide-react";import { coverageBand } from "./tokens";+import { FilePath } from "../shared/file-path";import { RowPromptAction } from "./row-prompt-action";import { AGENT_PROMPT_LABEL } from "./ai-prompt-action";@@ -48,9 +49,7 @@ export function UntestedHotspotWarning({{shown.map((e) => {const body = (<>- <span className="min-w-0 flex-1 truncate font-mono text-xs text-[var(--color-text-primary)]">- {e.file_path}- </span>+ <FilePath path={e.file_path} fold className="flex-1 text-[var(--color-text-primary)]" /><span className="shrink-0 tabular-nums text-xs text-[var(--color-text-tertiary)]">{e.dependents_count != null && `${e.dependents_count} dependents`}{e.dependents_count != null &&diff --git a/packages/ui/src/lib/format.ts b/packages/ui/src/lib/format.tsindex 3a13ebda4..334cb1423 100644--- a/packages/ui/src/lib/format.ts+++ b/packages/ui/src/lib/format.ts@@ -132,7 +132,14 @@ export function formatLOC(n: number): string {return String(n);}-/** Truncate a file path keeping as many trailing components as fit: src/very/long/path/file.py → …/long/path/file.py */+/**+ * Truncate a file path keeping as many trailing components as fit:+ * src/very/long/path/file.py → …/long/path/file.py+ *+ * @deprecated Render paths with `<FilePath>` (`shared/file-path`), which clips+ * by the box width and keeps the full path in the tooltip and accessible name.+ * Kept for plain-string contexts and existing callers.+ */export function truncatePath(path: string, maxChars = 60): string {if (path.length <= maxChars) return path;const parts = path.split("/");@@ -153,7 +160,7 @@ export function truncatePath(path: string, maxChars = 60): string {* basename is already unique keeps it. Each path grows by one trailing segment* per round until it is unique or has no segments left.*- * Prefer {@link truncatePath} for a path shown on its own; this is for many+ * Prefer `<FilePath>` for a path shown on its own; this is for many* paths displayed side by side, where a bare basename can be ambiguous.*/export function disambiguateBasenames(paths: Iterable<string>): Map<string, string> {diff --git a/packages/ui/src/lib/path-parts.ts b/packages/ui/src/lib/path-parts.tsnew file mode 100644index 000000000..340512529--- /dev/null+++ b/packages/ui/src/lib/path-parts.ts@@ -0,0 +1,76 @@+/**+ * Pure derivations behind `<FilePath>`: where a repository path splits into+ * directory and file name, and how its monorepo prefix folds for display.+ * Display only: callers always keep the original path for links, keys and+ * the accessible name.+ */++export interface PathParts {+ /** Directory without its trailing slash; empty for a top-level file. */+ dir: string;+ name: string;+}++export function splitPath(path: string): PathParts {+ const cut = path.lastIndexOf("/");+ return cut < 0 ? { dir: "", name: path } : { dir: path.slice(0, cut), name: path.slice(cut + 1) };+}++/** Top-level directories whose next segment names a workspace package. */+const PACKAGE_ROOTS = new Set(["packages", "apps", "libs", "services", "crates"]);++export interface FoldedPath {+ /** The workspace package (`server` for `packages/server/...`), or null when nothing folded. */+ pkg: string | null;+ /** What remains to print after the package chip. */+ rest: string;+}++/** `api-client` and `api_client` name the same package. */+function samePackage(segment: string, pkg: string): boolean {+ const norm = (s: string) => s.toLowerCase().replace(/[-_]/g, "");+ return norm(segment) === norm(pkg);+}++/**+ * `packages/server/src/repowise/server/mcp/tool.py` reads as package `server`+ * plus `mcp/tool.py`: the root, `src/`, and a namespace that repeats the+ * package name (`repowise/server/` or `server/`) say nothing the chip does+ * not. The file name always survives.+ */+export function foldPackagePrefix(path: string): FoldedPath {+ const segments = path.split("/");+ const pkg = segments[1];+ if (segments.length < 3 || !PACKAGE_ROOTS.has(segments[0] ?? "") || !pkg) {+ return { pkg: null, rest: path };+ }+ const inPackage = segments.slice(2);+ const rest = inPackage.length > 1 && inPackage[0] === "src" ? inPackage.slice(1) : inPackage;+ return { pkg, rest: dropRepeatedNamespace(rest, pkg).join("/") };+}++/** `server/x` or `repowise/server/x` under package `server` is just `x`; the name always stays. */+function dropRepeatedNamespace(rest: string[], pkg: string): string[] {+ if (rest.length > 1 && samePackage(rest[0] ?? "", pkg)) return rest.slice(1);+ if (rest.length > 2 && samePackage(rest[1] ?? "", pkg)) return rest.slice(2);+ return rest;+}++/**+ * A directory split for a middle ellipsis: the head clips, the last `keep`+ * segments stay, since the nearest folder is the one a reader recognises.+ */+export function splitDirTail(dir: string, keep = 1): { head: string; tail: string } {+ if (!dir) return { head: "", tail: "" };+ const segments = dir.split("/");+ if (segments.length <= keep) return { head: "", tail: dir };+ return {+ head: segments.slice(0, -keep).join("/"),+ tail: segments.slice(-keep).join("/"),+ };+}++/** `path:line` (or `path:12-40`) as tooltips and assistive tech read it. */+export function pathWithLine(path: string, line?: number | string | null): string {+ return line == null || line === "" ? path : `${path}:${line}`;+}diff --git a/packages/ui/src/onboarding/first-five-files.tsx b/packages/ui/src/onboarding/first-five-files.tsxindex 4cfa90028..2f640789f 100644--- a/packages/ui/src/onboarding/first-five-files.tsx+++ b/packages/ui/src/onboarding/first-five-files.tsx@@ -4,6 +4,7 @@ import { useState } from "react";import { Sparkles, ArrowUpRight, ChevronDown, ChevronRight } from "lucide-react";import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";import { Badge } from "../ui/badge";+import { FilePath } from "../shared/file-path";export interface FirstFiveFile {file_path: string;@@ -92,9 +93,7 @@ export function FirstFiveFiles({<li key={f.file_path}><Wrapper><span className="text-xs tabular-nums text-[var(--color-text-tertiary)]">{i + 1}</span>- <p className="font-mono text-xs text-[var(--color-text-primary)] truncate min-w-0 flex-1">- {f.file_path}- </p>+ <FilePath path={f.file_path} fold className="flex-1 text-[var(--color-text-primary)]" />{f.is_entry_point && <Badge variant="accent" className="h-4 text-[10px] shrink-0">entry</Badge>}{f.has_doc && <Badge variant="outline" className="h-4 text-[10px] shrink-0">doc</Badge>}{href && (diff --git a/packages/ui/src/refactoring/opportunity-drawer.tsx b/packages/ui/src/refactoring/opportunity-drawer.tsxindex f09155dc3..96ac9aff8 100644--- a/packages/ui/src/refactoring/opportunity-drawer.tsx+++ b/packages/ui/src/refactoring/opportunity-drawer.tsx@@ -30,7 +30,8 @@ import { Layers, Sparkles, Terminal } from "lucide-react";import { Sheet, SheetContent, SheetTitle } from "../ui/sheet";import { Skeleton, SkeletonRegion } from "../ui/skeleton";import { CollapsibleSection } from "../shared/collapsible-section";-import { formatNumber } from "../lib/format";+import { disambiguateBasenames, formatNumber } from "../lib/format";+import { FilePath } from "../shared/file-path";import { ValidationSummary } from "./validation-summary";import { CONFIDENCE_LABEL, EFFORT_LABEL, typeMeta } from "./meta";import { CodeBlock } from "./plan-detail";@@ -212,6 +213,10 @@ function DrawerBody({);const name = detail.file_path.split("/").pop() ?? detail.file_path;const others = detail.affected_files.filter((f) => f !== detail.file_path);+ const otherLabels = React.useMemo(+ () => disambiguateBasenames(detail.affected_files),+ [detail.affected_files],+ );// The opportunity resolved but its steps did not load. Everything else in the// drawer, triage included, still describes a real opportunity.const stepsUnavailable = detail.details_status === "unavailable";@@ -266,9 +271,12 @@ function DrawerBody({<SheetTitle className="mt-0.5 break-words font-mono text-sm font-semibold text-[var(--color-text-primary)]">{name}</SheetTitle>- <p className="mt-1 break-all font-mono text-xs text-[var(--color-text-tertiary)]">- {detail.file_path}- </p>+ <FilePath+ path={detail.file_path}+ mode="full"+ copyable+ className="mt-1 block text-[var(--color-text-tertiary)]"+ /></div><div className="flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-[var(--color-border-default)] px-5 py-2.5 text-xs text-[var(--color-text-secondary)]">@@ -468,13 +476,13 @@ function DrawerBody({{href ? (<ahref={href}- className="break-all font-mono text-xs text-[var(--color-text-secondary)] underline-offset-2 hover:text-[var(--color-accent-primary)] hover:underline"+ className="flex min-w-0 text-[var(--color-text-secondary)] underline-offset-2 hover:text-[var(--color-accent-primary)] hover:underline">- {f}+ <FilePath path={f} mode="distinguishing" labels={otherLabels} /></a>) : (- <span className="break-all font-mono text-xs text-[var(--color-text-secondary)]">- {f}+ <span className="flex min-w-0 text-[var(--color-text-secondary)]">+ <FilePath path={f} mode="distinguishing" labels={otherLabels} /></span>)}</li>@@ -586,17 +594,13 @@ function StepCard({{step.target_symbol || meta.label}</button>- <p className="mt-0.5 break-all font-mono text-xs text-[var(--color-text-tertiary)]">+ <p className="mt-0.5 text-[var(--color-text-tertiary)]">{href ? (<a href={href} className="underline-offset-2 hover:underline">- {step.file_path}- {span ? `:${span}` : ""}+ <FilePath path={step.file_path} line={span || null} mode="full" /></a>) : (- <>- {step.file_path}- {span ? `:${span}` : ""}- </>+ <FilePath path={step.file_path} line={span || null} mode="full" />)}</p>diff --git a/packages/ui/src/refactoring/opportunity-rows.tsx b/packages/ui/src/refactoring/opportunity-rows.tsxindex 2fd16c9ec..29ce110b9 100644--- a/packages/ui/src/refactoring/opportunity-rows.tsx+++ b/packages/ui/src/refactoring/opportunity-rows.tsx@@ -25,6 +25,7 @@import * as React from "react";import { formatNumber } from "../lib/format";+import { FilePath } from "../shared/file-path";import { typeMeta } from "./meta";import { PreviewBadge } from "../health/preview-badge";import {@@ -148,7 +149,6 @@ function OpportunityRow({const effort = EFFORT_WORD[opportunity.effort_bucket] ?? opportunity.effort_bucket;const href = fileHref?.(opportunity.file_path);const gain = opportunity.recoverable_health;- const name = opportunity.file_path.split("/").pop() ?? opportunity.file_path;// Optimistic, with the server's answer as the authority. A triage click that// waits for a round trip reads as a dead control on a list this long.@@ -204,14 +204,13 @@ function OpportunityRow({onBlur={() => onHighlight?.(null)}className="group order-1 col-span-2 min-w-0 text-left lg:order-none lg:col-span-1">- <span className="block break-words font-mono text-sm font-medium text-[var(--color-text-primary)] group-hover:text-[var(--color-accent-primary)]">- {name}- </span>- {/* Full path, no ellipsis: a truncated title reports a layout decision- to the reader as missing content. */}- <span className="mt-0.5 block break-all font-mono text-xs text-[var(--color-text-tertiary)]">- {opportunity.file_path}- </span>+ {/* One line: the file name never clips, the directory gives way+ first, and the tooltip carries the whole path. */}+ <FilePath+ path={opportunity.file_path}+ fold+ className="flex text-sm text-[var(--color-text-primary)] group-hover:text-[var(--color-accent-primary)]"+ /><span className="mt-1 block text-xs text-[var(--color-text-secondary)]">{opportunityLede(opportunity)}</span>diff --git a/packages/ui/src/refactoring/plan-before.tsx b/packages/ui/src/refactoring/plan-before.tsxindex de1e84036..5b1d69b7c 100644--- a/packages/ui/src/refactoring/plan-before.tsx+++ b/packages/ui/src/refactoring/plan-before.tsx@@ -12,20 +12,14 @@ import {} from "./types";import type { RefactoringPlan } from "@repowise-dev/types/refactoring";import { ExtractMethodBefore } from "./extract-method-before";+import { splitPath } from "../lib/path-parts";+import { FilePath } from "../shared/file-path";export interface PlanBeforeProps {plan: RefactoringPlan;}-function shortFile(path: string): string {- const parts = path.split("/");- return parts.length <= 2 ? path : `…/${parts.slice(-2).join("/")}`;-}--function baseName(path: string): string {- const parts = path.split("/");- return parts[parts.length - 1] ?? path;-}+const baseName = (path: string): string => splitPath(path).name;/*** The "before" half of the before→after comparison: a synthesized picture of@@ -61,10 +55,12 @@ export function PlanBefore({ plan }: PlanBeforeProps) {key={`${location.file_path}:${location.line_start ?? index}`}className="border-t border-[var(--color-border-default)] py-2">- <code className="break-all text-2xs text-[var(--color-text-secondary)]">- {location.file_path}- {location.line_start ? `:${location.line_start}` : ""}- </code>+ <FilePath+ path={location.file_path}+ line={location.line_start || null}+ mode="full"+ className="text-2xs text-[var(--color-text-secondary)]"+ /></div>))}{detail.affectedLocationsTotal > shown.length ? (@@ -142,9 +138,7 @@ export function PlanBefore({ plan }: PlanBeforeProps) {key={i}className="flex items-center justify-between gap-3 rounded-lg border border-dashed border-[var(--color-border-default)] bg-[var(--color-bg-surface)] px-3 py-2">- <code className="truncate text-2xs text-[var(--color-text-secondary)]" title={o.file}>- {shortFile(o.file)}- </code>+ <FilePath path={o.file} className="text-2xs text-[var(--color-text-secondary)]" /><span className="shrink-0 text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">duplicate</span>diff --git a/packages/ui/src/refactoring/plan-detail.tsx b/packages/ui/src/refactoring/plan-detail.tsxindex fcb3b88f0..21ff3078c 100644--- a/packages/ui/src/refactoring/plan-detail.tsx+++ b/packages/ui/src/refactoring/plan-detail.tsx@@ -3,6 +3,7 @@import { ArrowRight, CornerDownRight, FilePlus2, Layers, Scissors } from "lucide-react";import { getLanguageFromPath } from "../c4/panels/CodeViewer";import { HighlightedCodeBlock } from "../shared/code-block";+import { FilePath, type FilePathMode } from "../shared/file-path";import { PlaceholderHint } from "./placeholder-hint";import { ProvenancePathList } from "../shared/provenance-path-list";import {@@ -49,25 +50,32 @@ function FileRef({line,fileHref,label,+ mode = "name-first",className = "",}: {path: string;line?: number | null;fileHref?: PlanDetailProps["fileHref"];+ /** A symbol to print instead of the path, which then rides on `title`. */label?: string;- /** Extra classes, e.g. `block truncate` inside a `min-w-0` flex item. */+ mode?: FilePathMode;+ /** Extra classes, e.g. `flex` to let a name-first path clip in its column. */className?: string;}) {- const inner = (+ const inner = label ? (<>- {label ?? shortFile(path)}+ {label}{line ? <span className="text-[var(--color-text-tertiary)]">:{line}</span> : null}</>+ ) : (+ <FilePath path={path} line={line} mode={mode} />);+ const base = `min-w-0 font-mono text-xs text-[var(--color-text-secondary)] ${className}`;+ const title = label ? path : undefined;const href = fileHref?.(path, line ?? null);if (!href) {return (- <span className={`font-mono text-xs text-[var(--color-text-secondary)] ${className}`} title={path}>+ <span className={base} title={title}>{inner}</span>);@@ -75,8 +83,8 @@ function FileRef({return (<ahref={href}- className={`font-mono text-xs text-[var(--color-text-secondary)] underline-offset-2 hover:text-[var(--color-accent-primary)] hover:underline ${className}`}- title={path}+ className={`${base} underline-offset-2 hover:text-[var(--color-accent-primary)] hover:underline`}+ title={title}>{inner}</a>@@ -176,7 +184,7 @@ function StagedExtract({path={plan.file_path}line={stage.span.start}fileHref={fileHref}- className="min-w-0 break-all"+ mode="full"/><span className="ml-auto whitespace-nowrap font-mono text-[var(--color-text-secondary)]">lines {stage.span.start}–{stage.span.end}@@ -276,7 +284,7 @@ function ReuseDetail({path={s.file}line={s.span.start || null}fileHref={fileHref}- className="block truncate"+ className="flex"/></span><span className="shrink-0 text-2xs tabular-nums text-[var(--color-text-tertiary)]">@@ -355,7 +363,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProppath={location.file_path}line={location.line_start ?? null}fileHref={fileHref}- className="break-all"+ mode="full"/></li>))}@@ -518,7 +526,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProppath={o.file}line={o.line_start}fileHref={fileHref}- className="block truncate"+ className="flex"/></span><span className="flex shrink-0 items-center gap-2">@@ -602,9 +610,9 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp{edges.map((e, i) => (<div key={i} className="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs"><Scissors className="h-3.5 w-3.5 shrink-0" style={{ color: accent }} />- <FileRef path={e.from} fileHref={fileHref} className="min-w-0 truncate" />+ <FileRef path={e.from} fileHref={fileHref} className="flex" /><ArrowRight className="h-3.5 w-3.5 shrink-0 text-[var(--color-text-tertiary)]" />- <FileRef path={e.to} fileHref={fileHref} className="min-w-0 truncate" />+ <FileRef path={e.to} fileHref={fileHref} className="flex" /></div>))}{members.length > 0 ? (@@ -654,7 +662,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProppath={plan.file_path}line={em.span.start}fileHref={fileHref}- className="block truncate"+ className="flex"/></div><span className="ml-auto shrink-0 font-mono text-xs text-[var(--color-text-secondary)]">@@ -766,7 +774,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp{g.suggested_file ? (<div className="mb-2 flex items-center gap-1.5"><FilePlus2 className="h-3 w-3 shrink-0 text-[var(--color-text-tertiary)]" />- <FileRef path={g.suggested_file} fileHref={fileHref} className="min-w-0 truncate" />+ <FileRef path={g.suggested_file} fileHref={fileHref} className="flex" /></div>) : null}<ul className="space-y-0.5">@@ -818,7 +826,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp<ul className="space-y-1">{shownDeps.map((f) => (<li key={f}>- <FileRef path={f} fileHref={fileHref} className="block truncate" />+ <FileRef path={f} fileHref={fileHref} className="flex" /></li>))}{blast.dependent_files.length > shownDeps.length ? (diff --git a/packages/ui/src/refactoring/refactoring-drawer.tsx b/packages/ui/src/refactoring/refactoring-drawer.tsxindex 4bccd2bd0..6c4000941 100644--- a/packages/ui/src/refactoring/refactoring-drawer.tsx+++ b/packages/ui/src/refactoring/refactoring-drawer.tsx@@ -25,7 +25,8 @@ import { Layers, Sparkles, TrendingUp, Wand2 } from "lucide-react";import { CollapsibleSection } from "../shared/collapsible-section";import { Sheet, SheetContent, SheetTitle } from "../ui/sheet";import { Skeleton, SkeletonRegion } from "../ui/skeleton";-import { formatNumber } from "../lib/format";+import { disambiguateBasenames, formatNumber } from "../lib/format";+import { FilePath } from "../shared/file-path";import { PlanComparison } from "./plan-comparison";import { GenerateCodePanel } from "./generate-code-panel";import { RefactoringModelToggle, type RefactoringModelToggleProps } from "./refactoring-settings-card";@@ -140,6 +141,11 @@ function DrawerBody({const wins = planWins(plan);const blast = blastFiles(plan).filter((f) => f !== plan.file_path);const blastN = blastCount(plan);+ const blastLabels = disambiguateBasenames(blast);+ const lines =+ plan.line_start && plan.line_end+ ? `${plan.line_start}–${plan.line_end}`+ : plan.line_start || null;const name = plan.file_path.split("/").pop() ?? plan.file_path;// One line of words, in the order a reader asks: how big, how sure, how far,@@ -157,11 +163,13 @@ function DrawerBody({<SheetTitle className="mt-0.5 break-words font-mono text-[15px] font-semibold text-[var(--color-text-primary)]">{plan.target_symbol || name}</SheetTitle>- <p className="mt-1 break-all font-mono text-[11.5px] text-[var(--color-text-tertiary)]">- {plan.file_path}- {plan.line_start ? `:${plan.line_start}` : ""}- {plan.line_start && plan.line_end ? `–${plan.line_end}` : ""}- </p>+ <FilePath+ path={plan.file_path}+ line={lines}+ mode="full"+ copyable+ className="mt-1 block text-[11.5px] text-[var(--color-text-tertiary)]"+ /></div><div className="flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-[var(--color-border-default)] px-5 py-2.5 text-[12.5px] text-[var(--color-text-secondary)]">@@ -299,13 +307,13 @@ function DrawerBody({{href ? (<ahref={href}- className="break-all font-mono text-xs text-[var(--color-text-secondary)] underline-offset-2 hover:text-[var(--color-accent-primary)] hover:underline"+ className="flex min-w-0 text-[var(--color-text-secondary)] underline-offset-2 hover:text-[var(--color-accent-primary)] hover:underline">- {f}+ <FilePath path={f} mode="distinguishing" labels={blastLabels} /></a>) : (- <span className="break-all font-mono text-xs text-[var(--color-text-secondary)]">- {f}+ <span className="flex min-w-0 text-[var(--color-text-secondary)]">+ <FilePath path={f} mode="distinguishing" labels={blastLabels} /></span>)}</li>diff --git a/packages/ui/src/refactoring/start-here.tsx b/packages/ui/src/refactoring/start-here.tsxindex 1d93bb753..6561d136a 100644--- a/packages/ui/src/refactoring/start-here.tsx+++ b/packages/ui/src/refactoring/start-here.tsx@@ -24,6 +24,8 @@import * as React from "react";import { formatNumber } from "../lib/format";+import { splitPath } from "../lib/path-parts";+import { FilePath } from "../shared/file-path";import { EFFORT_LABEL } from "../health/labels";import { StructuralMap } from "./structural-map";import { typeMeta } from "./meta";@@ -137,13 +139,16 @@ export function StartHere({</span><span className="min-w-0"><span className="block text-sm font-semibold text-[var(--color-text-primary)] group-hover:text-[var(--color-accent-primary)]">- {meta.label} · {item.file_path.split("/").pop()}- </span>- {/* Full path, no ellipsis: a truncated title reports a layout- decision to the reader as missing content. */}- <span className="mt-0.5 block break-all font-mono text-xs text-[var(--color-text-tertiary)]">- {item.file_path}+ {meta.label} · {splitPath(item.file_path).name}</span>+ {/* One line under the title, which already names the file:+ the directory clips in the middle, the tooltip has it all. */}+ <FilePath+ path={item.file_path}+ mode="middle-ellipsis"+ fold+ className="mt-0.5 flex text-[var(--color-text-tertiary)]"+ /><span className="mt-1.5 block max-w-[70ch] text-sm text-[var(--color-text-secondary)]">{stepSummary(item)} ·{" "}{addressesPrimaryShort(item.addresses_primary_problem).toLowerCase()}diff --git a/packages/ui/src/security/findings-table.tsx b/packages/ui/src/security/findings-table.tsxindex 5693fed48..c510c05af 100644--- a/packages/ui/src/security/findings-table.tsx+++ b/packages/ui/src/security/findings-table.tsx@@ -1,6 +1,5 @@"use client";-import * as React from "react";import { useMemo, useState } from "react";import { Search } from "lucide-react";import { Input } from "../ui/input";@@ -13,6 +12,7 @@ import { AGENT_PROMPT_LABEL } from "../health/ai-prompt-action";import { SeverityMark } from "../health/severity-mark";import type { Severity } from "../health/tokens";import { formatDate, formatDateTime, formatRelativeTimeOrNull } from "../lib/format";+import { FilePath } from "../shared/file-path";import { securityLevel, securityPathClass, type SecurityLevel } from "./posture";import type { SecurityFinding } from "@repowise-dev/types";@@ -21,26 +21,6 @@ import type { SecurityFinding } from "@repowise-dev/types";// line number went unrendered.export type { SecurityFinding };-// Break only at path separators; `anywhere` is the last resort for a single-// segment wider than the box.-function BreakablePath({ path }: { path: string }) {- const parts = path.split("/");- return (- <>- {parts.map((part, i) => (- <React.Fragment key={i}>- {part}- {i < parts.length - 1 && (- <>- /<wbr />- </>- )}- </React.Fragment>- ))}- </>- );-}-// The scanner's `med` is the shared scale's `medium`. No level maps to// critical: a pattern match is a lead to confirm, not a proven path to harm.const MARK: Record<SecurityLevel, Severity> = { high: "high", med: "medium", low: "low" };@@ -64,7 +44,7 @@ const FILTERS: { value: SeverityFilter; label: string }[] = [* flagged code has moved away entirely. A wrong line here sends the reader to* innocent code looking authoritative, which is worse than showing none.*- * The path is the row's name, so it wraps rather than truncates.+ * The path is the row's name: its file name never clips.*/function FindingLocation({ finding }: { finding: SecurityFinding }) {const line = finding.line_number;@@ -76,45 +56,25 @@ function FindingLocation({ finding }: { finding: SecurityFinding }) {<span className="ml-1.5 font-sans text-2xs text-[var(--color-text-tertiary)]">{where}</span>);- // Every state carries words, not just a colour and a tooltip: `title` is- // invisible to touch and to assistive tech, which is why VerificationBadge- // keeps an sr-only label beside its icon. Same convention here.- if (line == null) {- return (- <span- className="block min-w-[14rem] [overflow-wrap:anywhere] font-mono text-xs text-[var(--color-text-primary)]"- title={`${finding.file_path}: the flagged code is no longer at the recorded line`}- >- <BreakablePath path={finding.file_path} />- <span className="ml-1.5 not-italic text-2xs text-[var(--color-text-tertiary)]">- (line moved)- </span>- {tag}- </span>- );- }-+ // Every state carries words, not just a colour: a line the server could+ // not confirm is marked `~` and named, and a line that moved away is named.+ // The file name leads; the directory clips before it, and the tooltip and+ // accessible name keep the whole `path:line`.+ const note = line == null ? "line moved" : verified ? null : "unconfirmed";return (- <span- className="block min-w-[14rem] [overflow-wrap:anywhere] font-mono text-xs text-[var(--color-text-primary)]"- title={- verified- ? `${finding.file_path}:${line}`- : `${finding.file_path}:${line}: could not be confirmed against the current file`- }- >- <BreakablePath path={finding.file_path} />- <wbr />- <span- className={- verified ? "text-[var(--color-text-secondary)]" : "text-[var(--color-text-tertiary)]"- }- >- :{verified ? "" : "~"}- {line}- </span>- {!verified && <span className="sr-only"> (line unconfirmed)</span>}- {tag}+ <span className="flex min-w-[14rem] max-w-[28rem] items-baseline text-[var(--color-text-primary)]">+ <FilePath+ path={finding.file_path}+ line={line == null ? null : verified ? line : `~${line}`}+ fold+ className="min-w-0"+ />+ {note ? (+ <span className="ml-1.5 shrink-0 font-sans text-2xs text-[var(--color-text-tertiary)]">+ ({note})+ </span>+ ) : null}+ {tag ? <span className="shrink-0">{tag}</span> : null}</span>);}diff --git a/packages/ui/src/shared/file-path.tsx b/packages/ui/src/shared/file-path.tsxnew file mode 100644index 000000000..ed30daf9d--- /dev/null+++ b/packages/ui/src/shared/file-path.tsx@@ -0,0 +1,355 @@+"use client";++/**+ * One way to print a repository path. The file name is what a reader+ * recognises, so no mode ever cuts it; the directory gives way first.+ *+ * - `name-first` (lists, tables): name, then the dim directory, which clips+ * in the middle so its first and last folders stay.+ * - `distinguishing` (compact sets of siblings): the shortest suffix that+ * tells the set apart, from {@link disambiguateBasenames} computed once by+ * the caller and passed as `labels`.+ * - `full` (drawers, headers): every segment, wrapping only after a slash.+ * - `middle-ellipsis` (one-line inline mentions): the path in reading order,+ * clipped in the middle by the box width, never by a character count.+ *+ * Abbreviated modes keep the whole path (and `:line`) as the accessible name+ * and in a tooltip that opens on hover and on keyboard focus of the link,+ * button or row that holds it. Strings are English props so+ * every host app can translate them.+ */++import * as React from "react";+import { useCallback, useEffect, useRef, useState } from "react";+import { Check, Copy } from "lucide-react";+import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip";+import { cn } from "../lib/cn";+import { foldPackagePrefix, pathWithLine, splitDirTail, splitPath } from "../lib/path-parts";++const TOOLTIP_DELAY_MS = 300;++export type FilePathMode = "name-first" | "distinguishing" | "full" | "middle-ellipsis";++export interface FilePathProps {+ path: string;+ mode?: FilePathMode;+ /** A line (`42`) or range (`12-40`) printed after the name. */+ line?: number | string | null | undefined;+ /** `distinguishing` only: labels from `disambiguateBasenames(siblings)`, computed once per set. */+ labels?: ReadonlyMap<string, string> | undefined;+ /** Print `packages/<x>/src/` as an `<x>` chip and drop a namespace that repeats it. Display only. */+ fold?: boolean;+ /** A copy-path button beside the path. Not inside a link or button: it is a button itself. */+ copyable?: boolean;+ /** The file name in the link colour, for a path that is a link. */+ accent?: boolean;+ className?: string;+ copyLabel?: string;+ copiedLabel?: string;+}++/** A slash-separated string that may wrap only after its slashes. `<wbr>`, so copying stays clean. */+export function SlashBreaks({ text }: { text: string }) {+ const segments = text.split("/");+ return (+ <>+ {segments.map((segment, i) => (+ <React.Fragment key={i}>+ {segment}+ {i < segments.length - 1 ? (+ <>+ /<wbr />+ </>+ ) : null}+ </React.Fragment>+ ))}+ </>+ );+}++const DIM = "text-[var(--color-text-tertiary)]";+const ACCENT = "text-[var(--color-accent-primary)]";+// Elements that take focus for the path. Not any `[tabindex]`: a dialog's+// `tabindex="-1"` would open every tooltip in a drawer at once.+const HOST = 'a[href],button,summary,[role=option],[role=row],[role=menuitem],[tabindex="0"]';++function PackageChip({ pkg }: { pkg: string }) {+ return (+ <span className={cn("shrink-0 rounded-sm bg-[var(--color-bg-inset)] px-1 text-[10px] leading-4", DIM)}>+ {pkg}+ </span>+ );+}++function LineSuffix({ line }: { line: number | string | null | undefined }) {+ if (line == null || line === "") return null;+ return <span className={cn("tabular-nums", DIM)}>:{line}</span>;+}++/** A directory that clips in the middle: the head gives way, the last folder stays. */+function DirClip({ dir, trailingSlash = false }: { dir: string; trailingSlash?: boolean }) {+ const { head, tail } = splitDirTail(dir);+ const end = trailingSlash ? "/" : "";+ return (+ <>+ {head ? <span className={cn("min-w-0 truncate", DIM)}>{head}/</span> : null}+ <span className={cn("min-w-0 shrink-[0.01] truncate", DIM)}>+ {tail}+ {end}+ </span>+ </>+ );+}++interface PieceProps {+ dir: string;+ name: string;+ chip: React.ReactNode;+ line: FilePathProps["line"];+ nameClass: string | undefined;+}++/** Every segment, wrapping only after a slash; the name at reading weight. */+function FullPieces({ dir, name, chip, line, nameClass }: PieceProps) {+ return (+ <span className="[word-break:normal] [overflow-wrap:break-word]">+ {chip ? <span className="mr-1 inline-block">{chip}</span> : null}+ {dir ? (+ <span className={DIM}>+ <SlashBreaks text={`${dir}/`} />+ </span>+ ) : null}+ <span className={cn("font-medium", nameClass)}>{name}</span>+ <LineSuffix line={line} />+ </span>+ );+}++/**+ * The file name in `name-first`: wider than its column, it wraps rather than+ * losing characters. `break-word` keeps its min-content width, so a table+ * column is not squeezed to one character.+ */+const NAME_CLS = "max-w-full shrink-0 whitespace-normal [overflow-wrap:break-word]";++/** The name first, then the package chip and a directory that clips. */+function NameFirstPieces({ dir, name, chip, line, nameClass }: PieceProps) {+ return (+ <span className="flex min-w-0 items-baseline gap-1.5 whitespace-nowrap">+ <span className={cn(NAME_CLS, nameClass)}>+ {name}+ <LineSuffix line={line} />+ </span>+ {chip}+ {dir ? (+ <span className="flex min-w-0">+ <DirClip dir={dir} />+ </span>+ ) : null}+ </span>+ );+}++/** Path order on one line: distinguishing labels and middle-ellipsis mentions. */+function InlinePieces({ dir, name, chip, line, nameClass }: PieceProps) {+ return (+ <span className="flex min-w-0 items-baseline whitespace-nowrap">+ {chip ? <span className="mr-1 flex shrink-0">{chip}</span> : null}+ {dir ? <DirClip dir={dir} trailingSlash /> : null}+ {/* One line: the name stays whole and unwrapped; the directory clips first. */}+ <span className={cn("shrink-0 whitespace-nowrap", nameClass)}>{name}</span>+ <LineSuffix line={line} />+ </span>+ );+}++const PIECES: Record<FilePathMode, (props: PieceProps) => React.ReactElement> = {+ full: FullPieces,+ "name-first": NameFirstPieces,+ distinguishing: InlinePieces,+ "middle-ellipsis": InlinePieces,+};++/** What the mode prints: a distinguishing label, or the (optionally folded) path. */+function displayed(path: string, mode: FilePathMode, labels: FilePathProps["labels"], fold: boolean) {+ if (mode === "distinguishing") return { pkg: null, rest: labels?.get(path) ?? splitPath(path).name };+ return fold ? foldPackagePrefix(path) : { pkg: null, rest: path };+}++function Visual({+ path,+ mode,+ line,+ labels,+ fold = false,+ accent,+}: Required<Pick<FilePathProps, "path" | "mode">> &+ Pick<FilePathProps, "line" | "labels" | "fold" | "accent">) {+ const { pkg, rest } = displayed(path, mode, labels, fold);+ const Pieces = PIECES[mode];+ return (+ <Pieces+ {...splitPath(rest)}+ chip={pkg ? <PackageChip pkg={pkg} /> : null}+ line={line}+ nameClass={accent ? ACCENT : undefined}+ />+ );+}++/** True for keyboard focus; an engine without `:focus-visible` counts as keyboard. */+function isKeyboardFocus(el: HTMLElement): boolean {+ try {+ return el.matches(":focus-visible");+ } catch {+ return true;+ }+}++/**+ * Opens the tooltip while the link or row holding the path has keyboard focus.+ * A path with no such host stays out of the tab order, so a plain list does+ * not gain a tab stop per row; its full path is still the accessible name.+ * Imperative, so a long list mounts without a re-render per row.+ */+function useHostFocus(+ ref: React.RefObject<HTMLElement | null>,+ setOpen: (open: boolean) => void,+ active: boolean,+) {+ useEffect(() => {+ const el = ref.current;+ if (!active || !el) return;+ const host = el.parentElement?.closest<HTMLElement>(HOST);+ if (!host) return;+ const show = () => {+ if (isKeyboardFocus(host)) setOpen(true);+ };+ const hide = () => setOpen(false);+ host.addEventListener("focus", show);+ host.addEventListener("blur", hide);+ return () => {+ host.removeEventListener("focus", show);+ host.removeEventListener("blur", hide);+ };+ }, [ref, setOpen, active]);+}++function CopyPathButton({ text, label, copiedLabel }: { text: string; label: string; copiedLabel: string }) {+ const [copied, setCopied] = useState(false);+ const copy = async () => {+ try {+ await navigator.clipboard.writeText(text);+ setCopied(true);+ window.setTimeout(() => setCopied(false), 1600);+ } catch {+ /* clipboard blocked: the path stays selectable */+ }+ };+ return (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ void copy();+ }}+ aria-label={copied ? copiedLabel : label}+ className={cn(+ "ml-1 inline-flex shrink-0 items-center self-center rounded-sm hover:text-[var(--color-text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)]",+ DIM,+ )}+ >+ {copied ? <Check className="h-3 w-3" aria-hidden /> : <Copy className="h-3 w-3" aria-hidden />}+ </button>+ );+}++export function FilePath({+ path,+ mode = "name-first",+ line,+ labels,+ fold = false,+ copyable = false,+ accent = false,+ className,+ copyLabel = "Copy path",+ copiedLabel = "Copied",+}: FilePathProps) {+ const ref = useRef<HTMLSpanElement>(null);+ const [open, setOpen] = useState(false);+ // The tooltip machinery mounts on first hover or focus, so a list of a+ // thousand paths mounts no Radix provider, root or listener per row, and+ // the path still works in hosts that mount no ambient TooltipProvider.+ const [armed, setArmed] = useState(false);+ const reveal = useCallback((next: boolean) => {+ if (next) setArmed(true);+ setOpen(next);+ }, []);+ // The hover that arms happens before the trigger exists, so Radix never+ // sees it; that hover opens the tooltip itself, after the same delay.+ const hoverTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);+ const cancelHover = useCallback(() => clearTimeout(hoverTimer.current), []);+ const armOnHover = useCallback(() => {+ setArmed(true);+ hoverTimer.current = setTimeout(() => setOpen(true), TOOLTIP_DELAY_MS);+ }, []);+ useEffect(() => cancelHover, [cancelHover]);+ const full = pathWithLine(path, line);+ // `full` shows every character in reading order, and a bare top-level+ // file is already its whole path: neither needs a second, hidden copy.+ const abbreviated = mode !== "full" && (path.includes("/") || full !== path);+ useHostFocus(ref, reveal, abbreviated);++ const visual = (+ <Visual path={path} mode={mode} line={line} labels={labels} fold={fold} accent={accent} />+ );+ const copy = copyable ? <CopyPathButton text={path} label={copyLabel} copiedLabel={copiedLabel} /> : null;++ if (!abbreviated) {+ return (+ <span+ data-path={path}+ className={cn("min-w-0 font-mono text-xs", mode === "full" ? "inline" : "inline-flex max-w-full", className)}+ >+ {visual}+ {copy}+ </span>+ );+ }++ const trigger = (+ <span+ ref={ref}+ className="flex min-w-0 max-w-full"+ onPointerEnter={armed ? undefined : armOnHover}+ >+ <span className="sr-only">{full}</span>+ <span aria-hidden className="flex min-w-0">+ {visual}+ </span>+ </span>+ );++ return (+ // The leave is caught here, on a node arming does not remount, so a pointer+ // that leaves while the trigger moves into the tooltip still cancels it.+ <span+ data-path={path}+ className={cn("inline-flex min-w-0 max-w-full items-baseline font-mono text-xs", className)}+ onPointerLeave={cancelHover}+ >+ {armed ? (+ <TooltipProvider delayDuration={TOOLTIP_DELAY_MS}>+ <Tooltip open={open} onOpenChange={setOpen}>+ <TooltipTrigger asChild>{trigger}</TooltipTrigger>+ <TooltipContent className="max-w-[min(36rem,90vw)] font-mono [overflow-wrap:anywhere]">{full}</TooltipContent>+ </Tooltip>+ </TooltipProvider>+ ) : (+ trigger+ )}+ {copy}+ </span>+ );+}diff --git a/packages/ui/src/shared/index.ts b/packages/ui/src/shared/index.tsindex aca719d59..4292bfa52 100644--- a/packages/ui/src/shared/index.ts+++ b/packages/ui/src/shared/index.ts@@ -97,3 +97,4 @@ export {type ProportionSegment,} from "./proportion-bar";export { SERIES, SERIES_TAIL, seriesColor, commitCategoryColor } from "./series";+export { FilePath, SlashBreaks, type FilePathMode, type FilePathProps } from "./file-path";diff --git a/packages/ui/src/stats/records-list.tsx b/packages/ui/src/stats/records-list.tsxindex bcec27440..fc6ff0f4a 100644--- a/packages/ui/src/stats/records-list.tsx+++ b/packages/ui/src/stats/records-list.tsx@@ -1,6 +1,8 @@import * as React from "react";import type { StatsRecords } from "@repowise-dev/types/stats";import { formatNumber } from "../lib/format";+import { splitPath } from "../lib/path-parts";+import { FilePath } from "../shared/file-path";export interface RecordLinks {fileHref?: ((path: string) => string) | undefined;@@ -14,33 +16,16 @@ interface RecordRow {/** The subject: a path, a symbol, a commit subject or a sentence. Never truncated. */primary: string;mono?: boolean;+ /** `primary` is a repository path. */+ isPath?: boolean;detail: string;href?: string | undefined;}type Href = (value: string) => string | undefined;-/** A path that wraps after a slash instead of mid-name. */-function breakable(text: string): React.ReactNode {- const parts = text.split("/");- return parts.map((part, i) => (- <React.Fragment key={i}>- {part}- {i < parts.length - 1 && (- <>- /<wbr />- </>- )}- </React.Fragment>- ));-}--function fileName(path: string): string {- return path.split("/").pop() || path;-}-function fileRow(key: string, title: string, path: string, detail: string, file: Href): RecordRow {- return { key, title, primary: path, mono: true, detail, href: file(path) };+ return { key, title, primary: path, mono: true, isPath: true, detail, href: file(path) };}function fileRows(r: StatsRecords, file: Href): RecordRow[] {@@ -94,7 +79,7 @@ function functionRow(title,primary: f.name,mono: true,- detail: `${detail}, in ${fileName(f.file_path)}`,+ detail: `${detail}, in ${splitPath(f.file_path).name}`,href: file(f.file_path),};}@@ -214,7 +199,11 @@ export function RecordsList({</h3><dl className="mt-2 divide-y divide-[var(--color-border-default)] border-y border-[var(--color-border-default)]">{g.rows.map((row) => {- const text = row.mono ? breakable(row.primary) : row.primary;+ const text = row.isPath ? (+ <FilePath path={row.primary} mode="full" className="text-[15px]" />+ ) : (+ row.primary+ );return (<div key={row.key} className="min-w-0 py-3"><dt className="text-xs text-[var(--color-text-tertiary)]">{row.title}</dt>diff --git a/packages/ui/src/symbols/symbol-detail-body.tsx b/packages/ui/src/symbols/symbol-detail-body.tsxindex 72c8b52c0..40d45bd57 100644--- a/packages/ui/src/symbols/symbol-detail-body.tsx+++ b/packages/ui/src/symbols/symbol-detail-body.tsx@@ -15,7 +15,8 @@ import { Badge } from "../ui/badge";import { Button } from "../ui/button";import { StatGrid, StatTile } from "../shared/stat-grid";import { scoreBadgeClass } from "../health/tokens";-import { formatRelativeTimeOrNull, formatTopPercentile, truncatePath } from "../lib/format";+import { formatRelativeTimeOrNull, formatTopPercentile } from "../lib/format";+import { FilePath } from "../shared/file-path";import { cn } from "../lib/cn";import { SymbolCallGraph } from "./symbol-call-graph";@@ -316,9 +317,7 @@ export function SymbolDetailBody({key={p.file_path}className="flex items-center justify-between gap-2 font-mono text-xs">- <span className="truncate text-[var(--color-text-secondary)]" title={p.file_path}>- {truncatePath(p.file_path, 40)}- </span>+ <FilePath path={p.file_path} fold className="text-[var(--color-text-secondary)]" /><span className="tabular-nums text-[var(--color-text-tertiary)]">{p.co_change_count}×</span>@@ -385,11 +384,8 @@ export function SymbolDetailBody({<span className="text-[10px] font-medium uppercase tracking-wider text-[var(--color-text-tertiary)]">Parent file</span>- <a- href={fileTo}- className="truncate font-mono text-xs text-[var(--color-accent-primary)] hover:underline"- >- {data.identity.file_path}+ <a href={fileTo} className="min-w-0 hover:underline">+ <FilePath path={data.identity.file_path} mode="full" accent /></a>{data.file_context?.health_score != null && (<span@@ -411,7 +407,8 @@ export function SymbolDetailBody({{onOpenBlastRadius && (<Button variant="outline" size="sm" onClick={onOpenBlastRadius}><Radius className="mr-1.5 h-3.5 w-3.5" />- View blast radius for {truncatePath(id.file_path, 28)}+ View blast radius for{" "}+ <FilePath path={id.file_path} mode="middle-ellipsis" className="max-w-[16rem]" /></Button>)}</div>diff --git a/packages/ui/src/symbols/symbol-page.tsx b/packages/ui/src/symbols/symbol-page.tsxindex 9824ecbdf..cf1bdcda3 100644--- a/packages/ui/src/symbols/symbol-page.tsx+++ b/packages/ui/src/symbols/symbol-page.tsx@@ -2,6 +2,7 @@ import { Flame } from "lucide-react";import { Badge } from "../ui/badge";import { fileEntityPath, symbolEntityPath } from "../shared/entity/routes";import { EntityHeader } from "../shared/entity";+import { FilePath } from "../shared/file-path";import type { BreadcrumbSegment } from "../shared/breadcrumb";import type {SymbolDetailData,@@ -143,10 +144,9 @@ export function SymbolPage({/><ahref={fileEntityPath(prefix, s.file_path)}- title={`${s.file_path}:${s.start_line}`}- className="block max-w-full truncate font-mono text-xs text-[var(--color-text-secondary)] hover:text-[var(--color-accent-primary)] hover:underline"+ className="max-w-full text-[var(--color-text-secondary)] hover:text-[var(--color-accent-primary)] hover:underline">- {s.file_path}:{s.start_line}+ <FilePath path={s.file_path} line={s.start_line} mode="full" /></a><AskAboutThiscontext={{diff --git a/packages/ui/src/symbols/symbol-table.tsx b/packages/ui/src/symbols/symbol-table.tsxindex 97a8fc34a..19397fc1f 100644--- a/packages/ui/src/symbols/symbol-table.tsx+++ b/packages/ui/src/symbols/symbol-table.tsx@@ -21,7 +21,7 @@ import { ResultsFooter } from "../shared/results-footer";import { RowActions } from "../shared/row-actions";import { VirtualizedTable } from "../shared/virtualized-table";import { docsPagePath, filePageId } from "../shared/entity/routes";-import { truncatePath } from "../lib/format";+import { FilePath } from "../shared/file-path";import { cn } from "../lib/cn";import type { CodeSymbol } from "@repowise-dev/types/symbols";@@ -360,9 +360,7 @@ export function SymbolTable({<Badge variant={sym.kind === "class" ? "accent" : "default"}>{sym.kind}</Badge></td><td className="px-4 py-2.5 font-mono text-xs text-[var(--color-text-tertiary)] min-w-[200px] max-w-[420px] hidden sm:table-cell">- <span className="block truncate" title={`${sym.file_path}:${sym.start_line}`}>- {truncatePath(sym.file_path)}:{sym.start_line}- </span>+ <FilePath path={sym.file_path} line={sym.start_line} fold className="flex" /></td><td className="px-4 py-2.5 text-xs text-[var(--color-text-secondary)] tabular-nums hidden md:table-cell text-right"><spandiff --git a/packages/ui/src/workspace/co-change-table.tsx b/packages/ui/src/workspace/co-change-table.tsxindex b5d2bd539..42a8e0219 100644--- a/packages/ui/src/workspace/co-change-table.tsx+++ b/packages/ui/src/workspace/co-change-table.tsx@@ -4,6 +4,7 @@ import * as React from "react";import { EmptyState } from "../shared/empty-state";import { InfoTip } from "../shared/info-tip";import { clickableRowProps, CLICKABLE_ROW_CLS } from "../shared/responsive-table";+import { FilePath } from "../shared/file-path";import { cn } from "../lib/cn";import { formatDate, formatDateTime } from "../lib/format";import { PAIR_MICRO as MICRO } from "../coupling/pair-drawer-parts";@@ -35,45 +36,20 @@ export function coChangeKey(cc: WorkspaceCoChangeEntry): string {// files and the strength stay at every width.const HIDE_BELOW_MD = "max-md:hidden";-function splitPath(path: string): [dir: string, base: string] {- const i = path.lastIndexOf("/");- return i < 0 ? ["", path] : [path.slice(0, i + 1), path.slice(i + 1)];-}-/**- * A repository as a quiet micro-label over its path: directory dim, filename- * full strength and never cut, so the part a reader recognises survives any- * width. In a row the directory truncates (full path in the DOM and the- * title); with `wrap`, where the exact file must be legible, lines break only- * after a "/".+ * A repository as a quiet micro-label over its path. In a row the file name+ * leads and the directory clips; with `wrap`, where the exact file must be+ * legible, the whole path wraps only after a "/".*/export function RepoPath({ repo, path, wrap = false }: { repo: string; path: string; wrap?: boolean }) {- const [dir, base] = splitPath(path);- if (wrap) {- return (- <div className="min-w-0">- <span className={cn(MICRO, "block")}>{repo}</span>- <p className="min-w-0 font-mono text-xs leading-5 [overflow-wrap:break-word]">- {dir.split("/").filter(Boolean).map((seg, i) => (- <React.Fragment key={i}>- <span className="text-[var(--color-text-tertiary)]">{seg}/</span>- <wbr />- </React.Fragment>- ))}- <span className="font-medium text-[var(--color-text-primary)]">{base}</span>- </p>- </div>- );- }return (<div className="min-w-0"><span className={cn(MICRO, "block")}>{repo}</span>- <span className="flex min-w-0 font-mono text-xs leading-5" title={path}>- {dir && <span className="truncate text-[var(--color-text-tertiary)]">{dir}</span>}- <span className="max-w-full shrink-0 font-medium text-[var(--color-text-primary)] [overflow-wrap:anywhere]">- {base}- </span>- </span>+ <FilePath+ path={path}+ mode={wrap ? "full" : "name-first"}+ className="leading-5 text-[var(--color-text-primary)]"+ /></div>);}diff --git a/packages/ui/src/workspace/contract-attention.tsx b/packages/ui/src/workspace/contract-attention.tsxindex 42df44a93..448c8f8c9 100644--- a/packages/ui/src/workspace/contract-attention.tsx+++ b/packages/ui/src/workspace/contract-attention.tsx@@ -25,7 +25,8 @@ import {buildUnmatchedConsumersAiPrompt,providerNoun,} from "./contract-ai-prompt";-import { ContractIdentity, FilePathText } from "./contract-identity";+import { ContractIdentity } from "./contract-identity";+import { FilePath } from "../shared/file-path";import { sortUnmatchedReasons, unmatchedReasonCopy, type OrphanGroup } from "./contract-facts";import type { ContractRef } from "./contract-drawer";@@ -210,7 +211,7 @@ function UnmatchedGroup({><ContractIdentity contractId={u.contract_id} /><span className="text-xs text-[var(--color-text-secondary)]">{u.repo}</span>- <FilePathText path={u.file_path} />+ <FilePath path={u.file_path} fold /></button></li>))}diff --git a/packages/ui/src/workspace/contract-drawer.tsx b/packages/ui/src/workspace/contract-drawer.tsxindex 52fd677dd..3225b036a 100644--- a/packages/ui/src/workspace/contract-drawer.tsx+++ b/packages/ui/src/workspace/contract-drawer.tsx@@ -31,7 +31,8 @@ import {sortChangesBySeverity,type BreakingChangeLinks,} from "./breaking-change-row";-import { ContractIdentity, FilePathText, distinctService } from "./contract-identity";+import { ContractIdentity, distinctService } from "./contract-identity";+import { FilePath } from "../shared/file-path";import { ContractPromptButton } from "./contract-prompt-button";import { ContractTestsSection } from "./contract-tests-section";import { contractTypeLabel } from "./contract-type-label";@@ -218,10 +219,10 @@ function Body({href={fileHref}className="rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)]">- <FilePathText path={contract.file_path} line={contract.line} accent />+ <FilePath path={contract.file_path} line={contract.line} mode="full" accent /></a>) : (- <FilePathText path={contract.file_path} line={contract.line} />+ <FilePath path={contract.file_path} line={contract.line} mode="full" />)}</Fact>{contract.symbol_name ? (@@ -443,7 +444,7 @@ function CounterpartRow({) : null}</span><span className="block">- <FilePathText path={file} />+ <FilePath path={file} mode="full" /></span>{symbol ? (<span className="block font-mono text-[10px] text-[var(--color-text-tertiary)] [overflow-wrap:anywhere]">diff --git a/packages/ui/src/workspace/contract-identity.tsx b/packages/ui/src/workspace/contract-identity.tsxindex c5bf1c31f..25ef0fb9a 100644--- a/packages/ui/src/workspace/contract-identity.tsx+++ b/packages/ui/src/workspace/contract-identity.tsx@@ -1,31 +1,14 @@/**- * How a contract and a file read in a row. Paths get a break opportunity after- * each `/`, so they wrap between segments and a segment is split only when it- * alone is wider than its column. No `"use client"`: server and client rows- * both render them.+ * How a contract reads in a row. Its label gets a break opportunity after+ * each `/`, so it wraps between segments and a segment is split only when it+ * alone is wider than its column.*/-import { Fragment } from "react";+import { FilePath, SlashBreaks } from "../shared/file-path";import { parseContractId } from "./contract-facts";-/** A slash-separated string that wraps only after its slashes. */-export function SlashBreaks({ text }: { text: string }) {- const segments = text.split("/");- return (- <>- {segments.map((segment, i) => (- <Fragment key={i}>- {segment}- {i < segments.length - 1 ? (- <>- /<wbr />- </>- ) : null}- </Fragment>- ))}- </>- );-}+/** @deprecated Import `SlashBreaks` from `shared/file-path`; kept so existing imports compile. */+export { SlashBreaks };const KIND_TAG: Record<string, string> = {data: "TABLE",@@ -81,8 +64,8 @@ export function ContractIdentity({}/**- * A repo-relative file: the directory dim, the file name at reading weight,- * the line when known. The full path rides on `title`.+ * @deprecated Use `<FilePath>` from `shared/file-path`, picking the mode for+ * the surface. Kept with its props so existing callers compile.*/export function FilePathText({path,@@ -91,34 +74,9 @@ export function FilePathText({}: {path: string;line?: number | null | undefined;- /** The file name in the link colour, for a path that is a link. */accent?: boolean;}) {- const cut = path.lastIndexOf("/");- const dir = cut >= 0 ? path.slice(0, cut + 1) : "";- const name = cut >= 0 ? path.slice(cut + 1) : path;- return (- <span- className="font-mono text-xs [word-break:normal] [overflow-wrap:break-word]"- title={line != null ? `${path}:${line}` : path}- >- {dir ? (- <span className="text-[var(--color-text-tertiary)]">- <SlashBreaks text={dir} />- </span>- ) : null}- <span- className={- accent ? "text-[var(--color-accent-primary)]" : "text-[var(--color-text-secondary)]"- }- >- {name}- </span>- {line != null ? (- <span className="tabular-nums text-[var(--color-text-tertiary)]">:{line}</span>- ) : null}- </span>- );+ return <FilePath path={path} line={line} mode="full" accent={accent} />;}/**diff --git a/packages/ui/src/workspace/contract-links-table.tsx b/packages/ui/src/workspace/contract-links-table.tsxindex 3f5bb5575..7a2950fb0 100644--- a/packages/ui/src/workspace/contract-links-table.tsx+++ b/packages/ui/src/workspace/contract-links-table.tsx@@ -2,7 +2,8 @@import { memo, useMemo } from "react";import { ContractTypeBadge } from "./contract-type-badge";-import { ContractIdentity, FilePathText, distinctService } from "./contract-identity";+import { ContractIdentity, distinctService } from "./contract-identity";+import { FilePath } from "../shared/file-path";import { LINK_CONFIDENCE_NOTE } from "./contract-facts";import { EmptyState } from "../shared/empty-state";import { InfoTip } from "../shared/info-tip";@@ -36,7 +37,7 @@ function Side({</span>) : null}</span>- <FilePathText path={file} />+ <FilePath path={file} fold className="max-w-[28rem]" /></div>);}diff --git a/packages/ui/src/workspace/system-map/system-map-drawer.tsx b/packages/ui/src/workspace/system-map/system-map-drawer.tsxindex cbae429df..bffa6d5d1 100644--- a/packages/ui/src/workspace/system-map/system-map-drawer.tsx+++ b/packages/ui/src/workspace/system-map/system-map-drawer.tsx@@ -23,6 +23,7 @@ import type {WorkspaceContractLinkEntry,} from "@repowise-dev/types/workspace";import { AdaptivePanel } from "../../shared/adaptive-panel";+import { FilePath } from "../../shared/file-path";import { AiPromptButton } from "../../health/ai-prompt-button";import { AiPromptModal } from "../../health/ai-prompt-modal";import type { AiPromptFlavor } from "../../health/ai-prompt-builder";@@ -465,10 +466,12 @@ function NodeBody({{c.role} · {plural(c.link_count, "link", "links")}</span></div>- <span className="font-mono text-[10px] text-[var(--color-text-tertiary)] [overflow-wrap:anywhere]">- {c.file_path}- {c.line ? `:${c.line}` : ""}- </span>+ <FilePath+ path={c.file_path}+ line={c.line || null}+ mode="full"+ className="text-[10px] text-[var(--color-text-tertiary)]"+ /></li>))}</ul>@@ -719,11 +722,13 @@ function EdgeBody({) : (<span className="font-mono text-xs [overflow-wrap:anywhere]">{l.contract_id}</span>)}- <span className="font-mono text-[10px] text-[var(--color-text-tertiary)] [overflow-wrap:anywhere]">- provides {l.provider_repo}/{l.provider_file}+ <span className="font-mono text-[10px] text-[var(--color-text-tertiary)]">+ provides{" "}+ <FilePath path={`${l.provider_repo}/${l.provider_file}`} mode="full" className="text-[10px]" /></span>- <span className="font-mono text-[10px] text-[var(--color-text-tertiary)] [overflow-wrap:anywhere]">- calls from {l.consumer_repo}/{l.consumer_file}+ <span className="font-mono text-[10px] text-[var(--color-text-tertiary)]">+ calls from{" "}+ <FilePath path={`${l.consumer_repo}/${l.consumer_file}`} mode="full" className="text-[10px]" /></span></li>))}@@ -777,12 +782,14 @@ function EdgeBody({<ul className="m-0 flex list-none flex-col divide-y divide-[var(--color-border-default)] p-0">{pairs.slice(0, DRAWER_EVIDENCE_ROWS).map(([a, b]) => (<li key={`${a}~${b}`} className="flex flex-col gap-0.5 py-1.5 font-mono text-[10px] leading-snug">- <span className="text-[var(--color-text-secondary)] [overflow-wrap:anywhere]">- {sourceName}/{a}- </span>+ <FilePath+ path={`${sourceName}/${a}`}+ mode="full"+ className="text-[10px] text-[var(--color-text-secondary)]"+ />{b && (- <span className="text-[var(--color-text-tertiary)] [overflow-wrap:anywhere]">- with {targetName}/{b}+ <span className="text-[var(--color-text-tertiary)]">+ with <FilePath path={`${targetName}/${b}`} mode="full" className="text-[10px]" /></span>)}</li>diff --git a/packages/web/src/app/workspace/contracts/contracts-table.tsx b/packages/web/src/app/workspace/contracts/contracts-table.tsxindex 071c4ae8a..afb356ca1 100644--- a/packages/web/src/app/workspace/contracts/contracts-table.tsx+++ b/packages/web/src/app/workspace/contracts/contracts-table.tsx@@ -3,11 +3,8 @@import { memo, useMemo, type MouseEvent } from "react";import { ResponsiveTable, type ResponsiveColumn } from "@repowise-dev/ui/shared/responsive-table";import { ContractTypeBadge, RoleBadge } from "@repowise-dev/ui/workspace/contract-type-badge";-import {- ContractIdentity,- FilePathText,- distinctService,-} from "@repowise-dev/ui/workspace/contract-identity";+import { ContractIdentity, distinctService } from "@repowise-dev/ui/workspace/contract-identity";+import { FilePath } from "@repowise-dev/ui/shared/file-path";import { contractMetaString } from "@repowise-dev/ui/workspace/contract-facts";import type { WorkspaceContractEntry } from "@/lib/api/types";import { useOpenContract } from "./contract-drawer-host";@@ -73,7 +70,7 @@ const COLUMNS: ResponsiveColumn<ContractRow>[] = [{key: "file_path",header: "File",- render: (c) => <FilePathText path={c.file_path} line={c.line} />,+ render: (c) => <FilePath path={c.file_path} line={c.line} fold className="max-w-[28rem]" />,},{key: "found_by",diff --git a/packages/web/src/components/search/command-palette.tsx b/packages/web/src/components/search/command-palette.tsxindex 1bca39f31..31e3bb8d2 100644--- a/packages/web/src/components/search/command-palette.tsx+++ b/packages/web/src/components/search/command-palette.tsx@@ -7,7 +7,7 @@ import { Command } from "cmdk";import useSWR from "swr";import { Search, LayoutDashboard, Settings, BookOpen, FileCode, Layers, Link2, GitMerge, MessageSquare } from "lucide-react";import { useSearch } from "@/lib/hooks/use-search";-import { truncatePath } from "@repowise-dev/ui/lib/format";+import { FilePath } from "@repowise-dev/ui/shared/file-path";import { commandPaletteShortcutIsClaimed } from "@repowise-dev/ui/lib/command-palette-scope";import { fileEntityPath } from "@repowise-dev/ui/shared/entity";import { getFilesIndex } from "@/lib/api/files";@@ -252,8 +252,6 @@ export function CommandPalette({ repos, workspace }: CommandPaletteProps) {{activeRepo && fileMatches.length > 0 && (<Command.Group heading={t("files")} className="px-2 pb-1">{fileMatches.map((path) => {- const name = path.split("/").pop() ?? path;- const dir = path.slice(0, path.length - name.length);return (<Command.Item// Embed the query so cmdk's own filter keeps our pre-ranked@@ -266,12 +264,7 @@ export function CommandPalette({ repos, workspace }: CommandPaletteProps) {className="flex items-center gap-2.5 rounded-md px-3 py-2 text-sm cursor-pointer hover:bg-[var(--color-bg-elevated)] data-[selected=true]:bg-[var(--color-bg-elevated)]"><FileCode className="h-4 w-4 shrink-0 text-[var(--color-text-tertiary)]" />- <span className="min-w-0 truncate font-mono text-[13px]">- <span className="text-[var(--color-text-tertiary)]">- {truncatePath(dir, 36)}- </span>- <span className="text-[var(--color-text-primary)]">{name}</span>- </span>+ <FilePath path={path} fold className="text-[13px] text-[var(--color-text-primary)]" /></Command.Item>);})}@@ -295,9 +288,11 @@ export function CommandPalette({ repos, workspace }: CommandPaletteProps) {className="flex flex-col items-start rounded-md px-3 py-2 text-sm cursor-pointer hover:bg-[var(--color-bg-elevated)] data-[selected=true]:bg-[var(--color-bg-elevated)]"><span className="text-[var(--color-text-primary)] font-medium">{r.title}</span>- <span className="text-xs text-[var(--color-text-tertiary)] font-mono">- {truncatePath(r.target_path, 50)}- </span>+ <FilePath+ path={r.target_path}+ mode="middle-ellipsis"+ className="text-[var(--color-text-tertiary)]"+ /></Command.Item>))}</Command.Group>