Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(graph-ui): navigate Windows drive breadcrumbs to real paths

Zadak4efa22cd95fe
diff --git a/graph-ui/src/components/StatsTab.test.tsx b/graph-ui/src/components/StatsTab.test.tsx
index f0cc22d58..494c0a306 100644
--- a/graph-ui/src/components/StatsTab.test.tsx
+++ b/graph-ui/src/components/StatsTab.test.tsx
@@ -1,6 +1,6 @@
/* @vitest-environment jsdom */
import "@testing-library/jest-dom/vitest";
-import { fireEvent, render, screen, waitFor, act } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen, waitFor, act } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { StatsTab, IndexProgress } from "./StatsTab";
import { messages } from "../lib/i18n";
@@ -43,6 +43,7 @@ function mockProjectsFetch(extra?: (url: string, init?: RequestInit) => Response
describe("StatsTab index modal", () => {
afterEach(() => {
+ cleanup();
vi.unstubAllGlobals();
});
@@ -93,6 +94,39 @@ describe("StatsTab index modal", () => {
expect(screen.getByRole("button", { name: "Index beta" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Browse D:/" })).toBeInTheDocument();
});
+
+ it("navigates Windows breadcrumb segments to real drive paths", async () => {
+ const fetchMock = mockProjectsFetch((url) => {
+ if (url.startsWith("/api/browse")) {
+ return new Response(JSON.stringify({
+ path: "C:/Users/rap",
+ parent: "C:/Users",
+ dirs: ["Documents", "Downloads"],
+ roots: ["C:/", "D:/"],
+ }), { status: 200, headers: { "Content-Type": "application/json" } });
+ }
+ return undefined;
+ });
+
+ render(<StatsTab onSelectProject={() => {}} />);
+ fireEvent.click(await screen.findByRole("button", { name: "Index your first repository" }));
+
+ /* No bogus unified "/" root crumb on a Windows drive path. */
+ await screen.findByRole("button", { name: "C:" });
+ expect(screen.queryByRole("button", { name: "/" })).not.toBeInTheDocument();
+
+ /* Clicking the drive crumb browses to "C:/", not "/C:". */
+ fireEvent.click(screen.getByRole("button", { name: "C:" }));
+ await waitFor(() => {
+ expect(fetchMock).toHaveBeenCalledWith("/api/browse?path=C%3A%2F");
+ });
+
+ /* Clicking a nested crumb browses to "C:/Users", not "/C:/Users". */
+ fireEvent.click(screen.getByRole("button", { name: "Users" }));
+ await waitFor(() => {
+ expect(fetchMock).toHaveBeenCalledWith("/api/browse?path=C%3A%2FUsers");
+ });
+ });
});
describe("IndexProgress", () => {
diff --git a/graph-ui/src/components/StatsTab.tsx b/graph-ui/src/components/StatsTab.tsx
index 07e15fd5a..b210f8612 100644
--- a/graph-ui/src/components/StatsTab.tsx
+++ b/graph-ui/src/components/StatsTab.tsx
@@ -239,6 +239,16 @@ function CreateIndexModal({ onClose, onCreated }: { onClose: () => void; onCreat
/* Breadcrumb segments */
const displayPath = currentPath.replace(/\\/g, "/");
const segments = displayPath.split("/").filter(Boolean);
+ /* A Windows drive path ("C:/Users/rap") has no unified "/" root — its first
+ * segment is the drive letter. Build crumb targets accordingly so clicking a
+ * segment navigates to a real directory instead of a bogus "/C:/..." path
+ * that the backend rejects as "not a directory". */
+ const isWinPath = /^[A-Za-z]:$/.test(segments[0] ?? "");
+ const crumbPath = (i: number): string => {
+ const parts = segments.slice(0, i + 1);
+ if (isWinPath) return parts.length === 1 ? `${parts[0]}/` : parts.join("/");
+ return "/" + parts.join("/");
+ };
return (
<div className="fixed inset-0 z-50 flex items-center justify-center" onClick={onClose}>
@@ -297,12 +307,14 @@ function CreateIndexModal({ onClose, onCreated }: { onClose: () => void; onCreat
{/* Breadcrumb */}
<div className="px-5 py-2 border-y border-border/20 flex items-center gap-0.5 overflow-x-auto text-[11px] shrink-0">
- <button onClick={() => browse("/")} className="text-primary/60 hover:text-primary shrink-0 transition-colors">/</button>
+ {!isWinPath && (
+ <button onClick={() => browse("/")} className="text-primary/60 hover:text-primary shrink-0 transition-colors">/</button>
+ )}
{segments.map((seg, i) => (
<span key={i} className="flex items-center gap-0.5 shrink-0">
- <span className="text-foreground/15">/</span>
+ {(i > 0 || !isWinPath) && <span className="text-foreground/15">/</span>}
<button
- onClick={() => browse("/" + segments.slice(0, i + 1).join("/"))}
+ onClick={() => browse(crumbPath(i))}
className={`transition-colors ${i === segments.length - 1 ? "text-foreground/70 font-medium" : "text-primary/50 hover:text-primary"}`}
>
{seg}