Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(ui): one way to do each thing: tables, tiles, banding, skeletons, errors, tooltips (#695)

Raghav Chamadiyab16206aad2ca
diff --git a/package-lock.json b/package-lock.json
index c65df6a64..2509df02d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2647,6 +2647,43 @@
}
}
},
+ "node_modules/@radix-ui/react-popover": {
+ "version": "1.1.18",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.1.18.tgz",
+ "integrity": "sha512-qdXDes+eHlnMUGlBAAAe5EG7oOQvqsXuq4mq585diMudg80iB+jHbsSeG3+Q4eWNsogNyhqU2p/3i+Y0iEepqg==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.4",
+ "@radix-ui/react-compose-refs": "1.1.3",
+ "@radix-ui/react-context": "1.1.4",
+ "@radix-ui/react-dismissable-layer": "1.1.14",
+ "@radix-ui/react-focus-guards": "1.1.4",
+ "@radix-ui/react-focus-scope": "1.1.11",
+ "@radix-ui/react-id": "1.1.2",
+ "@radix-ui/react-popper": "1.3.2",
+ "@radix-ui/react-portal": "1.1.13",
+ "@radix-ui/react-presence": "1.1.6",
+ "@radix-ui/react-primitive": "2.1.7",
+ "@radix-ui/react-slot": "1.3.0",
+ "@radix-ui/react-use-controllable-state": "1.2.3",
+ "aria-hidden": "^1.2.4",
+ "react-remove-scroll": "^2.7.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-popper": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.3.2.tgz",
@@ -18522,6 +18559,7 @@
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-hover-card": "^1.1.15",
"@radix-ui/react-label": "^2.1.8",
+ "@radix-ui/react-popover": "^1.1.18",
"@radix-ui/react-progress": "^1.1.8",
"@radix-ui/react-scroll-area": "^1.2.10",
"@radix-ui/react-select": "^2.2.6",
diff --git a/packages/ui/COMPONENT_CONTRACTS.md b/packages/ui/COMPONENT_CONTRACTS.md
index d290f76a5..5d40e2d5f 100644
--- a/packages/ui/COMPONENT_CONTRACTS.md
+++ b/packages/ui/COMPONENT_CONTRACTS.md
@@ -53,13 +53,19 @@ hide below `lg`; the wrapper always provides `overflow-x-auto`, and
| `columns` | `ResponsiveColumn<T>[]` | yes | `{ key, header, render, priority?, align?, sortable?, mobileLabel?, mobileRender?, hideInCard?, headerClassName?, cellClassName? }`. |
| `rows` | `T[]` | yes | |
| `rowKey` | `(row: T) => string` | yes | |
-| `onRowClick` | `(row: T) => void` | no | Rows get pointer affordance when set. |
+| `onRowClick` | `(row: T) => void` | no | Rows get pointer affordance plus keyboard activation (`tabIndex`, Enter/Space) when set. |
| `selectedKey` | `string \| null` | no | Highlights the matching row. |
-| `sortField` / `sortOrder` / `onSort` | `string` / `"asc" \| "desc"` / `(key) => void` | no | Controlled sorting; header arrows render on the active column. |
+| `sortField` / `sortOrder` / `onSort` | `string` / `"asc" \| "desc"` / `(key) => void` | no | Controlled sorting; sortable headers render as real buttons with `aria-sort` on the active column. |
| `empty` | `ReactNode` | no | Rendered instead of the table when `rows` is empty (pass `EmptyState`). |
+| `caption` | `string` | no | Screen-reader-only `<caption>` describing the table. |
| `stacked` | `"sm" \| "md"` | no | Collapse to stacked cards below the breakpoint. |
| `bare` | `boolean` | no | Omit the rounded border + surface background (for card-embedded tables). |
+The module also exports `clickableRowProps(activate)` and
+`CLICKABLE_ROW_CLS` so tables that own their `<tr>` markup (for example
+`VirtualizedTable` consumers) can give clickable rows the same keyboard
+activation and focus treatment.
+
---
## `shared/adaptive-panel` — `AdaptivePanel`
@@ -120,19 +126,22 @@ Empty-list placeholder with optional icon and CTA.
---
-## `shared/stat-card` — `StatCard`
+## `shared/metric-card` — `MetricCard`
-Single-stat display tile.
+The canonical single-stat display tile.
| Prop | Type | Required | Notes |
|------|------|----------|-------|
| `label` | `string` | yes | Uppercase label above the value. |
-| `value` | `string \| number` | yes | Rendered tabular-nums. |
+| `value` | `React.ReactNode` | yes | Rendered tabular-nums. |
| `description` | `string` | no | Caption under the value. |
-| `trend` | `{ value: string; positive: boolean }` | no | Renders an up/down arrow next to the value. |
+| `delta` | `{ value: string; positive: boolean; neutral?: boolean }` | no | Signed change; `positive` drives good/bad colour, `neutral` renders uncoloured. |
+| `sparkline` | `React.ReactNode` | no | Rendered beneath the value. |
+| `distBar` | `React.ReactNode` | no | Distribution bar beneath the value. |
| `icon` | `React.ReactNode` | no | Right-aligned glyph. |
+| `href` | `string` | no | Wraps the card in a link; hover affordance follows. |
+| `LinkComponent` | `React.ElementType` | no | Link element used with `href`; defaults to `"a"`. |
| `className` | `string` | no | Forwarded to the outer Card. |
-| `href` | `string` | no | Wraps the card in an `<a>`; hover affordance follows. |
---
@@ -692,7 +701,7 @@ bars colour-graded against the freshness thresholds.
### `workspace/cross-repo-summary` — `CrossRepoSummary`
-Four-tile summary header (`StatCard` × 4) for co-change pairs, package
+Four-tile summary header (`MetricCard` × 4) for co-change pairs, package
deps, contract links, and contract count.
| Prop | Type | Required |
diff --git a/packages/ui/README.md b/packages/ui/README.md
index 90d3ae890..b75f46ed5 100644
--- a/packages/ui/README.md
+++ b/packages/ui/README.md
@@ -31,7 +31,7 @@ src/
security/ findings table
settings/ general-form
shared/ primitives: responsive-table, adaptive-panel, toast,
- error-boundary, empty-state, api-error, stat-card,
+ error-boundary, empty-state, api-error, metric-card,
entity links/hover cards, context-drawer, owl-loader
symbols/ symbol-table, symbol-drawer, symbol-page, graph/git panels
ui/ Radix-CVA primitives
diff --git a/packages/ui/__tests__/c4/code-viewer.test.tsx b/packages/ui/__tests__/c4/code-viewer.test.tsx
index e2c63a183..4a3b789ce 100644
--- a/packages/ui/__tests__/c4/code-viewer.test.tsx
+++ b/packages/ui/__tests__/c4/code-viewer.test.tsx
@@ -115,7 +115,7 @@ describe("CodeViewer", () => {
});
it("shows error state with retry", async () => {
- mockFetchContent.mockRejectedValue(new Error("Network error"));
+ mockFetchContent.mockRejectedValue(new Error("File not found in the index"));
act(() => {
store.getState().setView(mockView);
store.getState().openCodeViewer("src/app.py");
@@ -124,7 +124,7 @@ describe("CodeViewer", () => {
await waitFor(() => {
expect(screen.getByRole("alert")).toBeInTheDocument();
});
- expect(screen.getByText("Network error")).toBeInTheDocument();
+ expect(screen.getByText("File not found in the index")).toBeInTheDocument();
expect(screen.getByText("Retry")).toBeInTheDocument();
});
});
diff --git a/packages/ui/__tests__/health/biomarker-chip.test.tsx b/packages/ui/__tests__/health/biomarker-chip.test.tsx
new file mode 100644
index 000000000..7dc7dd2be
--- /dev/null
+++ b/packages/ui/__tests__/health/biomarker-chip.test.tsx
@@ -0,0 +1,27 @@
+import { describe, it, expect } from "vitest";
+import { render, screen, fireEvent } from "@testing-library/react";
+import { BiomarkerChip } from "../../src/health/biomarker-chip.js";
+import { biomarkerInfo } from "../../src/health/biomarker-glossary.js";
+
+describe("BiomarkerChip", () => {
+ it("opens the glossary entry in a popover on click", () => {
+ const info = biomarkerInfo("brain_method");
+ render(<BiomarkerChip type="brain_method" />);
+ const trigger = screen.getByRole("button", { name: `What is ${info.label}?` });
+ expect(screen.queryByText(info.description)).toBeNull();
+
+ fireEvent.click(trigger);
+ expect(screen.getByText(info.description)).toBeInTheDocument();
+ });
+
+ it("renders a plain label when the glossary has no description", () => {
+ render(<BiomarkerChip type="totally_unknown_marker" />);
+ expect(screen.queryByRole("button")).toBeNull();
+ expect(screen.getByText("totally unknown marker")).toBeInTheDocument();
+ });
+
+ it("renders a plain label with showInfo=false", () => {
+ render(<BiomarkerChip type="brain_method" showInfo={false} />);
+ expect(screen.queryByRole("button")).toBeNull();
+ });
+});
diff --git a/packages/ui/__tests__/lib/errors.test.ts b/packages/ui/__tests__/lib/errors.test.ts
new file mode 100644
index 000000000..d5966ee22
--- /dev/null
+++ b/packages/ui/__tests__/lib/errors.test.ts
@@ -0,0 +1,36 @@
+import { describe, it, expect } from "vitest";
+import { toFriendlyMessage, DEFAULT_ERROR_MESSAGE } from "../../src/lib/errors.js";
+
+describe("toFriendlyMessage", () => {
+ it("keeps a human-written server message", () => {
+ expect(toFriendlyMessage(new Error("Path does not exist or is not a git repository"))).toBe(
+ "Path does not exist or is not a git repository",
+ );
+ });
+
+ it("translates network failures", () => {
+ expect(toFriendlyMessage(new TypeError("Failed to fetch"))).toMatch(/reach the server/i);
+ expect(toFriendlyMessage(new Error("NetworkError when attempting to fetch resource."))).toMatch(
+ /reach the server/i,
+ );
+ });
+
+ it("translates aborted requests", () => {
+ expect(toFriendlyMessage(new DOMException("The operation was aborted.", "AbortError"))).toBe(
+ "The request was cancelled.",
+ );
+ });
+
+ it("strips a leaked error-class prefix", () => {
+ expect(toFriendlyMessage(new Error("TypeError: x is not a function"))).toBe(
+ "x is not a function",
+ );
+ });
+
+ it("falls back for empty and object-ish errors", () => {
+ expect(toFriendlyMessage(new Error(""))).toBe(DEFAULT_ERROR_MESSAGE);
+ expect(toFriendlyMessage({})).toBe(DEFAULT_ERROR_MESSAGE);
+ expect(toFriendlyMessage("[object Object]")).toBe(DEFAULT_ERROR_MESSAGE);
+ expect(toFriendlyMessage(null, "Custom fallback")).toBe("Custom fallback");
+ });
+});
diff --git a/packages/ui/__tests__/shared/metric-card.test.tsx b/packages/ui/__tests__/shared/metric-card.test.tsx
new file mode 100644
index 000000000..567869048
--- /dev/null
+++ b/packages/ui/__tests__/shared/metric-card.test.tsx
@@ -0,0 +1,35 @@
+import { describe, it, expect } from "vitest";
+import { render, screen } from "@testing-library/react";
+import { MetricCard } from "../../src/shared/metric-card.js";
+
+describe("MetricCard", () => {
+ it("renders the label and value", () => {
+ render(<MetricCard label="Hotspots" value="42" />);
+ expect(screen.getByText("Hotspots")).toBeInTheDocument();
+ expect(screen.getByText("42")).toBeInTheDocument();
+ });
+
+ it("renders an optional description when provided", () => {
+ render(<MetricCard label="Coverage" value="87%" description="last 30 days" />);
+ expect(screen.getByText("last 30 days")).toBeInTheDocument();
+ });
+
+ it("renders a positive delta with an up arrow", () => {
+ render(
+ <MetricCard label="Hotspots" value={42} delta={{ value: "+5", positive: true }} />,
+ );
+ expect(screen.getByText(/↑ \+5/)).toBeInTheDocument();
+ });
+
+ it("renders a neutral delta without an arrow or coloring", () => {
+ render(
+ <MetricCard
+ label="Files"
+ value={1200}
+ delta={{ value: "+12", positive: true, neutral: true }}
+ />,
+ );
+ expect(screen.getByText("+12")).toBeInTheDocument();
+ expect(screen.queryByText(/↑/)).toBeNull();
+ });
+});
diff --git a/packages/ui/__tests__/shared/responsive-table.test.tsx b/packages/ui/__tests__/shared/responsive-table.test.tsx
new file mode 100644
index 000000000..16434d1c3
--- /dev/null
+++ b/packages/ui/__tests__/shared/responsive-table.test.tsx
@@ -0,0 +1,120 @@
+import { describe, it, expect, vi } from "vitest";
+import { render, screen, fireEvent } from "@testing-library/react";
+import {
+ ResponsiveTable,
+ type ResponsiveColumn,
+} from "../../src/shared/responsive-table/responsive-table.js";
+
+interface Row {
+ id: string;
+ name: string;
+ count: number;
+}
+
+const ROWS: Row[] = [
+ { id: "a", name: "alpha", count: 3 },
+ { id: "b", name: "beta", count: 7 },
+];
+
+const COLUMNS: ResponsiveColumn<Row>[] = [
+ { key: "name", header: "Name", render: (r) => r.name },
+ { key: "count", header: "Count", sortable: true, render: (r) => r.count },
+];
+
+describe("ResponsiveTable", () => {
+ it("renders headers, rows, and a screen-reader caption", () => {
+ render(
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={ROWS}
+ rowKey={(r) => r.id}
+ caption="Test rows"
+ />,
+ );
+ expect(screen.getByText("Name")).toBeTruthy();
+ expect(screen.getByText("alpha")).toBeTruthy();
+ expect(screen.getByText("beta")).toBeTruthy();
+ expect(screen.getByText("Test rows").tagName).toBe("CAPTION");
+ });
+
+ it("renders the empty slot when there are no rows", () => {
+ render(
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={[]}
+ rowKey={(r) => r.id}
+ empty={<div>Nothing here</div>}
+ />,
+ );
+ expect(screen.getByText("Nothing here")).toBeTruthy();
+ });
+
+ it("makes clickable rows focusable and activatable with Enter and Space", () => {
+ const onRowClick = vi.fn();
+ render(
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={ROWS}
+ rowKey={(r) => r.id}
+ onRowClick={onRowClick}
+ />,
+ );
+ const row = screen.getByText("alpha").closest("tr");
+ expect(row).toBeTruthy();
+ expect(row!.tabIndex).toBe(0);
+
+ fireEvent.keyDown(row!, { key: "Enter" });
+ expect(onRowClick).toHaveBeenCalledWith(ROWS[0]);
+
+ fireEvent.keyDown(row!, { key: " " });
+ expect(onRowClick).toHaveBeenCalledTimes(2);
+
+ fireEvent.click(row!);
+ expect(onRowClick).toHaveBeenCalledTimes(3);
+ });
+
+ it("does not activate the row when a key lands on an interactive child", () => {
+ const onRowClick = vi.fn();
+ render(
+ <ResponsiveTable
+ columns={[
+ {
+ key: "action",
+ header: "Action",
+ render: () => <button type="button">act</button>,
+ },
+ ]}
+ rows={ROWS}
+ rowKey={(r) => r.id}
+ onRowClick={onRowClick}
+ />,
+ );
+ const button = screen.getAllByText("act")[0]!;
+ fireEvent.keyDown(button, { key: "Enter" });
+ expect(onRowClick).not.toHaveBeenCalled();
+ });
+
+ it("does not make rows focusable without onRowClick", () => {
+ render(<ResponsiveTable columns={COLUMNS} rows={ROWS} rowKey={(r) => r.id} />);
+ const row = screen.getByText("alpha").closest("tr");
+ expect(row!.tabIndex).toBe(-1);
+ });
+
+ it("exposes sortable headers as buttons and reports aria-sort", () => {
+ const onSort = vi.fn();
+ render(
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={ROWS}
+ rowKey={(r) => r.id}
+ sortField="count"
+ sortOrder="asc"
+ onSort={onSort}
+ />,
+ );
+ const header = screen.getByRole("button", { name: /count/i });
+ fireEvent.click(header);
+ expect(onSort).toHaveBeenCalledWith("count");
+ expect(header.closest("th")!.getAttribute("aria-sort")).toBe("ascending");
+ });
+});
diff --git a/packages/ui/__tests__/shared/stat-card.test.tsx b/packages/ui/__tests__/shared/stat-card.test.tsx
deleted file mode 100644
index c721586f1..000000000
--- a/packages/ui/__tests__/shared/stat-card.test.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { describe, it, expect } from "vitest";
-import { render, screen } from "@testing-library/react";
-import { StatCard } from "../../src/shared/stat-card.js";
-
-describe("StatCard", () => {
- it("renders the label and value", () => {
- render(<StatCard label="Hotspots" value="42" />);
- expect(screen.getByText("Hotspots")).toBeInTheDocument();
- expect(screen.getByText("42")).toBeInTheDocument();
- });
-
- it("renders an optional description when provided", () => {
- render(<StatCard label="Coverage" value="87%" description="last 30 days" />);
- expect(screen.getByText("last 30 days")).toBeInTheDocument();
- });
-
- it("renders a positive trend with an up arrow", () => {
- render(
- <StatCard
- label="Hotspots"
- value={42}
- trend={{ value: "+5", positive: true }}
- />,
- );
- expect(screen.getByText(/↑ \+5/)).toBeInTheDocument();
- });
-});
diff --git a/packages/ui/__tests__/wiki/security-panel.test.tsx b/packages/ui/__tests__/wiki/security-panel.test.tsx
index feb0770af..47358aa0f 100644
--- a/packages/ui/__tests__/wiki/security-panel.test.tsx
+++ b/packages/ui/__tests__/wiki/security-panel.test.tsx
@@ -18,9 +18,10 @@ describe("SecurityPanel", () => {
expect(screen.getByText(/no security signals/i)).toBeInTheDocument();
});
- it("renders nothing while loading", () => {
+ it("renders a skeleton while loading", () => {
const { container } = render(<SecurityPanel findings={undefined} isLoading />);
- expect(container).toBeEmptyDOMElement();
+ expect(container.querySelector(".animate-pulse")).toBeInTheDocument();
+ expect(screen.queryByText(/no security signals/i)).not.toBeInTheDocument();
});
it("renders a finding with severity badge and kind", () => {
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 8c95b6f73..dda56d478 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -99,6 +99,7 @@
"./ui/*": "./src/ui/*.tsx",
"./lib/cn": "./src/lib/cn.ts",
"./lib/confidence": "./src/lib/confidence.ts",
+ "./lib/errors": "./src/lib/errors.ts",
"./lib/format": "./src/lib/format.ts",
"./lib/page-types": "./src/lib/page-types.ts"
},
@@ -116,6 +117,7 @@
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-hover-card": "^1.1.15",
"@radix-ui/react-label": "^2.1.8",
+ "@radix-ui/react-popover": "^1.1.18",
"@radix-ui/react-progress": "^1.1.8",
"@radix-ui/react-scroll-area": "^1.2.10",
"@radix-ui/react-select": "^2.2.6",
diff --git a/packages/ui/src/blast-radius/cells.tsx b/packages/ui/src/blast-radius/cells.tsx
deleted file mode 100644
index 9ac0fa109..000000000
--- a/packages/ui/src/blast-radius/cells.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import type { ReactNode } from "react";
-import { cn } from "../lib/cn";
-
-export function Th({ children }: { children: ReactNode }) {
- return (
- <th className="text-left text-[11px] font-medium uppercase tracking-wider text-[var(--color-text-tertiary)] py-1.5 pr-4 whitespace-nowrap">
- {children}
- </th>
- );
-}
-
-export function Td({
- children,
- className,
-}: {
- children: ReactNode;
- className?: string;
-}) {
- return (
- <td
- className={cn(
- "text-xs text-[var(--color-text-secondary)] py-1.5 pr-4 align-top",
- className,
- )}
- >
- {children}
- </td>
- );
-}
diff --git a/packages/ui/src/blast-radius/cochange-table.tsx b/packages/ui/src/blast-radius/cochange-table.tsx
index aa6742932..cfcfd79af 100644
--- a/packages/ui/src/blast-radius/cochange-table.tsx
+++ b/packages/ui/src/blast-radius/cochange-table.tsx
@@ -1,46 +1,51 @@
+"use client";
+
import type { CochangeWarning } from "@repowise-dev/types/blast-radius";
-import { Th, Td } from "./cells";
+import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";
interface CochangeTableProps {
rows: CochangeWarning[];
}
+const COLUMNS: ResponsiveColumn<CochangeWarning>[] = [
+ {
+ key: "changed",
+ header: "Changed File",
+ render: (r) => (
+ <span className="font-mono text-xs break-all" title={r.changed}>
+ {r.changed}
+ </span>
+ ),
+ },
+ {
+ key: "missing_partner",
+ header: "Missing Partner",
+ render: (r) => (
+ <span className="font-mono text-xs break-all" title={r.missing_partner}>
+ {r.missing_partner}
+ </span>
+ ),
+ },
+ {
+ key: "score",
+ header: "Co-change Count",
+ align: "right",
+ render: (r) => <span className="tabular-nums">{r.score}</span>,
+ },
+];
+
export function CochangeTable({ rows }: CochangeTableProps) {
+ const keyed = rows.map((row, i) => ({
+ ...row,
+ _key: `${row.changed}|${row.missing_partner}|${i}`,
+ }));
return (
- <div className="overflow-x-auto">
- <table className="w-full">
- <caption className="sr-only">Co-change warnings</caption>
- <thead>
- <tr className="border-b border-[var(--color-border-default)]">
- <Th>Changed File</Th>
- <Th>Missing Partner</Th>
- <Th>Co-change Count</Th>
- </tr>
- </thead>
- <tbody>
- {rows.map((r, i) => (
- <tr
- key={`${r.changed}|${r.missing_partner}|${i}`}
- className="group border-t border-[var(--color-table-divider)] hover:bg-[var(--color-bg-elevated)]"
- >
- <Td>
- <span
- className="font-mono break-all group-hover:underline underline-offset-2"
- title={r.changed}
- >
- {r.changed}
- </span>
- </Td>
- <Td>
- <span className="font-mono break-all" title={r.missing_partner}>
- {r.missing_partner}
- </span>
- </Td>
- <Td className="text-right tabular-nums">{r.score}</Td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <ResponsiveTable<CochangeWarning & { _key: string }>
+ columns={COLUMNS}
+ rows={keyed}
+ rowKey={(r) => r._key}
+ caption="Co-change warnings"
+ bare
+ />
);
}
diff --git a/packages/ui/src/blast-radius/direct-risks-table.tsx b/packages/ui/src/blast-radius/direct-risks-table.tsx
index cb1e80c97..82c006e3e 100644
--- a/packages/ui/src/blast-radius/direct-risks-table.tsx
+++ b/packages/ui/src/blast-radius/direct-risks-table.tsx
@@ -1,16 +1,13 @@
+"use client";
+
import type { DirectRiskEntry } from "@repowise-dev/types/blast-radius";
+import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";
+import { riskInk } from "../health/tokens";
interface DirectRisksTableProps {
rows: DirectRiskEntry[];
}
-/** Health-band ink, matching the impact-graph node colours. */
-function riskInk(risk01: number): string {
- if (risk01 >= 0.66) return "var(--color-error)";
- if (risk01 >= 0.33) return "var(--color-warning)";
- return "var(--color-success)";
-}
-
/** A 0–1 value rendered as a labelled mini-bar so rows scan visually. */
function MiniBar({
value01,
@@ -37,6 +34,62 @@ function MiniBar({
);
}
+const COLUMNS: ResponsiveColumn<DirectRiskEntry>[] = [
+ {
+ key: "path",
+ header: "File",
+ render: (r) => (
+ <span
+ className="block max-w-[280px] truncate font-mono text-xs text-[var(--color-text-secondary)]"
+ title={r.path}
+ >
+ {r.path}
+ </span>
+ ),
+ },
+ {
+ key: "risk_score",
+ header: "Risk (0–10)",
+ headerClassName: "w-[28%]",
+ render: (r) => (
+ <MiniBar
+ value01={r.risk_score}
+ color={riskInk(r.risk_score)}
+ display={(r.risk_score * 10).toFixed(1)}
+ />
+ ),
+ mobileRender: (r) => (r.risk_score * 10).toFixed(1),
+ },
+ {
+ key: "temporal_hotspot",
+ header: "Temporal hotspot",
+ headerClassName: "w-[24%]",
+ priority: 2,
+ render: (r) => (
+ <MiniBar
+ value01={r.temporal_hotspot}
+ color="var(--color-accent-secondary)"
+ display={(r.temporal_hotspot * 10).toFixed(1)}
+ />
+ ),
+ mobileRender: (r) => (r.temporal_hotspot * 10).toFixed(1),
+ },
+ {
+ key: "centrality",
+ header: "Centrality",
+ headerClassName: "w-[24%]",
+ priority: 2,
+ render: (r) => (
+ <MiniBar
+ value01={r.centrality}
+ color="var(--color-info)"
+ display={`${(r.centrality * 100).toFixed(0)}%`}
+ />
+ ),
+ mobileRender: (r) => `${(r.centrality * 100).toFixed(0)}%`,
+ },
+];
+
/**
* Direct dependents of the changed files, sorted by risk. Each numeric column
* is an inline mini-bar (risk health-banded, hotspot/centrality neutral) so the
@@ -45,56 +98,12 @@ function MiniBar({
export function DirectRisksTable({ rows }: DirectRisksTableProps) {
const sorted = [...rows].sort((a, b) => b.risk_score - a.risk_score);
return (
- <div className="overflow-x-auto">
- <table className="w-full">
- <caption className="sr-only">Direct risks for the changed files</caption>
- <thead>
- <tr className="border-b border-[var(--color-border-default)] text-left text-[11px] font-medium uppercase tracking-wider text-[var(--color-text-tertiary)]">
- <th className="py-1.5 pr-4">File</th>
- <th className="w-[28%] py-1.5 pr-4">Risk (0–10)</th>
- <th className="w-[24%] py-1.5 pr-4">Temporal hotspot</th>
- <th className="w-[24%] py-1.5">Centrality</th>
- </tr>
- </thead>
- <tbody>
- {sorted.map((r) => (
- <tr
- key={r.path}
- className="group border-t border-[var(--color-table-divider)] hover:bg-[var(--color-bg-elevated)]"
- >
- <td className="py-2 pr-4 align-middle">
- <span
- className="block max-w-[280px] truncate font-mono text-xs text-[var(--color-text-secondary)] group-hover:underline underline-offset-2"
- title={r.path}
- >
- {r.path}
- </span>
- </td>
- <td className="py-2 pr-4 align-middle">
- <MiniBar
- value01={r.risk_score}
- color={riskInk(r.risk_score)}
- display={(r.risk_score * 10).toFixed(1)}
- />
- </td>
- <td className="py-2 pr-4 align-middle">
- <MiniBar
- value01={r.temporal_hotspot}
- color="var(--color-accent-secondary)"
- display={(r.temporal_hotspot * 10).toFixed(1)}
- />
- </td>
- <td className="py-2 align-middle">
- <MiniBar
- value01={r.centrality}
- color="var(--color-info)"
- display={`${(r.centrality * 100).toFixed(0)}%`}
- />
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={sorted}
+ rowKey={(r) => r.path}
+ caption="Direct risks for the changed files"
+ bare
+ />
);
}
diff --git a/packages/ui/src/blast-radius/impact-view.tsx b/packages/ui/src/blast-radius/impact-view.tsx
index f3f10c0bf..6a013f82b 100644
--- a/packages/ui/src/blast-radius/impact-view.tsx
+++ b/packages/ui/src/blast-radius/impact-view.tsx
@@ -22,6 +22,7 @@ import { Skeleton } from "../ui/skeleton";
import { FilePathPicker } from "../health/file-path-picker";
import { BlastRadiusResults } from "./blast-radius-results";
import type { ImpactAdapter } from "./impact-adapter";
+import { toFriendlyMessage } from "../lib/errors";
export function ImpactView({ adapter }: { adapter: ImpactAdapter }) {
const [selected, setSelected] = useState<string[]>([]);
@@ -69,7 +70,7 @@ export function ImpactView({ adapter }: { adapter: ImpactAdapter }) {
setResult(data);
setAnalyzedFiles(selected);
} catch (err) {
- setError(err instanceof Error ? err.message : "Analysis failed.");
+ setError(toFriendlyMessage(err, "Analysis failed."));
} finally {
setLoading(false);
}
diff --git a/packages/ui/src/blast-radius/reviewers-table.tsx b/packages/ui/src/blast-radius/reviewers-table.tsx
index 1391b6743..b3c7bdeb1 100644
--- a/packages/ui/src/blast-radius/reviewers-table.tsx
+++ b/packages/ui/src/blast-radius/reviewers-table.tsx
@@ -1,41 +1,42 @@
+"use client";
+
import type { ReviewerEntry } from "@repowise-dev/types/blast-radius";
-import { Th, Td } from "./cells";
+import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";
interface ReviewersTableProps {
rows: ReviewerEntry[];
}
+const COLUMNS: ResponsiveColumn<ReviewerEntry>[] = [
+ {
+ key: "email",
+ header: "Email",
+ render: (r) => r.email,
+ },
+ {
+ key: "files",
+ header: "Files Owned",
+ align: "right",
+ render: (r) => <span className="tabular-nums">{r.files}</span>,
+ },
+ {
+ key: "ownership_pct",
+ header: "Avg Ownership %",
+ align: "right",
+ render: (r) => (
+ <span className="tabular-nums">{(r.ownership_pct * 100).toFixed(1)}%</span>
+ ),
+ },
+];
+
export function ReviewersTable({ rows }: ReviewersTableProps) {
return (
- <div className="overflow-x-auto">
- <table className="w-full">
- <caption className="sr-only">Recommended reviewers</caption>
- <thead>
- <tr className="border-b border-[var(--color-border-default)]">
- <Th>Email</Th>
- <Th>Files Owned</Th>
- <Th>Avg Ownership %</Th>
- </tr>
- </thead>
- <tbody>
- {rows.map((r) => (
- <tr
- key={r.email}
- className="group border-t border-[var(--color-table-divider)] hover:bg-[var(--color-bg-elevated)]"
- >
- <Td>
- <span className="group-hover:underline underline-offset-2">
- {r.email}
- </span>
- </Td>
- <Td className="text-right tabular-nums">{r.files}</Td>
- <Td className="text-right tabular-nums">
- {(r.ownership_pct * 100).toFixed(1)}%
- </Td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={rows}
+ rowKey={(r) => r.email}
+ caption="Recommended reviewers"
+ bare
+ />
);
}
diff --git a/packages/ui/src/blast-radius/transitive-table.tsx b/packages/ui/src/blast-radius/transitive-table.tsx
index fead839ef..c62573c1c 100644
--- a/packages/ui/src/blast-radius/transitive-table.tsx
+++ b/packages/ui/src/blast-radius/transitive-table.tsx
@@ -1,40 +1,38 @@
+"use client";
+
import type { TransitiveEntry } from "@repowise-dev/types/blast-radius";
-import { Th, Td } from "./cells";
+import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";
interface TransitiveTableProps {
rows: TransitiveEntry[];
}
+const COLUMNS: ResponsiveColumn<TransitiveEntry>[] = [
+ {
+ key: "path",
+ header: "File",
+ render: (r) => (
+ <span className="font-mono text-xs break-all" title={r.path}>
+ {r.path}
+ </span>
+ ),
+ },
+ {
+ key: "depth",
+ header: "Depth",
+ align: "right",
+ render: (r) => <span className="tabular-nums">{r.depth}</span>,
+ },
+];
+
export function TransitiveTable({ rows }: TransitiveTableProps) {
return (
- <div className="overflow-x-auto">
- <table className="w-full">
- <caption className="sr-only">Transitively affected files</caption>
- <thead>
- <tr className="border-b border-[var(--color-border-default)]">
- <Th>File</Th>
- <Th>Depth</Th>
- </tr>
- </thead>
- <tbody>
- {rows.map((r) => (
- <tr
- key={r.path}
- className="group border-t border-[var(--color-table-divider)] hover:bg-[var(--color-bg-elevated)]"
- >
- <Td>
- <span
- className="font-mono break-all group-hover:underline underline-offset-2"
- title={r.path}
- >
- {r.path}
- </span>
- </Td>
- <Td className="text-right tabular-nums">{r.depth}</Td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={rows}
+ rowKey={(r) => r.path}
+ caption="Transitively affected files"
+ bare
+ />
);
}
diff --git a/packages/ui/src/c4/ArchCanvas.tsx b/packages/ui/src/c4/ArchCanvas.tsx
index 515f4ecbe..a31671d57 100644
--- a/packages/ui/src/c4/ArchCanvas.tsx
+++ b/packages/ui/src/c4/ArchCanvas.tsx
@@ -18,6 +18,7 @@ import { ArchLegend } from "./panels";
import { KEYFRAMES } from "./theme/theme-variables";
import { EmptyState } from "../shared/empty-state";
import { OwlLoader } from "../shared/owl-loader";
+import { toFriendlyMessage } from "../lib/errors";
export interface ArchCanvasProps {
nodes: Node[];
@@ -74,7 +75,7 @@ export function ArchCanvas({
<EmptyState
icon={<AlertTriangle className="h-5 w-5" aria-hidden />}
title={errorTitle}
- description={error.message}
+ description={toFriendlyMessage(error)}
className="max-w-md p-8"
/>
</div>
diff --git a/packages/ui/src/c4/C4Diagram.tsx b/packages/ui/src/c4/C4Diagram.tsx
index 70862fef0..be1098a22 100644
--- a/packages/ui/src/c4/C4Diagram.tsx
+++ b/packages/ui/src/c4/C4Diagram.tsx
@@ -39,6 +39,7 @@ import type {
C4Level,
C4NodeData,
} from "./types";
+import { toFriendlyMessage } from "../lib/errors";
export interface C4DiagramProps {
level: C4Level;
@@ -193,7 +194,7 @@ function C4DiagramInner({
{/* Canvas */}
<div style={{ position: "relative", flex: 1, minHeight: 0 }}>
- {error && <CenteredMessage tone="error" text={error.message} />}
+ {error && <CenteredMessage tone="error" text={toFriendlyMessage(error)} />}
{!error && isLoading && nodes.length === 0 && (
<CenteredMessage tone="info" text="Loading knowledge graph…" />
)}
diff --git a/packages/ui/src/c4/export/svg-exporter.ts b/packages/ui/src/c4/export/svg-exporter.ts
index c5251c3fd..d2b5c9175 100644
--- a/packages/ui/src/c4/export/svg-exporter.ts
+++ b/packages/ui/src/c4/export/svg-exporter.ts
@@ -10,6 +10,7 @@ import type { Edge, Node } from "@xyflow/react";
import type { C4EdgeData, C4NodeData } from "../types";
import { TONE_STYLES, type ToneName } from "../../graph-primitives/tone-styles";
import { resolveToken } from "../../shared/use-theme-tokens";
+import { healthBand100 } from "../../health/tokens";
/**
* Blueprint ink palette, resolved from the LIVE theme at export time so the
@@ -264,7 +265,9 @@ function renderArchNode(n: Node, pal: InkPalette): string {
parts.push(`<text x="14" y="44" font-family="${FONT_FAMILY}" font-size="11" fill="${pal.inkText}" opacity="0.72">${subtitle}</text>`);
parts.push(`<text x="14" y="${h - 12}" font-family="${MONO_FONT}" font-size="9" font-weight="600" letter-spacing="1" fill="${pal.inkText}" opacity="0.6">${isGroup ? "GROUP" : "LAYER"} · ${layer.file_count} FILES</text>`);
if (layer.health_score !== null) {
- const healthColor = layer.health_score >= 80 ? pal.success : layer.health_score >= 60 ? pal.warning : pal.error;
+ const healthBand = healthBand100(layer.health_score);
+ const healthColor =
+ healthBand === "healthy" ? pal.success : healthBand === "warning" ? pal.warning : pal.error;
parts.push(`<text x="${w - 14}" y="${h - 12}" font-family="${FONT_FAMILY}" font-size="12" font-weight="600" fill="${healthColor}" text-anchor="end">${Math.round(layer.health_score)}</text>`);
}
parts.push(`</g>`);
diff --git a/packages/ui/src/c4/panels/CodeViewer.tsx b/packages/ui/src/c4/panels/CodeViewer.tsx
index a30fe50bf..197526586 100644
--- a/packages/ui/src/c4/panels/CodeViewer.tsx
+++ b/packages/ui/src/c4/panels/CodeViewer.tsx
@@ -4,6 +4,7 @@ import { useState, useEffect, useCallback } from "react";
import { X, Maximize2, Minimize2, AlertCircle, RefreshCw } from "lucide-react";
import { useArchitectureStore } from "../store/use-architecture-store";
import { Badge } from "./panel-atoms";
+import { toFriendlyMessage } from "../../lib/errors";
const EXTENSION_MAP: Record<string, string> = {
py: "python",
@@ -79,7 +80,7 @@ export function CodeViewer({ fetchContent }: CodeViewerProps): React.ReactElemen
setLoading(false);
},
(err: unknown) => {
- setError(err instanceof Error ? err.message : String(err));
+ setError(toFriendlyMessage(err));
setLoading(false);
},
);
diff --git a/packages/ui/src/commits/commit-table.tsx b/packages/ui/src/commits/commit-table.tsx
index 8d68b3a81..1a83cb3a8 100644
--- a/packages/ui/src/commits/commit-table.tsx
+++ b/packages/ui/src/commits/commit-table.tsx
@@ -7,6 +7,7 @@ import { PriorityBadge } from "./priority-badge";
import { ChurnBar } from "../git/churn-bar";
import { Input } from "../ui/input";
import { EmptyState } from "../shared/empty-state";
+import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";
import { ResultsFooter } from "../shared/results-footer";
import { formatLOC, formatRelativeTime } from "../lib/format";
import { cn } from "../lib/cn";
@@ -36,6 +37,112 @@ export interface CommitTableProps {
type Filter = "all" | "high" | "fixes";
+type CommitRow = Commit & { _idx: number };
+
+const COLUMNS: ResponsiveColumn<CommitRow>[] = [
+ {
+ key: "rank",
+ header: "#",
+ headerClassName: "w-8",
+ hideInCard: true,
+ render: (c) => (
+ <span className="text-xs tabular-nums text-[var(--color-text-tertiary)]">{c._idx + 1}</span>
+ ),
+ },
+ {
+ key: "commit",
+ header: "Commit",
+ cellClassName: "min-w-[200px] max-w-[460px]",
+ render: (c) => (
+ <div className="flex items-center gap-2">
+ <span className="font-mono text-xs text-[var(--color-text-tertiary)] shrink-0">
+ {c.short_sha}
+ </span>
+ {c.is_fix && <Bug className="h-3 w-3 shrink-0 text-[var(--color-error)]" />}
+ <span className="truncate text-xs text-[var(--color-text-primary)]" title={c.subject}>
+ {c.subject || "(no subject)"}
+ </span>
+ </div>
+ ),
+ },
+ {
+ key: "author",
+ header: "Author",
+ priority: 2,
+ cellClassName: "max-w-[220px]",
+ render: (c) => (
+ <div className="flex items-center gap-1.5 min-w-0 text-xs text-[var(--color-text-secondary)]">
+ <span className="truncate">{c.author_name || "—"}</span>
+ {c.agent_name && <AgentBadge agentName={c.agent_name} tier={c.agent_autonomy_tier} />}
+ {!c.agent_name &&
+ c.author_experience != null &&
+ c.author_experience < NEW_CONTRIBUTOR_THRESHOLD && (
+ <NewContributorBadge experience={c.author_experience} />
+ )}
+ </div>
+ ),
+ mobileRender: (c) => c.author_name || "—",
+ },
+ {
+ key: "when",
+ header: "When",
+ headerClassName: "w-24",
+ priority: 3,
+ render: (c) => (
+ <span className="text-xs tabular-nums text-[var(--color-text-tertiary)]">
+ {c.committed_at ? formatRelativeTime(c.committed_at) : "—"}
+ </span>
+ ),
+ },
+ {
+ key: "lines",
+ header: "Lines",
+ headerClassName: "w-24",
+ priority: 3,
+ render: (c) => (
+ <span className="text-xs tabular-nums">
+ <span className="text-[var(--color-success)]">+{formatLOC(c.lines_added)}</span>{" "}
+ <span className="text-[var(--color-error)]">-{formatLOC(c.lines_deleted)}</span>
+ </span>
+ ),
+ },
+ {
+ key: "risk",
+ header: "Risk",
+ headerClassName: "w-40",
+ render: (c) => (
+ <div className="flex items-center gap-2">
+ <ChurnBar percentile={c.risk_percentile} className="w-16" />
+ <span className="text-xs text-[var(--color-text-tertiary)] tabular-nums w-8">
+ {Math.round(c.risk_percentile)}%
+ </span>
+ <PriorityBadge priority={c.review_priority as ReviewPriority} />
+ </div>
+ ),
+ mobileRender: (c) => (
+ <span className="inline-flex items-center gap-2">
+ <span className="tabular-nums">{Math.round(c.risk_percentile)}%</span>
+ <PriorityBadge priority={c.review_priority as ReviewPriority} />
+ </span>
+ ),
+ },
+ {
+ key: "top_driver",
+ header: "Top driver",
+ headerClassName: "max-xl:hidden",
+ cellClassName: "max-xl:hidden max-w-[220px]",
+ hideInCard: true,
+ render: (c) => (
+ <span
+ className="block truncate text-xs text-[var(--color-text-tertiary)]"
+ title={c.top_driver ?? undefined}
+ >
+ {c.top_driver ?? "—"}
+ </span>
+ ),
+ },
+];
+
/**
* The review-priority queue: per-commit change-risk, ranked. Ordering is
* server-driven (risk vs date); search + priority filters are client-side over
@@ -173,99 +280,16 @@ export function CommitTable({
{filtered.length === 0 ? (
<EmptyState title="No matches" description="Try adjusting your search or filters." />
) : (
- <div className="rounded-lg border border-[var(--color-border-default)] overflow-x-auto">
- <table className="w-full min-w-[720px] text-sm">
- <thead className="sticky top-0 z-10 bg-[var(--color-bg-elevated)]">
- <tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-elevated)]">
- <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-8">
- #
- </th>
- <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
- Commit
- </th>
- <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider hidden md:table-cell">
- Author
- </th>
- <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-24 hidden lg:table-cell">
- When
- </th>
- <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-24 hidden lg:table-cell">
- Lines
- </th>
- <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-40">
- Risk
- </th>
- <th className="px-3 py-2.5 text-left text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider hidden xl:table-cell">
- Top driver
- </th>
- </tr>
- </thead>
- <tbody>
- {filtered.map((c, i) => (
- <tr
- key={c.sha}
- onClick={onSelect ? () => onSelect(c) : undefined}
- className={cn(
- "border-b border-[var(--color-border-default)] last:border-0 hover:bg-[var(--color-bg-elevated)] transition-colors",
- onSelect && "cursor-pointer",
- )}
- >
- <td className="px-3 py-2.5 text-[var(--color-text-tertiary)] tabular-nums text-xs">
- {i + 1}
- </td>
- <td className="px-3 py-2.5 min-w-[200px] max-w-[460px]">
- <div className="flex items-center gap-2">
- <span className="font-mono text-xs text-[var(--color-text-tertiary)] shrink-0">
- {c.short_sha}
- </span>
- {c.is_fix && <Bug className="h-3 w-3 shrink-0 text-[var(--color-error)]" />}
- <span
- className="truncate text-xs text-[var(--color-text-primary)]"
- title={c.subject}
- >
- {c.subject || "(no subject)"}
- </span>
- </div>
- </td>
- <td className="px-3 py-2.5 text-xs text-[var(--color-text-secondary)] hidden md:table-cell max-w-[220px]">
- <div className="flex items-center gap-1.5 min-w-0">
- <span className="truncate">{c.author_name || "—"}</span>
- {c.agent_name && (
- <AgentBadge agentName={c.agent_name} tier={c.agent_autonomy_tier} />
- )}
- {!c.agent_name &&
- c.author_experience != null &&
- c.author_experience < NEW_CONTRIBUTOR_THRESHOLD && (
- <NewContributorBadge experience={c.author_experience} />
- )}
- </div>
- </td>
- <td className="px-3 py-2.5 text-xs text-[var(--color-text-tertiary)] tabular-nums hidden lg:table-cell">
- {c.committed_at ? formatRelativeTime(c.committed_at) : "—"}
- </td>
- <td className="px-3 py-2.5 text-xs tabular-nums hidden lg:table-cell">
- <span className="text-[var(--color-success)]">+{formatLOC(c.lines_added)}</span>{" "}
- <span className="text-[var(--color-error)]">-{formatLOC(c.lines_deleted)}</span>
- </td>
- <td className="px-3 py-2.5">
- <div className="flex items-center gap-2">
- <ChurnBar percentile={c.risk_percentile} className="w-16" />
- <span className="text-xs text-[var(--color-text-tertiary)] tabular-nums w-8">
- {Math.round(c.risk_percentile)}%
- </span>
- <PriorityBadge priority={c.review_priority as ReviewPriority} />
- </div>
- </td>
- <td
- className="px-3 py-2.5 text-xs text-[var(--color-text-tertiary)] hidden xl:table-cell max-w-[220px] truncate"
- title={c.top_driver ?? undefined}
- >
- {c.top_driver ?? "—"}
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ <div className="rounded-lg border border-[var(--color-border-default)] overflow-hidden">
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={filtered.map((c, i) => ({ ...c, _idx: i }))}
+ rowKey={(c) => c.sha}
+ caption="Commit review-priority queue"
+ {...(onSelect ? { onRowClick: onSelect } : {})}
+ stacked="sm"
+ bare
+ />
{total != null && (
<ResultsFooter
shown={filtered.length}
diff --git a/packages/ui/src/coupling/coupling-table.tsx b/packages/ui/src/coupling/coupling-table.tsx
index bed1d4a71..4a78534f4 100644
--- a/packages/ui/src/coupling/coupling-table.tsx
+++ b/packages/ui/src/coupling/coupling-table.tsx
@@ -3,7 +3,9 @@
import { useMemo } from "react";
import { EmptyState } from "../shared/empty-state";
import { VirtualizedTable } from "../shared/virtualized-table";
+import { clickableRowProps, CLICKABLE_ROW_CLS } from "../shared/responsive-table";
import { AiPromptButton } from "../health/ai-prompt-button";
+import { cn } from "../lib/cn";
import type { CouplingEdge } from "@repowise-dev/types/coupling";
interface CouplingTableProps {
@@ -93,10 +95,12 @@ export function CouplingTable({ edges, focusedPath, onFocusChange, onGeneratePro
const isSelected = focusedPath != null && focusedPath === e.source;
return (
<tr
- className={`border-t border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] ${
- isSelected ? "bg-[var(--color-accent-muted)]/30 " : ""
- }${onClick ? "cursor-pointer" : ""}`}
- onClick={onClick}
+ className={cn(
+ "border-t border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)]",
+ isSelected && "bg-[var(--color-accent-muted)]/30",
+ onClick && CLICKABLE_ROW_CLS,
+ )}
+ {...(onClick ? clickableRowProps(onClick) : {})}
>
<td className="px-3 py-2 text-left min-w-[200px]">
<div className="flex flex-col gap-0.5">
diff --git a/packages/ui/src/dashboard/attention-panel.tsx b/packages/ui/src/dashboard/attention-panel.tsx
index 5af459697..ca36cb78b 100644
--- a/packages/ui/src/dashboard/attention-panel.tsx
+++ b/packages/ui/src/dashboard/attention-panel.tsx
@@ -3,6 +3,7 @@
import { useState } from "react";
import {
AlertTriangle,
+ CheckCircle2,
Trash2,
Users,
FileWarning,
@@ -11,6 +12,7 @@ import {
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
import { Badge } from "../ui/badge";
import { stripMarkdown } from "../lib/format";
+import { EmptyState } from "../shared/empty-state";
import { fileEntityPath } from "../shared/entity/routes";
import { AiPromptButton } from "../health/ai-prompt-button";
import { AiPromptModal } from "../health/ai-prompt-modal";
@@ -106,10 +108,12 @@ export function AttentionPanel({
if (items.length === 0) {
return (
<Card>
- <CardContent className="p-6 text-center">
- <p className="text-sm text-[var(--color-success)]">
- No attention items — codebase looks healthy
- </p>
+ <CardContent className="p-2">
+ <EmptyState
+ icon={<CheckCircle2 className="h-8 w-8 text-[var(--color-success)]" />}
+ title="Nothing needs attention"
+ description="No hotspots, risky files, or stale docs right now."
+ />
</CardContent>
</Card>
);
diff --git a/packages/ui/src/dashboard/health-overview-card.tsx b/packages/ui/src/dashboard/health-overview-card.tsx
index 1214374c1..8d1367274 100644
--- a/packages/ui/src/dashboard/health-overview-card.tsx
+++ b/packages/ui/src/dashboard/health-overview-card.tsx
@@ -11,6 +11,7 @@ import {
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
import { fileEntityPath } from "../shared/entity/routes";
import { truncatePath } from "../lib/format";
+import { Sparkline } from "../health/sparkline";
export interface HealthOverviewPoint {
taken_at: string | null;
@@ -84,42 +85,6 @@ function TrendChip({ delta }: { delta: number | null | undefined }) {
);
}
-function Sparkline({ points }: { points: number[] }) {
- if (points.length < 2) return null;
- const w = 96;
- const h = 28;
- const min = Math.min(...points);
- const max = Math.max(...points);
- const span = max - min || 1;
- const step = w / (points.length - 1);
- const coords = points.map((v, i) => {
- const x = i * step;
- const y = h - 3 - ((v - min) / span) * (h - 6);
- return [x, y] as const;
- });
- const line = coords.map(([x, y], i) => `${i === 0 ? "M" : "L"}${x.toFixed(1)},${y.toFixed(1)}`).join(" ");
- const area = `${line} L${w},${h} L0,${h} Z`;
- return (
- <svg width={w} height={h} className="shrink-0" aria-hidden>
- <defs>
- <linearGradient id="health-spark" x1="0" y1="0" x2="0" y2="1">
- <stop offset="0%" stopColor="var(--color-accent-fill)" stopOpacity="0.28" />
- <stop offset="100%" stopColor="var(--color-accent-fill)" stopOpacity="0" />
- </linearGradient>
- </defs>
- <path d={area} fill="url(#health-spark)" />
- <path
- d={line}
- fill="none"
- stroke="var(--color-accent-primary)"
- strokeWidth={1.5}
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- );
-}
-
/** Severity-mix donut whose center is the open-findings headline count. */
function SeverityDonut({
segments,
@@ -221,7 +186,15 @@ function MetricTile({
{b.label}
</span>
)}
- {sparkline && <Sparkline points={sparkline} />}
+ {sparkline && sparkline.length >= 2 && (
+ <Sparkline
+ values={sparkline}
+ width={96}
+ height={28}
+ stroke="var(--color-accent-primary)"
+ fill="color-mix(in srgb, var(--color-accent-fill) 20%, transparent)"
+ />
+ )}
</div>
</>
)}
diff --git a/packages/ui/src/dashboard/health-score-ring.tsx b/packages/ui/src/dashboard/health-score-ring.tsx
index bc9b7ff36..9ca44ace9 100644
--- a/packages/ui/src/dashboard/health-score-ring.tsx
+++ b/packages/ui/src/dashboard/health-score-ring.tsx
@@ -3,6 +3,7 @@
import { useEffect, useState } from "react";
import { motion } from "framer-motion";
import { HelpCircle } from "lucide-react";
+import { healthInk100 } from "../health/tokens";
export interface HealthScoreComponent {
key: string;
@@ -25,12 +26,6 @@ interface HealthScoreRingProps {
note?: string;
}
-function getScoreColor(score: number): string {
- if (score >= 75) return "var(--color-success)";
- if (score >= 50) return "var(--color-warning)";
- return "var(--color-error)";
-}
-
function getScoreLabel(score: number): string {
if (score >= 80) return "Excellent";
if (score >= 65) return "Good";
@@ -48,7 +43,7 @@ export function HealthScoreRing({ score, size = 160, components, note }: HealthS
const radius = (size - strokeWidth) / 2;
const circumference = 2 * Math.PI * radius;
const progress = mounted ? (score / 100) * circumference : 0;
- const color = getScoreColor(score);
+ const color = healthInk100(score);
const hasBreakdown = components && components.length > 0;
return (
@@ -122,12 +117,7 @@ export function HealthScoreRing({ score, size = 160, components, note }: HealthS
)}
<ul className="space-y-2">
{components.map((c) => {
- const barColor =
- c.score >= 75
- ? "var(--color-success)"
- : c.score >= 50
- ? "var(--color-warning)"
- : "var(--color-error)";
+ const barColor = healthInk100(c.score);
return (
<li key={c.key} className="space-y-1">
<div className="flex items-baseline justify-between gap-3">
diff --git a/packages/ui/src/dead-code/dead-code-view.tsx b/packages/ui/src/dead-code/dead-code-view.tsx
index ee3684588..332a9a5fe 100644
--- a/packages/ui/src/dead-code/dead-code-view.tsx
+++ b/packages/ui/src/dead-code/dead-code-view.tsx
@@ -33,6 +33,7 @@ import { OwnerLeaderboard } from "./owner-leaderboard";
import { FindingsBreakdownGrid } from "./findings-breakdown-grid";
import { FindingsTable } from "./findings-table";
import type { DeadCodeAdapter } from "./dead-code-adapter";
+import { toFriendlyMessage } from "../lib/errors";
export function DeadCodeView({ adapter }: { adapter: DeadCodeAdapter }) {
const [analyzing, setAnalyzing] = useState(false);
@@ -77,7 +78,7 @@ export function DeadCodeView({ adapter }: { adapter: DeadCodeAdapter }) {
} catch (err) {
toast.error(
err instanceof Error
- ? `Couldn't start analysis: ${err.message}`
+ ? `Couldn't start analysis: ${toFriendlyMessage(err)}`
: "Couldn't start analysis",
);
} finally {
@@ -98,7 +99,7 @@ export function DeadCodeView({ adapter }: { adapter: DeadCodeAdapter }) {
await adapter.patchFinding(id, { status: previousStatus });
} catch (err) {
toast.error(
- err instanceof Error ? `Couldn't undo: ${err.message}` : "Couldn't undo",
+ `Couldn't undo: ${toFriendlyMessage(err)}`,
);
}
},
diff --git a/packages/ui/src/dead-code/findings-table.tsx b/packages/ui/src/dead-code/findings-table.tsx
index 0ba4f74a0..cbd3e7a2e 100644
--- a/packages/ui/src/dead-code/findings-table.tsx
+++ b/packages/ui/src/dead-code/findings-table.tsx
@@ -3,7 +3,9 @@
import { useMemo, useState } from "react";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "../ui/tabs";
import { Button } from "../ui/button";
-import { Skeleton } from "../ui/skeleton";
+import { Slider } from "../ui/slider";
+import { Switch } from "../ui/switch";
+import { TableSkeleton } from "../shared/loading-skeletons";
import { ConfirmDialog } from "../ui/confirm-dialog";
import { EmptyState } from "../shared/empty-state";
import { FindingRow } from "./finding-row";
@@ -120,25 +122,19 @@ export function FindingsTable({ findings, repoId, onPatch, onBulkResolve, isLoad
<label htmlFor="min-confidence" className="text-xs text-[var(--color-text-secondary)]">
Min confidence: {Math.round(minConfidence * 100)}%
</label>
- <input
+ <Slider
id="min-confidence"
- type="range"
- min="0.4"
- max="1"
- step="0.05"
- value={minConfidence}
- onChange={(e) => setMinConfidence(Number(e.target.value))}
- aria-valuetext={`${Math.round(minConfidence * 100)} percent`}
- className="w-28 accent-[var(--color-accent-primary)]"
+ min={0.4}
+ max={1}
+ step={0.05}
+ value={[minConfidence]}
+ onValueChange={([v]) => setMinConfidence(v ?? 0.4)}
+ aria-label="Minimum confidence"
+ className="w-28"
/>
</div>
<label className="flex items-center gap-1.5 text-xs text-[var(--color-text-secondary)] cursor-pointer select-none">
- <input
- type="checkbox"
- checked={safeOnly}
- onChange={(e) => setSafeOnly(e.target.checked)}
- className="rounded border-[var(--color-border-default)]"
- />
+ <Switch checked={safeOnly} onCheckedChange={setSafeOnly} />
Cleanup-ready only
</label>
@@ -189,11 +185,7 @@ export function FindingsTable({ findings, repoId, onPatch, onBulkResolve, isLoad
{TABS.map((t) => (
<TabsContent key={t.value} value={t.value}>
{isLoading && current.length === 0 ? (
- <div className="space-y-2 mt-2">
- {Array.from({ length: 6 }).map((_, i) => (
- <Skeleton key={i} className="h-10 w-full" />
- ))}
- </div>
+ <TableSkeleton className="mt-2" />
) : current.length === 0 ? (
<EmptyState
title="No findings"
diff --git a/packages/ui/src/decisions/decision-detail.tsx b/packages/ui/src/decisions/decision-detail.tsx
index c0933bd9f..62adf50d3 100644
--- a/packages/ui/src/decisions/decision-detail.tsx
+++ b/packages/ui/src/decisions/decision-detail.tsx
@@ -43,6 +43,7 @@ import type {
DecisionDetailAdapter,
DecisionLinkComponent,
} from "./decision-detail-adapter";
+import { toFriendlyMessage } from "../lib/errors";
const STATUS_VARIANT: Record<
string,
@@ -155,7 +156,7 @@ export function DecisionDetail({ decision, adapter }: DecisionDetailProps) {
setLinkedFiles(previousFiles);
} catch (err) {
toast.error(
- err instanceof Error ? `Couldn't undo: ${err.message}` : "Couldn't undo",
+ `Couldn't undo: ${toFriendlyMessage(err)}`,
);
}
},
@@ -165,7 +166,7 @@ export function DecisionDetail({ decision, adapter }: DecisionDetailProps) {
} catch (err) {
toast.error(
err instanceof Error
- ? `Couldn't save linkage: ${err.message}`
+ ? `Couldn't save linkage: ${toFriendlyMessage(err)}`
: "Couldn't save linkage",
);
} finally {
@@ -189,7 +190,7 @@ export function DecisionDetail({ decision, adapter }: DecisionDetailProps) {
setStatus(previous);
} catch (err) {
toast.error(
- err instanceof Error ? `Couldn't undo: ${err.message}` : "Couldn't undo",
+ `Couldn't undo: ${toFriendlyMessage(err)}`,
);
}
},
@@ -199,7 +200,7 @@ export function DecisionDetail({ decision, adapter }: DecisionDetailProps) {
} catch (err) {
toast.error(
err instanceof Error
- ? `Couldn't update decision: ${err.message}`
+ ? `Couldn't update decision: ${toFriendlyMessage(err)}`
: "Couldn't update decision",
);
} finally {
diff --git a/packages/ui/src/files/files-treemap.tsx b/packages/ui/src/files/files-treemap.tsx
index a3a748f58..114a79656 100644
--- a/packages/ui/src/files/files-treemap.tsx
+++ b/packages/ui/src/files/files-treemap.tsx
@@ -5,6 +5,7 @@ import { hierarchy, treemap, treemapSquarify, type HierarchyRectangularNode } fr
import type { FileRow } from "@repowise-dev/types/files";
import { ChevronRight, FolderOpen } from "lucide-react";
import { cn } from "../lib/cn";
+import { healthInk } from "../health/tokens";
export type TreemapSize = "importance" | "loc";
export type TreemapColor = "health" | "language";
@@ -53,9 +54,7 @@ function langColor(lang: string): string {
/** Health score (0-10) → traffic-light fill. Null reads neutral. */
function healthColor(score: number | null): string {
if (score == null) return "var(--color-text-tertiary)";
- if (score < 4) return "var(--color-risk-high)";
- if (score < 7) return "var(--color-risk-medium)";
- return "var(--color-risk-low)";
+ return healthInk(score);
}
function sizeValue(row: FileRow, sizeBy: TreemapSize): number {
diff --git a/packages/ui/src/git/hotspot-table.tsx b/packages/ui/src/git/hotspot-table.tsx
index f8283637f..190a9b60b 100644
--- a/packages/ui/src/git/hotspot-table.tsx
+++ b/packages/ui/src/git/hotspot-table.tsx
@@ -13,6 +13,7 @@ import { ChurnBar } from "./churn-bar";
import { formatLOC } from "../lib/format";
import { cn } from "../lib/cn";
import { useVirtualRows } from "../shared/virtualized-table";
+import { clickableRowProps, CLICKABLE_ROW_CLS } from "../shared/responsive-table";
import type { Hotspot } from "@repowise-dev/types/git";
/**
@@ -236,27 +237,42 @@ export function HotspotTable({
<th
scope="col"
aria-sort={ariaSortFor("commits", sortKey, sortDir)}
- className="px-3 py-2.5 text-right text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-24 cursor-pointer select-none hover:text-[var(--color-text-secondary)]"
- onClick={() => handleSort("commits")}
+ className="px-3 py-2.5 text-right text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-24"
>
- Commits 90d<SortIcon column="commits" sortKey={sortKey} sortDir={sortDir} />
+ <button
+ type="button"
+ className="cursor-pointer select-none uppercase tracking-wider font-medium hover:text-[var(--color-text-secondary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)] rounded"
+ onClick={() => handleSort("commits")}
+ >
+ Commits 90d<SortIcon column="commits" sortKey={sortKey} sortDir={sortDir} />
+ </button>
</th>
<th
scope="col"
aria-sort={ariaSortFor("churn", sortKey, sortDir)}
- className="px-3 py-2.5 text-left text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-32 cursor-pointer select-none hover:text-[var(--color-text-secondary)] hidden lg:table-cell"
- onClick={() => handleSort("churn")}
+ className="px-3 py-2.5 text-left text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-32 hidden lg:table-cell"
>
- Churn<SortIcon column="churn" sortKey={sortKey} sortDir={sortDir} />
+ <button
+ type="button"
+ className="cursor-pointer select-none uppercase tracking-wider font-medium hover:text-[var(--color-text-secondary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)] rounded"
+ onClick={() => handleSort("churn")}
+ >
+ Churn<SortIcon column="churn" sortKey={sortKey} sortDir={sortDir} />
+ </button>
</th>
<th
scope="col"
aria-sort={ariaSortFor("trend", sortKey, sortDir)}
- className="px-3 py-2.5 text-right text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-24 cursor-pointer select-none hover:text-[var(--color-text-secondary)]"
- onClick={() => handleSort("trend")}
- title="Exponential decay score weighting recent commits more heavily (180-day half-life)"
+ className="px-3 py-2.5 text-right text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-24"
>
- Trend<SortIcon column="trend" sortKey={sortKey} sortDir={sortDir} />
+ <button
+ type="button"
+ className="cursor-pointer select-none uppercase tracking-wider font-medium hover:text-[var(--color-text-secondary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)] rounded"
+ onClick={() => handleSort("trend")}
+ title="Exponential decay score weighting recent commits more heavily (180-day half-life)"
+ >
+ Trend<SortIcon column="trend" sortKey={sortKey} sortDir={sortDir} />
+ </button>
</th>
<th className="px-3 py-2.5 text-left text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-20 hidden md:table-cell">
Bus Factor
@@ -287,11 +303,11 @@ export function HotspotTable({
return (
<tbody key={h.file_path} ref={measureElement} data-index={i}>
<tr
- onClick={onSelect ? () => onSelect(h) : undefined}
+ {...(onSelect ? clickableRowProps(() => onSelect(h)) : {})}
className={cn(
"border-b border-[var(--color-table-divider)] hover:bg-[var(--color-bg-elevated)] transition-colors group",
!isExpanded && "last:border-0",
- onSelect && "cursor-pointer",
+ onSelect && CLICKABLE_ROW_CLS,
)}
>
{expandable && (
diff --git a/packages/ui/src/git/risk-distribution-chart.tsx b/packages/ui/src/git/risk-distribution-chart.tsx
index 9627e33fe..355cce1ee 100644
--- a/packages/ui/src/git/risk-distribution-chart.tsx
+++ b/packages/ui/src/git/risk-distribution-chart.tsx
@@ -12,6 +12,7 @@ import {
ReferenceLine,
} from "recharts";
import type { Hotspot } from "@repowise-dev/types/git";
+import { riskInk } from "../health/tokens";
interface RiskDistributionChartProps {
hotspots: Hotspot[];
@@ -31,10 +32,7 @@ function computeRiskScore(h: Hotspot): number {
}
function riskColor(score: number): string {
- if (score >= 70) return "var(--color-error)";
- if (score >= 45) return "var(--color-accent-fill)";
- if (score >= 25) return "var(--color-warning)";
- return "var(--color-success)";
+ return riskInk(score / 100);
}
export function RiskDistributionChart({ hotspots, maxBars = 30 }: RiskDistributionChartProps) {
diff --git a/packages/ui/src/graph/centrality-leaderboard.tsx b/packages/ui/src/graph/centrality-leaderboard.tsx
index 330370729..5ea234026 100644
--- a/packages/ui/src/graph/centrality-leaderboard.tsx
+++ b/packages/ui/src/graph/centrality-leaderboard.tsx
@@ -1,7 +1,8 @@
"use client";
import { useState } from "react";
-import { ChevronLeft, ChevronRight, Crown } from "lucide-react";
+import { ChevronLeft, ChevronRight, Crown, Info } from "lucide-react";
+import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
import { cn } from "../lib/cn";
export interface CentralityNode {
@@ -30,6 +31,15 @@ const METRIC_LABEL: Record<string, string> = {
degree: "Degree (in+out)",
};
+const METRIC_EXPLAINER: Record<string, string> = {
+ pagerank:
+ "How much of the codebase depends on this file, directly or transitively. High PageRank files are load-bearing: many import paths flow through them.",
+ betweenness:
+ "How often this file sits on the shortest path between two other files. High betweenness marks bridges between otherwise separate parts of the codebase.",
+ degree:
+ "Direct connections only: imports into the file plus imports out of it. A simple measure of how busy the file's immediate neighborhood is.",
+};
+
function score(node: CentralityNode, metric: "pagerank" | "betweenness" | "degree"): number {
if (metric === "pagerank") return node.pagerank;
if (metric === "betweenness") return node.betweenness ?? 0;
@@ -64,6 +74,29 @@ export function CentralityLeaderboard({
<span className="text-xs font-medium text-[var(--color-text-primary)] truncate">
Centrality
</span>
+ <Popover>
+ <PopoverTrigger asChild>
+ <button
+ type="button"
+ aria-label="What do these metrics mean?"
+ className="inline-flex shrink-0 items-center rounded-sm text-[var(--color-text-tertiary)] hover:text-[var(--color-text-secondary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)]"
+ >
+ <Info className="h-3 w-3" aria-hidden />
+ </button>
+ </PopoverTrigger>
+ <PopoverContent align="start" className="space-y-2">
+ {(["pagerank", "betweenness", "degree"] as const).map((m) => (
+ <div key={m}>
+ <p className="font-medium text-[var(--color-text-primary)]">
+ {METRIC_LABEL[m]}
+ </p>
+ <p className="text-[var(--color-text-secondary)] leading-relaxed">
+ {METRIC_EXPLAINER[m]}
+ </p>
+ </div>
+ ))}
+ </PopoverContent>
+ </Popover>
</div>
)}
<button
@@ -78,7 +111,7 @@ export function CentralityLeaderboard({
{!collapsed && (
<>
- <div className="flex border-b border-[var(--color-border-default)] text-[10px]">
+ <div className="flex border-b border-[var(--color-border-default)] text-caption">
{(["pagerank", "betweenness", "degree"] as const).map((m) => (
<button
key={m}
@@ -112,7 +145,7 @@ export function CentralityLeaderboard({
)}
title={n.node_id}
>
- <span className="text-[10px] tabular-nums text-[var(--color-text-tertiary)] w-4 text-right">
+ <span className="text-caption tabular-nums text-[var(--color-text-tertiary)] w-4 text-right">
{i + 1}
</span>
<div className="min-w-0 flex-1">
@@ -126,7 +159,7 @@ export function CentralityLeaderboard({
/>
</div>
</div>
- <span className="text-[10px] tabular-nums text-[var(--color-text-tertiary)] shrink-0">
+ <span className="text-caption tabular-nums text-[var(--color-text-tertiary)] shrink-0">
{metric === "degree" ? v.toFixed(0) : v.toFixed(3)}
</span>
</button>
diff --git a/packages/ui/src/graph/graph-inspection-panel.tsx b/packages/ui/src/graph/graph-inspection-panel.tsx
index a3ce8db35..07add52f4 100644
--- a/packages/ui/src/graph/graph-inspection-panel.tsx
+++ b/packages/ui/src/graph/graph-inspection-panel.tsx
@@ -160,7 +160,7 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
<p className="text-sm font-semibold text-[var(--color-text-primary)] truncate">
{nodeId.split("/").pop()}
</p>
- <p className="text-[10px] text-[var(--color-text-tertiary)] truncate mt-0.5" title={data.fullPath}>
+ <p className="text-caption text-[var(--color-text-tertiary)] truncate mt-0.5" title={data.fullPath}>
{data.fullPath}
</p>
</div>
@@ -210,7 +210,7 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
{n.label}
</p>
</div>
- <span className="text-[10px] text-[var(--color-text-tertiary)] shrink-0">
+ <span className="text-caption text-[var(--color-text-tertiary)] shrink-0">
{n.direction === "importer" ? "imports this" : "imported"}
</span>
</button>
@@ -224,17 +224,17 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
{onEgoDepthChange && (
<div className="px-4 py-3 border-t border-[var(--color-border-default)]">
<div className="flex items-center justify-between mb-1.5">
- <span className="text-[10px] font-medium text-[var(--color-text-secondary)]">
+ <span className="text-caption font-medium text-[var(--color-text-secondary)]">
Ego Graph
</span>
{egoDepth != null && egoDepth > 0 && egoVisibleCount != null && (
- <span className="text-[10px] text-[var(--color-text-tertiary)] tabular-nums">
+ <span className="text-caption text-[var(--color-text-tertiary)] tabular-nums">
{egoVisibleCount} nodes
</span>
)}
</div>
<div className="flex items-center gap-2">
- <span className="text-[10px] text-[var(--color-text-tertiary)] w-4 text-right tabular-nums">
+ <span className="text-caption text-[var(--color-text-tertiary)] w-4 text-right tabular-nums">
{egoDepth ?? 0}
</span>
<input
@@ -246,9 +246,9 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
className="flex-1 h-1 accent-[var(--color-accent-graph)] cursor-pointer"
aria-label="Ego graph depth"
/>
- <span className="text-[10px] text-[var(--color-text-tertiary)]">5</span>
+ <span className="text-caption text-[var(--color-text-tertiary)]">5</span>
</div>
- <p className="text-[10px] text-[var(--color-text-tertiary)] mt-1">
+ <p className="text-caption text-[var(--color-text-tertiary)] mt-1">
{(egoDepth ?? 0) === 0
? "Slide to filter by hop distance"
: `Showing nodes within ${egoDepth} hop${egoDepth === 1 ? "" : "s"}`}
@@ -261,7 +261,7 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
{!isMod && filePageHref && (
<a
href={filePageHref}
- className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-accent-graph)]/10 hover:bg-[var(--color-accent-graph)]/20 border border-[var(--color-accent-graph)]/30 px-2 py-1.5 text-[10px] font-medium text-[var(--color-accent-graph)] transition-colors col-span-2"
+ className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-accent-graph)]/10 hover:bg-[var(--color-accent-graph)]/20 border border-[var(--color-accent-graph)]/30 px-2 py-1.5 text-caption font-medium text-[var(--color-accent-graph)] transition-colors col-span-2"
>
<FileText className="w-3 h-3" /> Open file page
</a>
@@ -269,7 +269,7 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
{isMod && onExpandModule && (
<button
onClick={onExpandModule}
- className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-accent-graph)]/10 hover:bg-[var(--color-accent-graph)]/20 border border-[var(--color-accent-graph)]/30 px-2 py-1.5 text-[10px] font-medium text-[var(--color-accent-graph)] transition-colors col-span-2"
+ className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-accent-graph)]/10 hover:bg-[var(--color-accent-graph)]/20 border border-[var(--color-accent-graph)]/30 px-2 py-1.5 text-caption font-medium text-[var(--color-accent-graph)] transition-colors col-span-2"
>
<Network className="w-3 h-3" /> Expand Module
</button>
@@ -277,7 +277,7 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
{onViewDocs && (
<button
onClick={onViewDocs}
- className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-bg-inset)] hover:bg-[var(--color-bg-surface)] border border-[var(--color-border-default)] px-2 py-1.5 text-[10px] font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors"
+ className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-bg-inset)] hover:bg-[var(--color-bg-surface)] border border-[var(--color-border-default)] px-2 py-1.5 text-caption font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors"
>
<BookOpen className="w-3 h-3" /> View Docs
</button>
@@ -285,7 +285,7 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
{!isMod && onViewSymbols && (
<button
onClick={onViewSymbols}
- className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-bg-inset)] hover:bg-[var(--color-bg-surface)] border border-[var(--color-border-default)] px-2 py-1.5 text-[10px] font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors"
+ className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-bg-inset)] hover:bg-[var(--color-bg-surface)] border border-[var(--color-border-default)] px-2 py-1.5 text-caption font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors"
>
<Code2 className="w-3 h-3" /> Symbols
</button>
@@ -293,7 +293,7 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
{onFindPath && (
<button
onClick={onFindPath}
- className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-bg-inset)] hover:bg-[var(--color-bg-surface)] border border-[var(--color-border-default)] px-2 py-1.5 text-[10px] font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors"
+ className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-bg-inset)] hover:bg-[var(--color-bg-surface)] border border-[var(--color-border-default)] px-2 py-1.5 text-caption font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors"
>
<Route className="w-3 h-3" /> Find Path
</button>
@@ -301,7 +301,7 @@ export const GraphInspectionPanel = memo(function GraphInspectionPanel({
{!isMod && onShowEgoGraph && (
<button
onClick={onShowEgoGraph}
- className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-bg-inset)] hover:bg-[var(--color-bg-surface)] border border-[var(--color-border-default)] px-2 py-1.5 text-[10px] font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors"
+ className="flex items-center justify-center gap-1.5 rounded-lg bg-[var(--color-bg-inset)] hover:bg-[var(--color-bg-surface)] border border-[var(--color-border-default)] px-2 py-1.5 text-caption font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors"
>
<Network className="w-3 h-3" /> Ego Graph
</button>
@@ -386,21 +386,21 @@ function FileMetadata({
<div className="flex items-center gap-1.5 pt-1 flex-wrap">
{data.isEntryPoint && (
- <span className="inline-flex items-center gap-1 rounded-md bg-[var(--color-accent-graph)]/10 text-[var(--color-accent-graph)] px-1.5 py-0.5 text-[10px] font-medium">
+ <span className="inline-flex items-center gap-1 rounded-md bg-[var(--color-accent-graph)]/10 text-[var(--color-accent-graph)] px-1.5 py-0.5 text-caption font-medium">
<Zap className="w-2.5 h-2.5" /> Entry Point
</span>
)}
{data.isTest && (
- <span className="inline-flex items-center gap-1 rounded-md bg-[var(--color-accent-secondary)]/10 text-[var(--color-accent-secondary)] px-1.5 py-0.5 text-[10px] font-medium">
+ <span className="inline-flex items-center gap-1 rounded-md bg-[var(--color-accent-secondary)]/10 text-[var(--color-accent-secondary)] px-1.5 py-0.5 text-caption font-medium">
<FlaskConical className="w-2.5 h-2.5" /> Test
</span>
)}
{data.hasDoc ? (
- <span className="inline-flex items-center gap-1 rounded-md bg-[var(--color-success)]/10 text-[var(--color-success)] px-1.5 py-0.5 text-[10px] font-medium">
+ <span className="inline-flex items-center gap-1 rounded-md bg-[var(--color-success)]/10 text-[var(--color-success)] px-1.5 py-0.5 text-caption font-medium">
<BookOpen className="w-2.5 h-2.5" /> Documented
</span>
) : (
- <span className="inline-flex items-center gap-1 rounded-md bg-[var(--color-bg-inset)] text-[var(--color-text-tertiary)] px-1.5 py-0.5 text-[10px] font-medium">
+ <span className="inline-flex items-center gap-1 rounded-md bg-[var(--color-bg-inset)] text-[var(--color-text-tertiary)] px-1.5 py-0.5 text-caption font-medium">
<BookOpen className="w-2.5 h-2.5" /> No docs
</span>
)}
diff --git a/packages/ui/src/health/biomarker-chip.tsx b/packages/ui/src/health/biomarker-chip.tsx
index 9f9294d9e..26a40c107 100644
--- a/packages/ui/src/health/biomarker-chip.tsx
+++ b/packages/ui/src/health/biomarker-chip.tsx
@@ -1,6 +1,7 @@
"use client";
import { Info } from "lucide-react";
+import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
import {
biomarkerInfo,
biomarkerDimension,
@@ -14,18 +15,48 @@ export interface BiomarkerChipProps {
className?: string;
}
+/**
+ * A biomarker label with its glossary entry in a click/keyboard popover, so
+ * the definition is reachable on touch and by keyboard, not just mouse hover.
+ */
export function BiomarkerChip({ type, showInfo = true, className = "" }: BiomarkerChipProps) {
const info = biomarkerInfo(type);
- const title = `${info.label} · ${CATEGORY_LABEL[info.category]} · ${DIMENSION_LABEL[biomarkerDimension(type)]}\n\n${info.description}`;
+ const dimension = biomarkerDimension(type);
+
+ if (!showInfo || !info.description) {
+ return (
+ <span
+ className={`inline-flex items-center gap-1 text-xs font-medium text-[var(--color-text-primary)] ${className}`}
+ >
+ {info.label}
+ </span>
+ );
+ }
+
return (
- <span
- className={`inline-flex items-center gap-1 text-xs font-medium text-[var(--color-text-primary)] ${className}`}
- title={title}
- >
- {info.label}
- {showInfo && info.description ? (
- <Info className="h-3 w-3 text-[var(--color-text-tertiary)]" aria-hidden />
- ) : null}
- </span>
+ <Popover>
+ <PopoverTrigger asChild>
+ <button
+ type="button"
+ onClick={(e) => e.stopPropagation()}
+ aria-label={`What is ${info.label}?`}
+ className={`inline-flex items-center gap-1 text-xs font-medium text-[var(--color-text-primary)] rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)] ${className}`}
+ >
+ {info.label}
+ <Info className="h-3 w-3 text-[var(--color-text-tertiary)]" aria-hidden />
+ </button>
+ </PopoverTrigger>
+ <PopoverContent
+ align="start"
+ onClick={(e) => e.stopPropagation()}
+ className="space-y-1.5"
+ >
+ <p className="font-medium text-[var(--color-text-primary)]">{info.label}</p>
+ <p className="text-[var(--color-text-tertiary)]">
+ {CATEGORY_LABEL[info.category]} · {DIMENSION_LABEL[dimension]}
+ </p>
+ <p className="text-[var(--color-text-secondary)] leading-relaxed">{info.description}</p>
+ </PopoverContent>
+ </Popover>
);
}
diff --git a/packages/ui/src/health/module-rollup-list.tsx b/packages/ui/src/health/module-rollup-list.tsx
index c05623770..c3ccf4139 100644
--- a/packages/ui/src/health/module-rollup-list.tsx
+++ b/packages/ui/src/health/module-rollup-list.tsx
@@ -1,7 +1,7 @@
"use client";
import { useMemo, useState } from "react";
-import { ArrowDown, ArrowUp } from "lucide-react";
+import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";
import { HealthBadge } from "./health-badge";
export interface ModuleRollupRow {
@@ -22,6 +22,60 @@ export interface ModuleRollupListProps {
type SortKey = "average_health" | "file_count" | "nloc" | "module";
+const SORT_KEYS: SortKey[] = ["average_health", "file_count", "nloc", "module"];
+
+const COLUMNS: ResponsiveColumn<ModuleRollupRow>[] = [
+ {
+ key: "module",
+ header: "Module",
+ sortable: true,
+ render: (m) => (
+ <span className="font-medium text-[var(--color-text-primary)]">{m.module}</span>
+ ),
+ },
+ {
+ key: "file_count",
+ header: "Files",
+ sortable: true,
+ render: (m) => (
+ <span className="tabular-nums text-[var(--color-text-secondary)]">{m.file_count}</span>
+ ),
+ },
+ {
+ key: "nloc",
+ header: "NLOC",
+ sortable: true,
+ priority: 2,
+ render: (m) => (
+ <span className="tabular-nums text-[var(--color-text-secondary)]">
+ {m.nloc.toLocaleString()}
+ </span>
+ ),
+ },
+ {
+ key: "average_health",
+ header: "Avg health",
+ sortable: true,
+ render: (m) => <HealthBadge score={m.average_health} />,
+ },
+ {
+ key: "worst_performer_path",
+ header: "Worst file",
+ priority: 3,
+ render: (m) => (
+ <span
+ className="block truncate max-w-[280px] font-mono text-xs text-[var(--color-text-secondary)]"
+ title={m.worst_performer_path}
+ >
+ {m.worst_performer_path}{" "}
+ <span className="text-[var(--color-text-tertiary)]">
+ ({m.worst_performer_score.toFixed(1)})
+ </span>
+ </span>
+ ),
+ },
+];
+
export function ModuleRollupList({
modules,
emptyMessage = "No modules detected yet. Community labels populate after the first index.",
@@ -54,49 +108,29 @@ export function ModuleRollupList({
}
const visible = expanded ? sorted : sorted.slice(0, pageSize);
- const toggle = (key: SortKey) => {
+ const toggle = (key: string) => {
+ if (!SORT_KEYS.includes(key as SortKey)) return;
if (sort === key) setOrder((o) => (o === "asc" ? "desc" : "asc"));
else {
- setSort(key);
+ setSort(key as SortKey);
setOrder(key === "average_health" ? "asc" : "desc");
}
};
return (
<div className="border border-[var(--color-border-default)] overflow-hidden">
- <table className="w-full text-sm">
- <thead className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-surface)] text-[var(--color-text-tertiary)] text-[11px] uppercase tracking-wider">
- <tr>
- <Th label="Module" active={sort === "module"} order={order} onClick={() => toggle("module")} />
- <Th label="Files" active={sort === "file_count"} order={order} onClick={() => toggle("file_count")} />
- <Th label="NLOC" active={sort === "nloc"} order={order} onClick={() => toggle("nloc")} />
- <Th label="Avg health" active={sort === "average_health"} order={order} onClick={() => toggle("average_health")} />
- <th className="text-left px-3 py-2">Worst file</th>
- </tr>
- </thead>
- <tbody>
- {visible.map((m) => (
- <tr
- key={m.module}
- className={`group border-t border-[var(--color-table-divider)] ${onSelect ? "cursor-pointer hover:bg-[var(--color-bg-elevated)]" : ""}`}
- onClick={onSelect ? () => onSelect(m) : undefined}
- >
- <td className="px-3 py-2 font-medium text-[var(--color-text-primary)]">
- <span className="group-hover:underline underline-offset-2">{m.module}</span>
- </td>
- <td className="px-3 py-2 tabular-nums text-[var(--color-text-secondary)]">{m.file_count}</td>
- <td className="px-3 py-2 tabular-nums text-[var(--color-text-secondary)]">{m.nloc.toLocaleString()}</td>
- <td className="px-3 py-2">
- <HealthBadge score={m.average_health} />
- </td>
- <td className="px-3 py-2 font-mono text-xs text-[var(--color-text-secondary)] truncate max-w-[280px]" title={m.worst_performer_path}>
- {m.worst_performer_path}{" "}
- <span className="text-[var(--color-text-tertiary)]">({m.worst_performer_score.toFixed(1)})</span>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
+ <ResponsiveTable
+ columns={COLUMNS}
+ rows={visible}
+ rowKey={(m) => m.module}
+ caption="Module health rollup"
+ sortField={sort}
+ sortOrder={order}
+ onSort={toggle}
+ {...(onSelect ? { onRowClick: onSelect } : {})}
+ stacked="sm"
+ bare
+ />
{modules.length > pageSize ? (
<div className="border-t border-[var(--color-border-default)] px-3 py-2 text-xs text-[var(--color-text-tertiary)]">
<button
@@ -111,27 +145,3 @@ export function ModuleRollupList({
</div>
);
}
-
-function Th({
- label,
- active,
- order,
- onClick,
-}: {
- label: string;
- active: boolean;
- order: "asc" | "desc";
- onClick: () => void;
-}) {
- return (
- <th
- className="text-left px-3 py-2 font-medium cursor-pointer select-none"
- onClick={onClick}
- >
- <span className="inline-flex items-center gap-1">
- {label}
- {active ? (order === "asc" ? <ArrowUp className="h-3 w-3" /> : <ArrowDown className="h-3 w-3" />) : null}
- </span>
- </th>
- );
-}
diff --git a/packages/ui/src/health/tokens.ts b/packages/ui/src/health/tokens.ts
index bbc2d3da5..31654faea 100644
--- a/packages/ui/src/health/tokens.ts
+++ b/packages/ui/src/health/tokens.ts
@@ -7,7 +7,7 @@
* caution/success) so the surface themes correctly in both modes.
*/
-import type { HealthBand } from "@repowise-dev/types/health";
+import { bandForScore, type HealthBand } from "@repowise-dev/types/health";
export type Severity = "critical" | "high" | "medium" | "low";
@@ -120,6 +120,44 @@ export function scoreSoftBadgeClass(score: number): string {
return BAND_BADGE_SOFT[scoreBand(score)];
}
+/* Raw CSS custom-property references per canonical band, for SVG/canvas
+ * fills and inline styles where a class string cannot be used. */
+const HEALTH_BAND_INK: Record<HealthBand, string> = {
+ alert: "var(--color-error)",
+ warning: "var(--color-warning)",
+ healthy: "var(--color-success)",
+};
+
+/**
+ * Canonical banding for a higher-is-better health score on the 0-10 scale,
+ * as an ink color usable in `style`/SVG attributes. Thresholds come from the
+ * shared `bandForScore` mirror so every surface agrees on what counts as red.
+ */
+export function healthInk(score10: number): string {
+ return HEALTH_BAND_INK[bandForScore(score10)];
+}
+
+/** `healthInk` for scores expressed on a 0-100 scale. */
+export function healthInk100(score100: number): string {
+ return healthInk(score100 / 10);
+}
+
+/** `bandForScore` for scores expressed on a 0-100 scale. */
+export function healthBand100(score100: number): HealthBand {
+ return bandForScore(score100 / 10);
+}
+
+/**
+ * Banding for a higher-is-worse risk value on the 0-1 scale, as an ink
+ * color. Matches the impact-graph node banding (>=0.66 alert, >=0.33
+ * warning) so risk reads the same across tables, charts, and graphs.
+ */
+export function riskInk(risk01: number): string {
+ if (risk01 >= 0.66) return "var(--color-error)";
+ if (risk01 >= 0.33) return "var(--color-warning)";
+ return "var(--color-success)";
+}
+
export function coverageColor(pct: number): string {
if (pct < 30) return "bg-[var(--color-error)]";
if (pct < 60) return "bg-[var(--color-warning)]";
diff --git a/packages/ui/src/lib/errors.ts b/packages/ui/src/lib/errors.ts
new file mode 100644
index 000000000..f7c250e74
--- /dev/null
+++ b/packages/ui/src/lib/errors.ts
@@ -0,0 +1,32 @@
+/**
+ * Error-to-copy mapping shared by every surface that shows a failure to the
+ * user. Raw `error.message` leaks implementation detail ("TypeError: Failed
+ * to fetch", "[object Object]"); this keeps server-provided messages, which
+ * are written for users, and translates the technical ones.
+ */
+
+const NETWORK_RE = /failed to fetch|network ?error|fetch failed|load failed|ECONNREFUSED|ERR_CONNECTION/i;
+const ABORT_RE = /\baborted?\b|abort ?error/i;
+
+export const DEFAULT_ERROR_MESSAGE = "Something went wrong. Please try again.";
+
+export function toFriendlyMessage(
+ error: unknown,
+ fallback: string = DEFAULT_ERROR_MESSAGE,
+): string {
+ // Anything message-shaped counts (DOMException is not an Error everywhere).
+ const raw =
+ typeof error === "string"
+ ? error
+ : typeof (error as { message?: unknown } | null)?.message === "string"
+ ? (error as { message: string }).message
+ : "";
+ if (!raw || raw === "[object Object]") return fallback;
+ if (NETWORK_RE.test(raw)) {
+ return "Could not reach the server. Check that it is running and try again.";
+ }
+ if (ABORT_RE.test(raw)) return "The request was cancelled.";
+ // Drop a leaked error-class prefix; the message itself is usually usable.
+ const cleaned = raw.replace(/^(?:[A-Z][a-zA-Z]*Error|Error):\s*/, "").trim();
+ return cleaned || fallback;
+}
diff --git a/packages/ui/src/modules/module-helpers.tsx b/packages/ui/src/modules/module-helpers.tsx
index e2cf841a5..0366bfa28 100644
--- a/packages/ui/src/modules/module-helpers.tsx
+++ b/packages/ui/src/modules/module-helpers.tsx
@@ -1,22 +1,28 @@
import * as React from "react";
import { Folder } from "lucide-react";
+import type { HealthBand } from "@repowise-dev/types/health";
import { cn } from "../lib/cn";
+import { healthBand100 } from "../health/tokens";
/**
- * Single source of truth for module-health colour + chrome shared by the
- * module card and the module detail header. Module scores are on a 0–100
- * scale (unlike the 0–10 file-health pills in `health/tokens`), so these
- * helpers live alongside the module components rather than reusing the
- * file-score ramp.
+ * Module-health colour + chrome shared by the module card and the module
+ * detail header. Module scores are on a 0–100 scale; banding thresholds
+ * come from the shared `healthBand100` so modules agree with every other
+ * health surface on what counts as red.
*/
+/* Literal class strings per band so Tailwind's static scanner keeps them. */
+const BAND_CHIP: Record<HealthBand, string> = {
+ healthy:
+ "text-[var(--color-success)] bg-[var(--color-success)]/10 border-[var(--color-success)]/40",
+ warning:
+ "text-[var(--color-caution)] bg-[var(--color-caution)]/10 border-[var(--color-caution)]/40",
+ alert: "text-[var(--color-error)] bg-[var(--color-error)]/10 border-[var(--color-error)]/40",
+};
+
/** Colour classes for a 0–100 module health score. */
export function scoreColor(score: number): string {
- if (score >= 70)
- return "text-[var(--color-success)] bg-[var(--color-success)]/10 border-[var(--color-success)]/40";
- if (score >= 40)
- return "text-[var(--color-caution)] bg-[var(--color-caution)]/10 border-[var(--color-caution)]/40";
- return "text-[var(--color-error)] bg-[var(--color-error)]/10 border-[var(--color-error)]/40";
+ return BAND_CHIP[healthBand100(score)];
}
export interface HealthChipProps {
diff --git a/packages/ui/src/refactoring/generate-code-panel.tsx b/packages/ui/src/refactoring/generate-code-panel.tsx
index 4da4f5324..cf213b559 100644
--- a/packages/ui/src/refactoring/generate-code-panel.tsx
+++ b/packages/ui/src/refactoring/generate-code-panel.tsx
@@ -9,6 +9,7 @@ import {
type RefactoringPlan,
type VerdictTone,
} from "./types";
+import { toFriendlyMessage } from "../lib/errors";
/**
* Run the opt-in LLM code generation for one plan: takes a deterministic plan,
@@ -55,7 +56,7 @@ export function GenerateCodePanel({ plan, onGenerate }: GenerateCodePanelProps)
setState({ status: "done", result });
} catch (err) {
const message =
- err instanceof Error ? err.message : "Code generation failed. Check the provider config.";
+ toFriendlyMessage(err, "Code generation failed. Check the provider config.");
setState({ status: "error", message });
}
}, [onGenerate, plan]);
diff --git a/packages/ui/src/refactoring/plan-before.tsx b/packages/ui/src/refactoring/plan-before.tsx
index 72638abf0..9f7fead26 100644
--- a/packages/ui/src/refactoring/plan-before.tsx
+++ b/packages/ui/src/refactoring/plan-before.tsx
@@ -49,12 +49,12 @@ export function PlanBefore({ plan }: PlanBeforeProps) {
{plan.target_symbol || baseName(plan.file_path)}
</code>
{lcom4 > 0 ? (
- <span className="shrink-0 rounded-full bg-[var(--color-error)]/10 px-2 py-0.5 text-[10px] font-semibold tabular-nums text-[var(--color-error)]">
+ <span className="shrink-0 rounded-full bg-[var(--color-error)]/10 px-2 py-0.5 text-caption font-semibold tabular-nums text-[var(--color-error)]">
LCOM4 {lcom4}
</span>
) : null}
</div>
- <p className="mb-2 text-[11px] text-[var(--color-text-tertiary)]">
+ <p className="mb-2 text-2xs text-[var(--color-text-tertiary)]">
{methods.length} method{methods.length === 1 ? "" : "s"} and {fields.length} field
{fields.length === 1 ? "" : "s"} packed into one class with no clear seams.
</p>
@@ -62,7 +62,7 @@ export function PlanBefore({ plan }: PlanBeforeProps) {
{shownF.map((f) => (
<code
key={`f-${f}`}
- className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-[11px] text-[var(--color-text-tertiary)]"
+ className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-2xs text-[var(--color-text-tertiary)]"
>
{f}
</code>
@@ -70,13 +70,13 @@ export function PlanBefore({ plan }: PlanBeforeProps) {
{shownM.map((m) => (
<code
key={`m-${m}`}
- className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-[11px] text-[var(--color-text-secondary)]"
+ className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-2xs text-[var(--color-text-secondary)]"
>
{m}
</code>
))}
{methods.length + fields.length > shownM.length + shownF.length ? (
- <span className="px-1 py-0.5 text-[11px] text-[var(--color-text-tertiary)]">
+ <span className="px-1 py-0.5 text-2xs text-[var(--color-text-tertiary)]">
+{methods.length + fields.length - shownM.length - shownF.length} more
</span>
) : null}
@@ -91,7 +91,7 @@ export function PlanBefore({ plan }: PlanBeforeProps) {
const shown = occ.slice(0, 5);
return (
<div className="space-y-2">
- <p className="text-[11px] text-[var(--color-text-tertiary)]">
+ <p className="text-2xs text-[var(--color-text-tertiary)]">
The same {lines ? `~${lines}-line ` : ""}block is copy-pasted across {occ.length} site
{occ.length === 1 ? "" : "s"}.
</p>
@@ -101,16 +101,16 @@ 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-[11px] text-[var(--color-text-secondary)]" title={o.file}>
+ <code className="truncate text-2xs text-[var(--color-text-secondary)]" title={o.file}>
{shortFile(o.file)}
</code>
- <span className="shrink-0 text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <span className="shrink-0 text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
duplicate
</span>
</div>
))}
{occ.length > shown.length ? (
- <p className="px-1 text-[11px] text-[var(--color-text-tertiary)]">
+ <p className="px-1 text-2xs text-[var(--color-text-tertiary)]">
+{occ.length - shown.length} more copies
</p>
) : null}
@@ -127,15 +127,15 @@ export function PlanBefore({ plan }: PlanBeforeProps) {
return (
<div className="rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-3.5">
<div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] p-2.5">
- <div className="text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <div className="text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
Currently in
</div>
<code className="text-xs text-[var(--color-text-secondary)]">{mv.from_class}</code>
<div className="mt-1.5 inline-flex items-center gap-1 rounded-md border border-dashed px-1.5 py-0.5" style={{ borderColor: accent }}>
- <code className="text-[11px] text-[var(--color-text-primary)]">{mv.method}()</code>
+ <code className="text-2xs text-[var(--color-text-primary)]">{mv.method}()</code>
</div>
</div>
- <p className="mt-2.5 text-[11px] leading-relaxed text-[var(--color-text-tertiary)]">
+ <p className="mt-2.5 text-2xs leading-relaxed text-[var(--color-text-tertiary)]">
It reaches into{" "}
<code className="text-[var(--color-text-secondary)]">{mv.to_class}</code>
{foreign || own ? (
@@ -168,12 +168,12 @@ export function PlanBefore({ plan }: PlanBeforeProps) {
{baseName(plan.file_path)}
</code>
{nloc > 0 ? (
- <span className="shrink-0 rounded-full bg-[var(--color-error)]/10 px-2 py-0.5 text-[10px] font-semibold tabular-nums text-[var(--color-error)]">
+ <span className="shrink-0 rounded-full bg-[var(--color-error)]/10 px-2 py-0.5 text-caption font-semibold tabular-nums text-[var(--color-error)]">
{nloc} NLOC
</span>
) : null}
</div>
- <p className="mb-2 text-[11px] text-[var(--color-text-tertiary)]">
+ <p className="mb-2 text-2xs text-[var(--color-text-tertiary)]">
{count} top-level symbol{count === 1 ? "" : "s"} in one module — loosely related, no clear
seams.
</p>
@@ -181,13 +181,13 @@ export function PlanBefore({ plan }: PlanBeforeProps) {
{shown.map((s) => (
<code
key={s}
- className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-[11px] text-[var(--color-text-tertiary)]"
+ className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-2xs text-[var(--color-text-tertiary)]"
>
{s}
</code>
))}
{symbols.length > shown.length ? (
- <span className="px-1 py-0.5 text-[11px] text-[var(--color-text-tertiary)]">
+ <span className="px-1 py-0.5 text-2xs text-[var(--color-text-tertiary)]">
+{symbols.length - shown.length} more
</span>
) : null}
@@ -206,7 +206,7 @@ function CycleGraph({ plan, accent }: { plan: RefactoringPlan; accent: string })
const n = Math.min(members.length, 8);
if (n < 2) {
return (
- <div className="rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-3.5 text-[11px] text-[var(--color-text-tertiary)]">
+ <div className="rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-3.5 text-2xs text-[var(--color-text-tertiary)]">
{members.length} files form an import cycle.
</div>
);
@@ -284,7 +284,7 @@ function CycleGraph({ plan, accent }: { plan: RefactoringPlan; accent: string })
</g>
))}
</svg>
- <p className="px-2 pb-1 text-center text-[11px] text-[var(--color-text-tertiary)]">
+ <p className="px-2 pb-1 text-center text-2xs text-[var(--color-text-tertiary)]">
{members.length} files import each other in a closed loop.
</p>
</div>
diff --git a/packages/ui/src/refactoring/plan-detail.tsx b/packages/ui/src/refactoring/plan-detail.tsx
index 09d6ead59..97e4eef50 100644
--- a/packages/ui/src/refactoring/plan-detail.tsx
+++ b/packages/ui/src/refactoring/plan-detail.tsx
@@ -107,14 +107,14 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
</div>
{g.fields.length > 0 ? (
<div className="mb-1.5">
- <span className="text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <span className="text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
Fields
</span>
<div className="mt-1 flex flex-wrap gap-1">
{g.fields.map((f) => (
<code
key={f}
- className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-[11px] text-[var(--color-text-secondary)]"
+ className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-2xs text-[var(--color-text-secondary)]"
>
{f}
</code>
@@ -123,14 +123,14 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
</div>
) : null}
<div>
- <span className="text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <span className="text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
Methods
</span>
<ul className="mt-1 space-y-0.5">
{g.methods.map((m) => (
<li
key={m}
- className="flex items-center gap-1.5 font-mono text-[11px] text-[var(--color-text-secondary)]"
+ className="flex items-center gap-1.5 font-mono text-2xs text-[var(--color-text-secondary)]"
>
<CornerDownRight className="h-3 w-3 text-[var(--color-text-tertiary)]" />
{m}
@@ -158,7 +158,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
<>
{" "}
near{" "}
- <code className="rounded bg-[var(--color-bg-elevated)] px-1 py-0.5 text-[11px] text-[var(--color-text-secondary)]">
+ <code className="rounded bg-[var(--color-bg-elevated)] px-1 py-0.5 text-2xs text-[var(--color-text-secondary)]">
{site}
</code>
</>
@@ -172,7 +172,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
<span className="min-w-0 flex-1">
<FileRef path={o.file} line={o.line_start} fileHref={fileHref} className="block truncate" />
</span>
- <span className="shrink-0 text-[11px] tabular-nums text-[var(--color-text-tertiary)]">
+ <span className="shrink-0 text-2xs tabular-nums text-[var(--color-text-tertiary)]">
lines {o.line_start}–{o.line_end}
</span>
</li>
@@ -194,20 +194,20 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
)}
<div className="flex flex-wrap items-center gap-3 rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-4">
<div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-3 py-2">
- <div className="text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <div className="text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
From
</div>
<code className="text-xs text-[var(--color-text-secondary)]">{mv.from_class}</code>
</div>
<div className="flex flex-col items-center text-[var(--color-text-tertiary)]">
- <code className="mb-0.5 text-[11px] text-[var(--color-text-primary)]">{mv.method}</code>
+ <code className="mb-0.5 text-2xs text-[var(--color-text-primary)]">{mv.method}</code>
<ArrowRight className="h-4 w-4" style={{ color: accent }} />
</div>
<div
className="rounded-lg border px-3 py-2"
style={{ borderColor: accent, backgroundColor: `color-mix(in srgb, ${accent} 8%, transparent)` }}
>
- <div className="text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <div className="text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
To
</div>
<code className="text-xs text-[var(--color-text-primary)]">{mv.to_class}</code>
@@ -234,7 +234,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
</p>
)}
<div className="space-y-2 rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-3.5">
- <div className="text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <div className="text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
Cut these import edges
</div>
{edges.map((e, i) => (
@@ -246,7 +246,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
</div>
))}
{members.length > 0 ? (
- <div className="break-words pt-1 text-[11px] leading-relaxed text-[var(--color-text-tertiary)]">
+ <div className="break-words pt-1 text-2xs leading-relaxed text-[var(--color-text-tertiary)]">
Cycle: {members.map(shortFile).join(" → ")}
</div>
) : null}
@@ -277,7 +277,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
<div className="flex items-center gap-2 rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-3.5">
<Scissors className="h-4 w-4 shrink-0" style={{ color: accent }} aria-hidden />
<div className="min-w-0">
- <div className="text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <div className="text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
Extract span
</div>
<FileRef
@@ -294,13 +294,13 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
) : null}
<div className="rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-3.5">
- <div className="mb-1.5 text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <div className="mb-1.5 text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
Inferred signature
</div>
<code className="block break-all font-mono text-xs text-[var(--color-text-primary)]">
{sig}
</code>
- <div className="mt-2 flex flex-wrap gap-3 text-[11px] text-[var(--color-text-tertiary)]">
+ <div className="mt-2 flex flex-wrap gap-3 text-2xs text-[var(--color-text-tertiary)]">
<span>
In (params):{" "}
<span className="text-[var(--color-text-secondary)]">
@@ -361,7 +361,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
{g.symbols.map((s) => (
<li
key={s}
- className="flex items-center gap-1.5 font-mono text-[11px] text-[var(--color-text-secondary)]"
+ className="flex items-center gap-1.5 font-mono text-2xs text-[var(--color-text-secondary)]"
>
<CornerDownRight className="h-3 w-3 shrink-0 text-[var(--color-text-tertiary)]" />
<span className="truncate">{s}</span>
@@ -374,14 +374,14 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
{residual.length > 0 ? (
<div className="rounded-xl border border-dashed border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-3.5">
- <div className="mb-1.5 text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <div className="mb-1.5 text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
Stays in {originalName} (shared core)
</div>
<div className="flex flex-wrap gap-1">
{residual.map((s) => (
<code
key={s}
- className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-[11px] text-[var(--color-text-secondary)]"
+ className="rounded bg-[var(--color-bg-elevated)] px-1.5 py-0.5 text-2xs text-[var(--color-text-secondary)]"
>
{s}
</code>
@@ -392,7 +392,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
{blast.dependent_count > 0 ? (
<div className="space-y-1.5 rounded-xl border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-3.5">
- <div className="flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-[var(--color-text-tertiary)]">
+ <div className="flex items-center gap-1.5 text-caption uppercase tracking-wide text-[var(--color-text-tertiary)]">
<Layers className="h-3.5 w-3.5" />
{blast.import_rewrites > 0
? `Rewrite imports in ${blast.import_rewrites} dependent file${
@@ -410,7 +410,7 @@ export function PlanDetail({ plan, fileHref, hideIntro = false }: PlanDetailProp
</li>
))}
{blast.dependent_files.length > shownDeps.length ? (
- <li className="text-[11px] text-[var(--color-text-tertiary)]">
+ <li className="text-2xs text-[var(--color-text-tertiary)]">
+{blast.dependent_files.length - shownDeps.length} more
</li>
) : null}
diff --git a/packages/ui/src/refactoring/refactoring-settings-card.tsx b/packages/ui/src/refactoring/refactoring-settings-card.tsx
index 7545efe1b..717ce3054 100644
--- a/packages/ui/src/refactoring/refactoring-settings-card.tsx
+++ b/packages/ui/src/refactoring/refactoring-settings-card.tsx
@@ -5,6 +5,7 @@ import { Check, Loader2, TriangleAlert, Wand2 } from "lucide-react";
import { Switch } from "../ui/switch";
import { Input } from "../ui/input";
import { Label } from "../ui/label";
+import { toFriendlyMessage } from "../lib/errors";
export interface RefactoringSettingsValue {
enabled: boolean;
@@ -70,7 +71,7 @@ export function RefactoringSettingsCard({
window.setTimeout(() => setSave("idle"), 1800);
} catch (err) {
setSave("error");
- setError(err instanceof Error ? err.message : "Could not save settings.");
+ setError(toFriendlyMessage(err, "Could not save settings."));
}
}, [enabled, provider, model, onSave]);
diff --git a/packages/ui/src/security/findings-table.tsx b/packages/ui/src/security/findings-table.tsx
index 09d4dc3ff..5ba6081b7 100644
--- a/packages/ui/src/security/findings-table.tsx
+++ b/packages/ui/src/security/findings-table.tsx
@@ -5,6 +5,7 @@ import { Search } from "lucide-react";
import { Badge } from "../ui/badge";
import { Input } from "../ui/input";
import { EmptyState } from "../shared/empty-state";
+import { ResponsiveTable, type ResponsiveColumn } from "../shared/responsive-table";
import { AiPromptButton } from "../health/ai-prompt-button";
export interface SecurityFinding {
@@ -48,6 +49,81 @@ export function SecurityFindingsTable({ findings, onSelect, onGeneratePrompt }:
return items;
}, [findings, q, sev]);
+ const columns = useMemo(() => {
+ const cols: ResponsiveColumn<SecurityFinding>[] = [
+ {
+ key: "severity",
+ header: "Severity",
+ headerClassName: "w-20",
+ render: (f) => (
+ <Badge variant={SEVERITY_VARIANT[f.severity] ?? "outline"} className="capitalize">
+ {f.severity}
+ </Badge>
+ ),
+ },
+ {
+ key: "file_path",
+ header: "File",
+ render: (f) => (
+ <span
+ className="block max-w-[280px] truncate font-mono text-xs text-[var(--color-text-primary)]"
+ title={f.file_path}
+ >
+ {f.file_path}
+ </span>
+ ),
+ },
+ {
+ key: "kind",
+ header: "Kind",
+ headerClassName: "w-40",
+ render: (f) => <span className="text-xs text-[var(--color-text-secondary)]">{f.kind}</span>,
+ },
+ {
+ key: "snippet",
+ header: "Snippet",
+ priority: 2,
+ render: (f) => (
+ <span
+ className="block max-w-[320px] truncate font-mono text-xs text-[var(--color-text-tertiary)]"
+ title={f.snippet ?? ""}
+ >
+ {f.snippet ?? "—"}
+ </span>
+ ),
+ },
+ {
+ key: "detected_at",
+ header: "Detected",
+ headerClassName: "w-28",
+ priority: 3,
+ render: (f) => (
+ <span className="text-xs tabular-nums text-[var(--color-text-tertiary)]">
+ {new Date(f.detected_at).toLocaleDateString()}
+ </span>
+ ),
+ },
+ ];
+ if (onGeneratePrompt) {
+ cols.push({
+ key: "actions",
+ header: "",
+ headerClassName: "w-10",
+ hideInCard: true,
+ render: (f) => (
+ <span onClick={(e) => e.stopPropagation()}>
+ <AiPromptButton
+ variant="icon"
+ label="AI fix prompt"
+ onClick={() => onGeneratePrompt(f)}
+ />
+ </span>
+ ),
+ });
+ }
+ return cols;
+ }, [onGeneratePrompt]);
+
if (findings.length === 0) {
return (
<EmptyState
@@ -92,73 +168,17 @@ export function SecurityFindingsTable({ findings, onSelect, onGeneratePrompt }:
</div>
</div>
- <div className="border border-[var(--color-border-default)] overflow-hidden overflow-x-auto">
- <table className="w-full min-w-[560px] text-sm">
- <thead className="sticky top-0 z-10 bg-[var(--color-bg-surface)]">
- <tr className="border-b border-[var(--color-border-default)] bg-[var(--color-bg-surface)]">
- <th className="px-3 py-2.5 text-left text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-20">
- Severity
- </th>
- <th className="px-3 py-2.5 text-left text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
- File
- </th>
- <th className="px-3 py-2.5 text-left text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-40">
- Kind
- </th>
- <th className="px-3 py-2.5 text-left text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
- Snippet
- </th>
- <th className="px-3 py-2.5 text-left text-[11px] font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider w-28">
- Detected
- </th>
- {onGeneratePrompt && <th className="px-3 py-2.5 w-10" />}
- </tr>
- </thead>
- <tbody>
- {filtered.map((f) => (
- <tr
- key={f.id}
- onClick={onSelect ? () => onSelect(f) : undefined}
- className={
- "group border-b border-[var(--color-table-divider)] last:border-0 hover:bg-[var(--color-bg-elevated)] transition-colors" +
- (onSelect ? " cursor-pointer" : "")
- }
- >
- <td className="px-3 py-2">
- <Badge variant={SEVERITY_VARIANT[f.severity] ?? "outline"} className="capitalize">
- {f.severity}
- </Badge>
- </td>
- <td className="px-3 py-2 font-mono text-xs text-[var(--color-text-primary)] max-w-[280px]">
- <span className="block truncate group-hover:underline underline-offset-2" title={f.file_path}>{f.file_path}</span>
- </td>
- <td className="px-3 py-2 text-xs text-[var(--color-text-secondary)]">{f.kind}</td>
- <td className="px-3 py-2 font-mono text-xs text-[var(--color-text-tertiary)] max-w-[320px]">
- <span className="block truncate" title={f.snippet ?? ""}>
- {f.snippet ?? "—"}
- </span>
- </td>
- <td className="px-3 py-2 text-xs text-[var(--color-text-tertiary)] tabular-nums">
- {new Date(f.detected_at).toLocaleDateString()}
- </td>
- {onGeneratePrompt && (
- <td className="px-3 py-2" onClick={(e) => e.stopPropagation()}>
- <AiPromptButton
- variant="icon"
- label="AI fix prompt"
- onClick={() => onGeneratePrompt(f)}
- />
- </td>
- )}
- </tr>
- ))}
- </tbody>
- </table>
- </div>
-
- {filtered.length === 0 && (
- <p className="text-sm text-[var(--color-text-tertiary)] py-6 text-center">No matches.</p>
- )}
+ <ResponsiveTable
+ columns={columns}
+ rows={filtered}
+ rowKey={(f) => String(f.id)}
+ caption="Security findings"
+ {...(onSelect ? { onRowClick: onSelect } : {})}
+ stacked="sm"
+ empty={
+ <p className="text-sm text-[var(--color-text-tertiary)] py-6 text-center">No matches.</p>
+ }
+ />
</div>
);
}
diff --git a/packages/ui/src/shared/error-boundary.tsx b/packages/ui/src/shared/error-boundary.tsx
index 7ec08cebf..2c17f1240 100644
--- a/packages/ui/src/shared/error-boundary.tsx
+++ b/packages/ui/src/shared/error-boundary.tsx
@@ -2,6 +2,7 @@
import * as React from "react";
import { ApiError } from "./api-error";
+import { toFriendlyMessage } from "../lib/errors";
/**
* ErrorBoundary — catches render errors in a subtree and shows a recoverable
@@ -41,7 +42,7 @@ export class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoun
return (
<ApiError
title={this.props.title ?? "Something went wrong"}
- message={error.message}
+ message={toFriendlyMessage(error)}
onRetry={this.reset}
/>
);
diff --git a/packages/ui/src/shared/index.ts b/packages/ui/src/shared/index.ts
index 968e76f2d..a7811abf2 100644
--- a/packages/ui/src/shared/index.ts
+++ b/packages/ui/src/shared/index.ts
@@ -7,6 +7,8 @@ export { BrandMark, type BrandMarkProps } from "./brand-mark";
export { ErrorBoundary, type ErrorBoundaryProps } from "./error-boundary";
export {
ResponsiveTable,
+ clickableRowProps,
+ CLICKABLE_ROW_CLS,
type ResponsiveColumn,
type ResponsiveTableProps,
type ColumnPriority,
@@ -24,7 +26,12 @@ export * from "./breadcrumb";
export * from "./empty-state";
export { InfoTip, type InfoTipProps } from "./info-tip";
export { OwlLoader, type OwlLoaderProps } from "./owl-loader";
-export * from "./stat-card";
+export {
+ TableSkeleton,
+ CardSkeleton,
+ type TableSkeletonProps,
+ type CardSkeletonProps,
+} from "./loading-skeletons";
export { PageShell, type PageShellProps } from "./page-shell";
export { ViewTabs, type ViewTab, type ViewTabsProps } from "./view-tabs";
export { MetricCard, type MetricCardProps } from "./metric-card";
diff --git a/packages/ui/src/shared/loading-skeletons.tsx b/packages/ui/src/shared/loading-skeletons.tsx
new file mode 100644
index 000000000..bc509e9dc
--- /dev/null
+++ b/packages/ui/src/shared/loading-skeletons.tsx
@@ -0,0 +1,45 @@
+import { Skeleton } from "../ui/skeleton";
+import { cn } from "../lib/cn";
+
+export interface TableSkeletonProps {
+ /** Number of placeholder rows. Default 6. */
+ rows?: number;
+ className?: string;
+}
+
+/** Loading placeholder shaped like a table: a stack of row-height bars. */
+export function TableSkeleton({ rows = 6, className }: TableSkeletonProps) {
+ return (
+ <div className={cn("space-y-2", className)} aria-hidden>
+ {Array.from({ length: rows }).map((_, i) => (
+ <Skeleton key={i} className="h-10 w-full" />
+ ))}
+ </div>
+ );
+}
+
+export interface CardSkeletonProps {
+ /** Number of placeholder text lines under the title bar. Default 3. */
+ lines?: number;
+ className?: string;
+}
+
+/** Loading placeholder shaped like a card: a title bar over shorter lines. */
+export function CardSkeleton({ lines = 3, className }: CardSkeletonProps) {
+ return (
+ <div
+ className={cn(
+ "rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-surface)] p-4 space-y-3",
+ className,
+ )}
+ aria-hidden
+ >
+ <Skeleton className="h-4 w-1/3" />
+ <div className="space-y-2">
+ {Array.from({ length: lines }).map((_, i) => (
+ <Skeleton key={i} className={cn("h-3", i === lines - 1 ? "w-2/3" : "w-full")} />
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/packages/ui/src/shared/metric-card.tsx b/packages/ui/src/shared/metric-card.tsx
index 20b844e5b..1de0aa810 100644
--- a/packages/ui/src/shared/metric-card.tsx
+++ b/packages/ui/src/shared/metric-card.tsx
@@ -5,6 +5,8 @@ import { Card, CardContent } from "../ui/card";
export interface MetricCardProps {
label: string;
value: React.ReactNode;
+ /** One-line context rendered beneath the value. */
+ description?: string;
/**
* Signed change indicator. `positive` is a good-vs-bad flag (drives
* success/error colouring), not up-vs-down. Set `neutral` to render the
@@ -27,13 +29,14 @@ export interface MetricCardProps {
}
/**
- * The canonical stat tile: label + value with optional delta, sparkline, and
- * distribution-bar slots. Built on `Card`; the future single replacement for
- * the near-identical summary-card variants across views.
+ * The canonical stat tile: label + value with optional description, delta,
+ * sparkline, and distribution-bar slots. Built on `Card`. Use this for every
+ * summary card; `StatTile` remains the deliberately denser inline-grid cell.
*/
export function MetricCard({
label,
value,
+ description,
delta,
sparkline,
distBar,
@@ -75,6 +78,9 @@ export function MetricCard({
</span>
)}
</div>
+ {description && (
+ <p className="text-xs text-[var(--color-text-secondary)]">{description}</p>
+ )}
</div>
{icon && (
<div className="shrink-0 rounded-md bg-[var(--color-bg-elevated)] p-2 text-[var(--color-text-secondary)]">
diff --git a/packages/ui/src/shared/responsive-table/index.ts b/packages/ui/src/shared/responsive-table/index.ts
index 12cffb1f0..3000fa4cd 100644
--- a/packages/ui/src/shared/responsive-table/index.ts
+++ b/packages/ui/src/shared/responsive-table/index.ts
@@ -1,5 +1,7 @@
export {
ResponsiveTable,
+ clickableRowProps,
+ CLICKABLE_ROW_CLS,
type ResponsiveColumn,
type ResponsiveTableProps,
type ColumnPriority,
diff --git a/packages/ui/src/shared/responsive-table/responsive-table.tsx b/packages/ui/src/shared/responsive-table/responsive-table.tsx
index 40dddd86b..011e82083 100644
--- a/packages/ui/src/shared/responsive-table/responsive-table.tsx
+++ b/packages/ui/src/shared/responsive-table/responsive-table.tsx
@@ -52,6 +52,8 @@ export interface ResponsiveTableProps<T> {
onSort?: ((key: string) => void) | undefined;
/** Rendered instead of the table when `rows` is empty (use EmptyState). */
empty?: React.ReactNode | undefined;
+ /** Screen-reader-only `<caption>` describing the table. */
+ caption?: string | undefined;
/** Collapse to stacked cards below this breakpoint. Default: no collapse. */
stacked?: "sm" | "md" | undefined;
/** Extra classes on the outer wrapper. */
@@ -80,6 +82,27 @@ function alignCls(align?: "left" | "right" | "center"): string {
return align === "right" ? "text-right" : align === "center" ? "text-center" : "text-left";
}
+/**
+ * Keyboard/focus props for a clickable row. Keeps the native row semantics
+ * (no role override, which would detach the row from the table for assistive
+ * tech) while making the row tabbable and activatable with Enter/Space.
+ */
+export function clickableRowProps<E extends HTMLElement>(activate: () => void) {
+ return {
+ tabIndex: 0,
+ onClick: activate,
+ onKeyDown: (event: React.KeyboardEvent<E>) => {
+ if (event.key !== "Enter" && event.key !== " ") return;
+ if (event.target !== event.currentTarget) return;
+ event.preventDefault();
+ activate();
+ },
+ };
+}
+
+export const CLICKABLE_ROW_CLS =
+ "cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--color-accent-primary)]";
+
export function ResponsiveTable<T>({
columns,
rows,
@@ -90,6 +113,7 @@ export function ResponsiveTable<T>({
sortOrder = "desc",
onSort,
empty,
+ caption,
stacked,
className,
bare,
@@ -101,10 +125,23 @@ export function ResponsiveTable<T>({
const table = (
<div className={cn("overflow-x-auto", stacked && STACKED_TABLE_CLS[stacked])}>
<table className="w-full text-sm">
- <thead className="bg-[var(--color-bg-surface)] text-[var(--color-text-tertiary)] text-[11px] uppercase tracking-wider sticky top-0 z-10 border-b border-[var(--color-border-default)]">
+ {caption ? <caption className="sr-only">{caption}</caption> : null}
+ <thead className="bg-[var(--color-bg-surface)] text-[var(--color-text-tertiary)] text-2xs uppercase tracking-wider sticky top-0 z-10 border-b border-[var(--color-border-default)]">
<tr>
{columns.map((c) => {
const isActive = c.sortable && c.key === sortField;
+ const label = (
+ <span className="inline-flex items-center gap-1">
+ {c.header}
+ {isActive ? (
+ sortOrder === "asc" ? (
+ <ArrowUp className="h-3 w-3" />
+ ) : (
+ <ArrowDown className="h-3 w-3" />
+ )
+ ) : null}
+ </span>
+ );
return (
<th
key={c.key}
@@ -112,24 +149,23 @@ export function ResponsiveTable<T>({
"px-3 py-2.5 font-medium whitespace-nowrap",
alignCls(c.align),
PRIORITY_CELL_CLS[c.priority ?? 1],
- c.sortable && onSort && "cursor-pointer select-none",
c.headerClassName,
)}
- onClick={c.sortable && onSort ? () => onSort(c.key) : undefined}
aria-sort={
isActive ? (sortOrder === "asc" ? "ascending" : "descending") : undefined
}
>
- <span className="inline-flex items-center gap-1">
- {c.header}
- {isActive ? (
- sortOrder === "asc" ? (
- <ArrowUp className="h-3 w-3" />
- ) : (
- <ArrowDown className="h-3 w-3" />
- )
- ) : null}
- </span>
+ {c.sortable && onSort ? (
+ <button
+ type="button"
+ className="inline-flex cursor-pointer select-none items-center font-medium uppercase tracking-wider focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent-primary)] rounded"
+ onClick={() => onSort(c.key)}
+ >
+ {label}
+ </button>
+ ) : (
+ label
+ )}
</th>
);
})}
@@ -145,9 +181,9 @@ export function ResponsiveTable<T>({
className={cn(
"border-t border-[var(--color-table-divider)] hover:bg-[var(--color-bg-elevated)]",
isSelected && "bg-[var(--color-accent-muted)]/30",
- onRowClick && "cursor-pointer",
+ onRowClick && CLICKABLE_ROW_CLS,
)}
- onClick={onRowClick ? () => onRowClick(row) : undefined}
+ {...(onRowClick ? clickableRowProps(() => onRowClick(row)) : {})}
>
{columns.map((c) => (
<td
@@ -183,9 +219,9 @@ export function ResponsiveTable<T>({
className={cn(
"px-3 py-2.5",
isSelected && "bg-[var(--color-accent-muted)]/30",
- onRowClick && "cursor-pointer hover:bg-[var(--color-bg-elevated)]",
+ onRowClick && cn("hover:bg-[var(--color-bg-elevated)]", CLICKABLE_ROW_CLS),
)}
- onClick={onRowClick ? () => onRowClick(row) : undefined}
+ {...(onRowClick ? clickableRowProps(() => onRowClick(row)) : {})}
>
<div className="text-sm text-[var(--color-text-primary)]">
{(titleCol.mobileRender ?? titleCol.render)(row)}
diff --git a/packages/ui/src/shared/stat-card.tsx b/packages/ui/src/shared/stat-card.tsx
deleted file mode 100644
index e6ebbcffd..000000000
--- a/packages/ui/src/shared/stat-card.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import * as React from "react";
-import { cn } from "../lib/cn";
-import { Card, CardContent } from "../ui/card";
-
-interface StatCardProps {
- label: string;
- value: string | number;
- description?: string;
- trend?: { value: string; positive: boolean };
- icon?: React.ReactNode;
- className?: string;
- href?: string;
- /** Tighter padding for dense stat strips. */
- dense?: boolean;
-}
-
-export function StatCard({
- label,
- value,
- description,
- trend,
- icon,
- className,
- href,
- dense,
-}: StatCardProps) {
- const card = (
- <Card className={cn("h-full transition-colors hover:border-[var(--color-border-hover)]", href && "cursor-pointer", className)}>
- <CardContent className={dense ? "p-3" : "p-4"}>
- <div className="flex items-start justify-between">
- <div className="space-y-1">
- <p className="text-xs font-medium text-[var(--color-text-tertiary)] uppercase tracking-wider">
- {label}
- </p>
- <div className="flex items-baseline gap-2">
- <p className="text-2xl font-bold text-[var(--color-text-primary)] tabular-nums">
- {value}
- </p>
- {trend && (
- <span
- className={cn(
- "text-xs font-medium tabular-nums",
- trend.positive
- ? "text-[var(--color-success)]"
- : "text-[var(--color-error)]",
- )}
- >
- {trend.positive ? "\u2191" : "\u2193"} {trend.value}
- </span>
- )}
- </div>
- {description && (
- <p className="text-xs text-[var(--color-text-secondary)]">{description}</p>
- )}
- </div>
- {icon && (
- <div className="rounded-md bg-[var(--color-bg-elevated)] p-2 text-[var(--color-text-secondary)]">
- {icon}
- </div>
- )}
- </div>
- </CardContent>
- </Card>
- );
-
- if (href) {
- return (
- <a href={href} className="block h-full no-underline">
- {card}
- </a>
- );
- }
-
- return card;
-}
diff --git a/packages/ui/src/ui/index.ts b/packages/ui/src/ui/index.ts
index 9953720f1..83c59a079 100644
--- a/packages/ui/src/ui/index.ts
+++ b/packages/ui/src/ui/index.ts
@@ -5,6 +5,7 @@ export * from "./confirm-dialog";
export * from "./dialog";
export * from "./input";
export * from "./label";
+export * from "./popover";
export * from "./progress";
export * from "./scroll-area";
export * from "./select";
diff --git a/packages/ui/src/ui/popover.tsx b/packages/ui/src/ui/popover.tsx
new file mode 100644
index 000000000..aeece508c
--- /dev/null
+++ b/packages/ui/src/ui/popover.tsx
@@ -0,0 +1,30 @@
+"use client";
+
+import * as React from "react";
+import * as PopoverPrimitive from "@radix-ui/react-popover";
+import { cn } from "../lib/cn";
+
+const Popover = PopoverPrimitive.Root;
+const PopoverTrigger = PopoverPrimitive.Trigger;
+const PopoverAnchor = PopoverPrimitive.Anchor;
+
+const PopoverContent = React.forwardRef<
+ React.ElementRef<typeof PopoverPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
+>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
+ <PopoverPrimitive.Portal>
+ <PopoverPrimitive.Content
+ ref={ref}
+ align={align}
+ sideOffset={sideOffset}
+ className={cn(
+ "z-[var(--z-dropdown)] w-72 rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-overlay)] p-3 text-xs text-[var(--color-text-primary)] shadow-md outline-none animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ className,
+ )}
+ {...props}
+ />
+ </PopoverPrimitive.Portal>
+));
+PopoverContent.displayName = PopoverPrimitive.Content.displayName;
+
+export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
diff --git a/packages/ui/src/wiki/mermaid-diagram.tsx b/packages/ui/src/wiki/mermaid-diagram.tsx
index 885a9d8cd..8a97ba935 100644
--- a/packages/ui/src/wiki/mermaid-diagram.tsx
+++ b/packages/ui/src/wiki/mermaid-diagram.tsx
@@ -3,6 +3,7 @@
import { useEffect, useRef, useState } from "react";
import { Maximize2, X, ZoomIn, ZoomOut, RotateCcw } from "lucide-react";
import { resolveToken, useThemeVersion } from "../shared/use-theme-tokens";
+import { toFriendlyMessage } from "../lib/errors";
type MermaidSecurityLevel = "strict" | "loose";
@@ -158,7 +159,7 @@ function useMermaidRender(
setRenderTick((t) => t + 1);
})
.catch((e: unknown) => {
- if (!cancelled) setError(e instanceof Error ? e.message : "Diagram render failed");
+ if (!cancelled) setError(toFriendlyMessage(e, "Diagram render failed"));
});
});
return () => {
diff --git a/packages/ui/src/wiki/security-panel.tsx b/packages/ui/src/wiki/security-panel.tsx
index 7f67123e5..f0e3cd838 100644
--- a/packages/ui/src/wiki/security-panel.tsx
+++ b/packages/ui/src/wiki/security-panel.tsx
@@ -2,11 +2,12 @@
import type { SecurityFinding, SecuritySeverity } from "@repowise-dev/types";
import { Badge } from "../ui/badge";
+import { CardSkeleton } from "../shared/loading-skeletons";
export interface SecurityPanelProps {
/** Findings for the file. Empty / undefined renders an empty-state message. */
findings: SecurityFinding[] | undefined;
- /** While loading the shell renders nothing. */
+ /** While loading the shell renders a card skeleton. */
isLoading?: boolean;
}
@@ -23,7 +24,7 @@ function severityLabel(severity: SecuritySeverity): string {
}
export function SecurityPanel({ findings, isLoading }: SecurityPanelProps) {
- if (isLoading) return null;
+ if (isLoading) return <CardSkeleton lines={2} />;
if (!findings || findings.length === 0) {
return (
<p className="text-xs text-[var(--color-text-tertiary)]">No security signals.</p>
diff --git a/packages/ui/src/workspace/cross-repo-summary.tsx b/packages/ui/src/workspace/cross-repo-summary.tsx
index f8b2797b7..d5f74ee08 100644
--- a/packages/ui/src/workspace/cross-repo-summary.tsx
+++ b/packages/ui/src/workspace/cross-repo-summary.tsx
@@ -1,7 +1,7 @@
"use client";
import { Link2, GitMerge, Package } from "lucide-react";
-import { StatCard } from "../shared/stat-card";
+import { MetricCard } from "../shared/metric-card";
import type {
WorkspaceCrossRepoSummary,
WorkspaceContractSummary,
@@ -21,22 +21,22 @@ export function CrossRepoSummary({ crossRepo, contracts }: CrossRepoSummaryProps
return (
<div className="grid grid-cols-2 gap-3 lg:grid-cols-4">
- <StatCard
+ <MetricCard
label="Co-Change Pairs"
value={crossRepo?.co_change_count ?? 0}
icon={<GitMerge className="h-4 w-4 text-[var(--color-accent-primary)]" />}
/>
- <StatCard
+ <MetricCard
label="Package Deps"
value={crossRepo?.package_dep_count ?? 0}
icon={<Package className="h-4 w-4 text-[var(--color-accent-secondary)]" />}
/>
- <StatCard
+ <MetricCard
label="Contract Links"
value={contracts?.total_links ?? 0}
icon={<Link2 className="h-4 w-4 text-[var(--color-info)]" />}
/>
- <StatCard
+ <MetricCard
label="Contracts Detected"
value={contracts?.total_contracts ?? 0}
{...(byTypeDescription ? { description: byTypeDescription } : {})}
diff --git a/packages/ui/src/workspace/repo-pair-table.tsx b/packages/ui/src/workspace/repo-pair-table.tsx
index 0ce885bec..03d0daee7 100644
--- a/packages/ui/src/workspace/repo-pair-table.tsx
+++ b/packages/ui/src/workspace/repo-pair-table.tsx
@@ -3,6 +3,8 @@
import { Badge } from "../ui/badge";
import { EmptyState } from "../shared/empty-state";
import { VirtualizedTable } from "../shared/virtualized-table";
+import { clickableRowProps, CLICKABLE_ROW_CLS } from "../shared/responsive-table";
+import { cn } from "../lib/cn";
import { ChevronRight } from "lucide-react";
export interface RepoPairSummary {
@@ -58,10 +60,12 @@ export function RepoPairTable({ repoPairs, onSelectPair, selectedPairId }: RepoP
const isSelected = selectedPairId != null && selectedPairId === p.id;
return (
<tr
- className={`border-t border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)] ${
- isSelected ? "bg-[var(--color-accent-muted)]/30 " : ""
- }${onClick ? "cursor-pointer" : ""}`}
- onClick={onClick}
+ className={cn(
+ "border-t border-[var(--color-border-default)] hover:bg-[var(--color-bg-elevated)]",
+ isSelected && "bg-[var(--color-accent-muted)]/30",
+ onClick && CLICKABLE_ROW_CLS,
+ )}
+ {...(onClick ? clickableRowProps(onClick) : {})}
>
<td className="px-3 py-2 text-left">
<div className="flex items-center gap-2">
diff --git a/packages/ui/src/workspace/system-map/system-map.tsx b/packages/ui/src/workspace/system-map/system-map.tsx
index 77b6c80fb..0b90a74da 100644
--- a/packages/ui/src/workspace/system-map/system-map.tsx
+++ b/packages/ui/src/workspace/system-map/system-map.tsx
@@ -32,6 +32,7 @@ import { SystemMapInspector } from "./system-map-inspector";
import { useSystemMapLayout } from "./use-system-map-layout";
import type { SystemMapView } from "./layout";
import type { RepoHealth, SystemMapOverlay, SystemMapSelection } from "./types";
+import { toFriendlyMessage } from "../../lib/errors";
export interface SystemMapProps {
graph: SystemGraph | null;
@@ -137,7 +138,7 @@ function SystemMapInner({ graph, loading, error, healthByRepo, overlay, roleByNo
<div style={{ position: "relative", flex: 1, minHeight: 0 }}>
{error ? (
<Centered>
- <EmptyState title="Couldn't load the system map" description={error.message} />
+ <EmptyState title="Couldn't load the system map" description={toFriendlyMessage(error)} />
</Centered>
) : !isLoading && !hasGraph ? (
<Centered>
diff --git a/packages/ui/src/workspace/workspace-graph-node.tsx b/packages/ui/src/workspace/workspace-graph-node.tsx
index 4ee9f997c..635dca431 100644
--- a/packages/ui/src/workspace/workspace-graph-node.tsx
+++ b/packages/ui/src/workspace/workspace-graph-node.tsx
@@ -4,6 +4,7 @@ import { memo } from "react";
import { Handle, Position, type NodeProps } from "@xyflow/react";
import { FileText, BarChart3 } from "lucide-react";
import { languageColor } from "../lib/confidence";
+import { healthInk100 } from "../health/tokens";
export interface WorkspaceGraphNodeData {
repoId: string;
@@ -16,9 +17,7 @@ export interface WorkspaceGraphNodeData {
}
export function healthColor(score: number): string {
- if (score >= 70) return "var(--color-risk-low)";
- if (score >= 40) return "var(--color-risk-medium)";
- return "var(--color-risk-high)";
+ return healthInk100(score);
}
export function HealthRing({
diff --git a/packages/ui/styles/globals.css b/packages/ui/styles/globals.css
index 81ee20cf6..14fabb4b3 100644
--- a/packages/ui/styles/globals.css
+++ b/packages/ui/styles/globals.css
@@ -248,6 +248,11 @@
--font-lora; Georgia fallback keeps SSR/storybook surfaces sane). */
--font-serif: var(--font-lora), "Lora", Georgia, serif;
+ /* Micro sizes for dense chrome: `caption` (10px) for uppercase micro-labels
+ and axis ticks, `2xs` (11px) for secondary metadata one step under xs.
+ Use these instead of arbitrary text-[10px]/text-[11px] brackets. */
+ --text-caption: 0.625rem;
+ --text-2xs: 0.6875rem;
--text-xs: 0.8125rem;
--text-sm: 0.875rem;
--text-base: 0.9375rem;
diff --git a/packages/web/src/app/page.tsx b/packages/web/src/app/page.tsx
index f3daea335..55d407285 100644
--- a/packages/web/src/app/page.tsx
+++ b/packages/web/src/app/page.tsx
@@ -16,7 +16,7 @@ import { listJobs } from "@/lib/api/jobs";
import { getGitSummary } from "@/lib/api/git";
import { getWorkspace } from "@/lib/api/workspace";
import type { RepoStatsResponse, GitSummaryResponse } from "@/lib/api/types";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
+import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";
import { Badge } from "@repowise-dev/ui/ui/badge";
import { EmptyState } from "@repowise-dev/ui/shared/empty-state";
@@ -91,24 +91,24 @@ export default async function DashboardPage() {
{/* Stat Cards */}
<div className="grid grid-cols-2 gap-4 lg:grid-cols-4">
- <StatCard
+ <MetricCard
label="Total Pages"
value={formatNumber(totalPages)}
icon={<FileText className="h-4 w-4" />}
/>
- <StatCard
+ <MetricCard
label="Fresh Pages"
value={formatNumber(freshPages)}
description="Confidence ≥ 80%"
icon={<CheckCircle2 className="h-4 w-4 text-[var(--color-success)]" />}
/>
- <StatCard
+ <MetricCard
label="Stale Pages"
value={formatNumber(stalePages)}
description="Need regeneration"
icon={<AlertCircle className="h-4 w-4 text-[var(--color-warning)]" />}
/>
- <StatCard
+ <MetricCard
label="Dead Code"
value={deadCode > 0 ? formatNumber(deadCode) : "—"}
description={deadCode > 0 ? "Unused exports" : "Analyze to detect"}
diff --git a/packages/web/src/app/repos/[id]/costs/page.tsx b/packages/web/src/app/repos/[id]/costs/page.tsx
index c5f09b574..73adfa123 100644
--- a/packages/web/src/app/repos/[id]/costs/page.tsx
+++ b/packages/web/src/app/repos/[id]/costs/page.tsx
@@ -4,7 +4,6 @@ import { useState } from "react";
import useSWR from "swr";
import { useParams } from "next/navigation";
import { DollarSign } from "lucide-react";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
import { PageShell } from "@repowise-dev/ui/shared/page-shell";
import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";
@@ -180,23 +179,23 @@ export default function CostsPage() {
</div>
) : summary ? (
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
- <StatCard
+ <MetricCard
label="Indexing cost"
value={formatCost(summary.total_cost_usd)}
description="across all generation runs"
icon={<DollarSign className="h-4 w-4 text-[var(--color-success)]" />}
/>
- <StatCard
+ <MetricCard
label="Total Calls"
value={formatNumber(summary.total_calls)}
description="LLM API calls"
/>
- <StatCard
+ <MetricCard
label="Input Tokens"
value={formatTokens(summary.total_input_tokens)}
description="prompt tokens"
/>
- <StatCard
+ <MetricCard
label="Output Tokens"
value={formatTokens(summary.total_output_tokens)}
description="completion tokens"
diff --git a/packages/web/src/app/repos/[id]/docs/coverage/page.tsx b/packages/web/src/app/repos/[id]/docs/coverage/page.tsx
index 72913bf7e..3fb71eb6f 100644
--- a/packages/web/src/app/repos/[id]/docs/coverage/page.tsx
+++ b/packages/web/src/app/repos/[id]/docs/coverage/page.tsx
@@ -5,7 +5,7 @@ import { DriftBanner } from "@repowise-dev/ui/coverage/drift-banner";
import { ConfidenceVsFreshnessMatrix } from "@repowise-dev/ui/coverage/confidence-vs-freshness-matrix";
import { FreshnessTableWithRegenerate } from "@/components/coverage/freshness-table-wrapper";
import type { DocPage } from "@repowise-dev/types/docs";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
+import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
import { listPages } from "@/lib/api/pages";
import { formatNumber } from "@repowise-dev/ui/lib/format";
@@ -53,17 +53,17 @@ export default async function CoveragePage({
{/* Stat cards */}
<div className="flex-1 grid grid-cols-1 gap-3 sm:grid-cols-3">
- <StatCard
+ <MetricCard
label="Fresh"
value={formatNumber(fresh)}
description={`${pages.length > 0 ? Math.round((fresh / pages.length) * 100) : 0}% of pages`}
/>
- <StatCard
+ <MetricCard
label="Stale"
value={formatNumber(stale)}
description={`${pages.length > 0 ? Math.round((stale / pages.length) * 100) : 0}% of pages`}
/>
- <StatCard
+ <MetricCard
label="Outdated"
value={formatNumber(outdated)}
description={`${pages.length > 0 ? Math.round((outdated / pages.length) * 100) : 0}% of pages`}
diff --git a/packages/web/src/app/repos/[id]/search/page.tsx b/packages/web/src/app/repos/[id]/search/page.tsx
index 8171b72e1..821f8c398 100644
--- a/packages/web/src/app/repos/[id]/search/page.tsx
+++ b/packages/web/src/app/repos/[id]/search/page.tsx
@@ -8,6 +8,7 @@ import { SearchResultCard } from "@/components/search/search-result-card";
import { EmptyState } from "@repowise-dev/ui/shared/empty-state";
import { Skeleton } from "@repowise-dev/ui/ui/skeleton";
import { useSearch } from "@/lib/hooks/use-search";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
type SearchType = "fulltext" | "semantic";
@@ -85,7 +86,7 @@ export default function SearchPage() {
{showResults && error && (
<div className="rounded-lg border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] p-4 text-sm text-[var(--color-outdated)]">
- Couldn&apos;t run search: {error instanceof Error ? error.message : "unknown error"}
+ Couldn&apos;t run search: {toFriendlyMessage(error)}
</div>
)}
diff --git a/packages/web/src/app/workspace/co-changes/page.tsx b/packages/web/src/app/workspace/co-changes/page.tsx
index cbade8557..55fc31c52 100644
--- a/packages/web/src/app/workspace/co-changes/page.tsx
+++ b/packages/web/src/app/workspace/co-changes/page.tsx
@@ -6,7 +6,7 @@ import { useWorkspaceCoChanges, useWorkspace } from "@/lib/hooks/use-workspace";
import { CoChangeTable } from "@repowise-dev/ui/workspace/co-change-table";
import { RepoPairTable, type RepoPairSummary } from "@repowise-dev/ui/workspace/repo-pair-table";
import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
+import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
import { Skeleton } from "@repowise-dev/ui/ui/skeleton";
import { Button } from "@repowise-dev/ui/ui/button";
@@ -112,17 +112,17 @@ export default function CoChangesPage() {
{/* Summary */}
<div className="grid grid-cols-2 gap-3 lg:grid-cols-3">
- <StatCard
+ <MetricCard
label="Total Co-Change Pairs"
value={data?.total ?? "—"}
icon={<GitMerge className="h-4 w-4 text-[var(--color-accent-primary)]" />}
/>
- <StatCard
+ <MetricCard
label="Repo Pairs"
value={data?.co_changes ? repoPairs.length : "—"}
icon={<GitMerge className="h-4 w-4 text-[var(--color-accent-secondary)]" />}
/>
- <StatCard
+ <MetricCard
label="Avg Strength"
value={
data?.co_changes && data.co_changes.length > 0
diff --git a/packages/web/src/app/workspace/conformance/page.tsx b/packages/web/src/app/workspace/conformance/page.tsx
index 9b48ce2e9..87cb2ed31 100644
--- a/packages/web/src/app/workspace/conformance/page.tsx
+++ b/packages/web/src/app/workspace/conformance/page.tsx
@@ -6,7 +6,7 @@ import { ShieldCheck, ShieldAlert, RefreshCw, Waypoints, ListChecks, Gauge } fro
import { buildDsm, DsmMatrixView } from "@repowise-dev/ui/workspace/dsm";
import { AiPromptButton, AiPromptModal, buildConformanceAiPrompt } from "@repowise-dev/ui/health";
import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
+import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
import { Skeleton } from "@repowise-dev/ui/ui/skeleton";
import {
useWorkspaceSystemGraph,
@@ -47,7 +47,7 @@ export default function ConformancePage() {
</div>
<div className="grid grid-cols-2 gap-3 lg:grid-cols-4">
- <StatCard
+ <MetricCard
label="Architecture score"
value={metrics ? `${metrics.score.toFixed(1)} / 10` : "—"}
description={
@@ -57,18 +57,18 @@ export default function ConformancePage() {
}
icon={<Gauge className="h-4 w-4 text-[var(--color-accent-primary)]" />}
/>
- <StatCard
+ <MetricCard
label="Rules evaluated"
value={isLoading ? "—" : (report?.rules_evaluated ?? 0)}
icon={<ListChecks className="h-4 w-4 text-[var(--color-accent-secondary)]" />}
/>
- <StatCard
+ <MetricCard
label="Violations"
value={isLoading ? "—" : violations.length}
description="Dependencies that break a declared rule"
icon={<ShieldAlert className="h-4 w-4 text-[var(--color-risk-high)]" />}
/>
- <StatCard
+ <MetricCard
label="Dependency cycles"
value={isLoading ? "—" : cycles.length}
description="Circular service dependencies"
diff --git a/packages/web/src/app/workspace/contracts/page.tsx b/packages/web/src/app/workspace/contracts/page.tsx
index 5f50c37ab..b71d1fb3b 100644
--- a/packages/web/src/app/workspace/contracts/page.tsx
+++ b/packages/web/src/app/workspace/contracts/page.tsx
@@ -7,9 +7,14 @@ import { useWorkspace } from "@/lib/hooks/use-workspace";
import { ContractLinksTable } from "@repowise-dev/ui/workspace/contract-links-table";
import { ContractTypeBadge, RoleBadge } from "@repowise-dev/ui/workspace/contract-type-badge";
import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
-import { EmptyState } from "@repowise-dev/ui/shared";
-import { Skeleton } from "@repowise-dev/ui/ui/skeleton";
+import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
+import {
+ EmptyState,
+ ResponsiveTable,
+ TableSkeleton,
+ type ResponsiveColumn,
+} from "@repowise-dev/ui/shared";
+import type { WorkspaceContractEntry } from "@/lib/api/types";
const TYPE_OPTIONS = [
{ value: "", label: "All Types" },
@@ -25,6 +30,57 @@ const ROLE_OPTIONS = [
{ value: "consumer", label: "Consumers" },
];
+type ContractRow = WorkspaceContractEntry & { _key: string };
+
+const CONTRACT_COLUMNS: ResponsiveColumn<ContractRow>[] = [
+ {
+ key: "contract_id",
+ header: "Contract ID",
+ render: (c) => (
+ <span className="text-xs font-mono text-[var(--color-text-secondary)] break-all">
+ {c.contract_id}
+ </span>
+ ),
+ },
+ {
+ key: "contract_type",
+ header: "Type",
+ render: (c) => <ContractTypeBadge type={c.contract_type} />,
+ },
+ {
+ key: "role",
+ header: "Role",
+ render: (c) => <RoleBadge role={c.role} />,
+ },
+ {
+ key: "repo",
+ header: "Repo",
+ render: (c) => (
+ <span className="text-xs font-medium text-[var(--color-text-primary)]">{c.repo}</span>
+ ),
+ },
+ {
+ key: "file_path",
+ header: "File",
+ priority: 2,
+ render: (c) => (
+ <span className="text-xs font-mono text-[var(--color-text-tertiary)] truncate block max-w-[200px]">
+ {c.file_path}
+ </span>
+ ),
+ },
+ {
+ key: "confidence",
+ header: "Confidence",
+ align: "right",
+ render: (c) => (
+ <span className="text-xs text-[var(--color-text-tertiary)] tabular-nums">
+ {Math.round(c.confidence * 100)}%
+ </span>
+ ),
+ },
+];
+
export default function ContractsPage() {
const { workspace } = useWorkspace();
const [contractType, setContractType] = useState("");
@@ -67,23 +123,23 @@ export default function ContractsPage() {
{/* Summary Stats */}
<div className="grid grid-cols-2 gap-3 lg:grid-cols-4">
- <StatCard
+ <MetricCard
label="Total Contracts"
value={data?.total_contracts ?? "—"}
icon={<Link2 className="h-4 w-4" />}
/>
- <StatCard
+ <MetricCard
label="Matched Links"
value={data?.total_links ?? "—"}
icon={<Link2 className="h-4 w-4 text-[var(--color-success)]" />}
/>
- <StatCard
+ <MetricCard
label="Unmatched"
value={isLoading ? "—" : unmatchedCount}
description="No matching provider or consumer"
icon={<Link2 className="h-4 w-4 text-[var(--color-warning)]" />}
/>
- <StatCard
+ <MetricCard
label="By Type"
value={
data?.by_type
@@ -154,11 +210,7 @@ export default function ContractsPage() {
</CardHeader>
<CardContent className="pt-0">
{isLoading ? (
- <div className="space-y-3 py-4">
- {Array.from({ length: 5 }).map((_, i) => (
- <Skeleton key={i} className="h-10 w-full" />
- ))}
- </div>
+ <TableSkeleton rows={5} className="py-4" />
) : (
<ContractLinksTable links={data?.links ?? []} />
)}
@@ -174,11 +226,7 @@ export default function ContractsPage() {
</CardHeader>
<CardContent className="pt-0">
{isLoading ? (
- <div className="space-y-3 py-4">
- {Array.from({ length: 5 }).map((_, i) => (
- <Skeleton key={i} className="h-10 w-full" />
- ))}
- </div>
+ <TableSkeleton rows={5} className="py-4" />
) : (data?.contracts ?? []).length === 0 ? (
<EmptyState
className="p-6"
@@ -186,48 +234,14 @@ export default function ContractsPage() {
description="API contracts are detected during workspace indexing when providers and consumers share schemas."
/>
) : (
- <div className="overflow-x-auto">
- <table className="w-full text-sm">
- <thead>
- <tr className="border-b border-[var(--color-border-default)] text-left text-xs text-[var(--color-text-tertiary)]">
- <th className="pb-2 pr-4 font-medium">Contract ID</th>
- <th className="pb-2 pr-4 font-medium">Type</th>
- <th className="pb-2 pr-4 font-medium">Role</th>
- <th className="pb-2 pr-4 font-medium">Repo</th>
- <th className="pb-2 pr-4 font-medium">File</th>
- <th className="pb-2 font-medium w-20">Confidence</th>
- </tr>
- </thead>
- <tbody className="divide-y divide-[var(--color-border-default)]">
- {(data?.contracts ?? []).map((c, i) => (
- <tr key={i} className="hover:bg-[var(--color-bg-elevated)] transition-colors">
- <td className="py-2 pr-4">
- <span className="text-xs font-mono text-[var(--color-text-secondary)] break-all">
- {c.contract_id}
- </span>
- </td>
- <td className="py-2 pr-4">
- <ContractTypeBadge type={c.contract_type} />
- </td>
- <td className="py-2 pr-4">
- <RoleBadge role={c.role} />
- </td>
- <td className="py-2 pr-4 text-xs font-medium text-[var(--color-text-primary)]">
- {c.repo}
- </td>
- <td className="py-2 pr-4">
- <span className="text-xs font-mono text-[var(--color-text-tertiary)] truncate block max-w-[200px]">
- {c.file_path}
- </span>
- </td>
- <td className="py-2 text-xs text-[var(--color-text-tertiary)] tabular-nums">
- {Math.round(c.confidence * 100)}%
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
+ <ResponsiveTable
+ columns={CONTRACT_COLUMNS}
+ rows={(data?.contracts ?? []).map((c, i) => ({ ...c, _key: `${c.contract_id}|${i}` }))}
+ rowKey={(c) => c._key}
+ caption="All detected contracts"
+ stacked="md"
+ bare
+ />
)}
</CardContent>
</Card>
diff --git a/packages/web/src/app/workspace/page.tsx b/packages/web/src/app/workspace/page.tsx
index 1def4b37d..b062b8916 100644
--- a/packages/web/src/app/workspace/page.tsx
+++ b/packages/web/src/app/workspace/page.tsx
@@ -11,7 +11,7 @@ import {
ArrowRight,
} from "lucide-react";
import { getWorkspace, getWorkspaceCoChanges } from "@/lib/api/workspace";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
+import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
import { EmptyState } from "@repowise-dev/ui/shared/empty-state";
import { Card, CardContent, CardHeader, CardTitle } from "@repowise-dev/ui/ui/card";
import { RepoCard } from "@repowise-dev/ui/workspace/repo-card";
@@ -128,27 +128,27 @@ export default async function WorkspaceDashboardPage() {
{/* Aggregate Stats */}
<div className="grid grid-cols-2 gap-4 lg:grid-cols-5">
- <StatCard
+ <MetricCard
label="Total Files"
value={formatNumber(totalFiles)}
icon={<FileText className="h-4 w-4" />}
/>
- <StatCard
+ <MetricCard
label="Total Symbols"
value={formatNumber(totalSymbols)}
icon={<Code2 className="h-4 w-4" />}
/>
- <StatCard
+ <MetricCard
label="Avg Coverage"
value={`${avgCoverage}%`}
icon={<BarChart3 className="h-4 w-4" />}
/>
- <StatCard
+ <MetricCard
label="Hotspots"
value={totalHotspots}
icon={<Flame className="h-4 w-4 text-[var(--color-warning)]" />}
/>
- <StatCard
+ <MetricCard
label="Pages"
value={formatNumber(wsRepos.reduce((a, r) => a + r.page_count, 0))}
icon={<Code2 className="h-4 w-4 text-[var(--color-text-tertiary)]" />}
diff --git a/packages/web/src/app/workspace/sync-buttons.tsx b/packages/web/src/app/workspace/sync-buttons.tsx
index 39e7b7609..eb83ae4c1 100644
--- a/packages/web/src/app/workspace/sync-buttons.tsx
+++ b/packages/web/src/app/workspace/sync-buttons.tsx
@@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
import { RefreshCw } from "lucide-react";
import { syncWorkspace } from "@/lib/api/workspace";
import type { WorkspaceSyncResult } from "@/lib/api/types";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
type SyncState =
| { kind: "idle" }
@@ -46,7 +47,7 @@ export function SyncButton({
} catch (e) {
setState({
kind: "error",
- message: e instanceof Error ? e.message : "unknown error",
+ message: toFriendlyMessage(e),
});
}
};
diff --git a/packages/web/src/app/workspace/system-map/page.tsx b/packages/web/src/app/workspace/system-map/page.tsx
index 96bccff46..ea49ceb6c 100644
--- a/packages/web/src/app/workspace/system-map/page.tsx
+++ b/packages/web/src/app/workspace/system-map/page.tsx
@@ -15,7 +15,7 @@ import {
type RepoHealth,
} from "@repowise-dev/ui/workspace/system-map";
import type { NodeArchitectureRole } from "@/lib/api/types";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
+import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
import { Skeleton } from "@repowise-dev/ui/ui/skeleton";
import {
useWorkspaceSystemGraph,
@@ -106,7 +106,7 @@ export default function SystemMapPage() {
</div>
<div className="grid grid-cols-2 gap-3 lg:grid-cols-5">
- <StatCard
+ <MetricCard
label="Architecture score"
value={architecture ? `${architecture.score.toFixed(1)} / 10` : "—"}
description={
@@ -116,22 +116,22 @@ export default function SystemMapPage() {
}
icon={<Gauge className="h-4 w-4 text-[var(--color-accent-primary)]" />}
/>
- <StatCard
+ <MetricCard
label="Services"
value={isLoading ? "—" : serviceCount}
icon={<Boxes className="h-4 w-4" />}
/>
- <StatCard
+ <MetricCard
label="Relationships"
value={isLoading ? "—" : edgeCount}
icon={<Share2 className="h-4 w-4 text-[var(--color-accent-secondary)]" />}
/>
- <StatCard
+ <MetricCard
label="Providers / Consumers"
value={diag ? `${diag.total_providers} / ${diag.total_consumers}` : "—"}
icon={<ArrowLeftRight className="h-4 w-4 text-[var(--color-success)]" />}
/>
- <StatCard
+ <MetricCard
label="Orphans / Weak links"
value={diag ? `${diag.orphan_providers.length} / ${diag.weak_link_count}` : "—"}
description="Providers with no consumer; low-confidence links"
diff --git a/packages/web/src/components/architecture/dependencies-view.tsx b/packages/web/src/components/architecture/dependencies-view.tsx
index eab1274eb..9f084f911 100644
--- a/packages/web/src/components/architecture/dependencies-view.tsx
+++ b/packages/web/src/components/architecture/dependencies-view.tsx
@@ -8,6 +8,7 @@ import { ApiError } from "@repowise-dev/ui/shared/api-error";
import { Skeleton } from "@repowise-dev/ui/ui/skeleton";
import { fileEntityPath } from "@repowise-dev/ui/shared/entity";
import { getExternalSystems } from "@/lib/api/external-systems";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
export function DependenciesView({ repoId }: { repoId: string }) {
const { data, error, isLoading, mutate } = useSWR(
@@ -31,7 +32,7 @@ export function DependenciesView({ repoId }: { repoId: string }) {
{error ? (
<ApiError
title="Couldn't load the dependency registry"
- message={error instanceof Error ? error.message : String(error)}
+ message={toFriendlyMessage(error)}
onRetry={() => void mutate()}
/>
) : isLoading || !data ? (
diff --git a/packages/web/src/components/commits/commits-explorer.tsx b/packages/web/src/components/commits/commits-explorer.tsx
index 4328da4e3..96c98303d 100644
--- a/packages/web/src/components/commits/commits-explorer.tsx
+++ b/packages/web/src/components/commits/commits-explorer.tsx
@@ -4,7 +4,7 @@ import { useState } from "react";
import useSWR from "swr";
import { useQueryState } from "nuqs";
import { AlertTriangle, Bug, GitCommitHorizontal } from "lucide-react";
-import { StatCard } from "@repowise-dev/ui/shared/stat-card";
+import { MetricCard } from "@repowise-dev/ui/shared/metric-card";
import { Skeleton } from "@repowise-dev/ui/ui/skeleton";
import {
Sheet,
@@ -127,25 +127,25 @@ export function CommitsExplorer({ repoId }: { repoId: string }) {
)}
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
- <StatCard
+ <MetricCard
label="Commits"
value={total}
description="with change-risk"
icon={<GitCommitHorizontal className="h-4 w-4 text-[var(--color-text-tertiary)]" />}
/>
- <StatCard
+ <MetricCard
label="High priority"
value={highCount}
description="top risk tercile"
icon={<AlertTriangle className="h-4 w-4 text-[var(--color-error)]" />}
/>
- <StatCard
+ <MetricCard
label="Fix commits"
value={fixCount}
description="bug-fix subjects"
icon={<Bug className="h-4 w-4 text-[var(--color-warning)]" />}
/>
- <StatCard
+ <MetricCard
label="Avg entropy"
value={avgEntropy.toFixed(2)}
description="change diffusion"
diff --git a/packages/web/src/components/coupling/coupling-tab.tsx b/packages/web/src/components/coupling/coupling-tab.tsx
index 4b6289d06..d69de53da 100644
--- a/packages/web/src/components/coupling/coupling-tab.tsx
+++ b/packages/web/src/components/coupling/coupling-tab.tsx
@@ -5,6 +5,7 @@ import { ApiError } from "@repowise-dev/ui/shared/api-error";
import { Skeleton } from "@repowise-dev/ui/ui/skeleton";
import { getCoupling } from "@/lib/api/coupling";
import { CouplingView } from "@/components/coupling/coupling-view";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
/**
* Self-fetching host for the change-coupling Architecture tab. The Architecture
@@ -24,7 +25,7 @@ export function CouplingTab({ repoId }: { repoId: string }) {
{error ? (
<ApiError
title="Couldn't load change coupling"
- message={error instanceof Error ? error.message : String(error)}
+ message={toFriendlyMessage(error)}
onRetry={() => void mutate()}
/>
) : isLoading || !data ? (
diff --git a/packages/web/src/components/dashboard/quick-actions-wrapper.tsx b/packages/web/src/components/dashboard/quick-actions-wrapper.tsx
index 3e901ddc8..2d41c4ce8 100644
--- a/packages/web/src/components/dashboard/quick-actions-wrapper.tsx
+++ b/packages/web/src/components/dashboard/quick-actions-wrapper.tsx
@@ -10,6 +10,7 @@ import { syncRepo, fullResyncRepo } from "@/lib/api/repos";
import { listJobs } from "@/lib/api/jobs";
import { analyzeDeadCode } from "@/lib/api/dead-code";
import { GenerationProgressWrapper } from "@/components/jobs/generation-progress-wrapper";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
interface Props {
repoId: string;
@@ -67,7 +68,7 @@ export function QuickActionsWrapper({
toast.info("Dead code analysis started");
}
} catch (e) {
- const msg = e instanceof Error ? e.message : "Unknown error";
+ const msg = toFriendlyMessage(e);
if (/already in progress/i.test(msg)) {
try {
const [running, pending] = await Promise.all([
diff --git a/packages/web/src/components/jobs/generation-progress-wrapper.tsx b/packages/web/src/components/jobs/generation-progress-wrapper.tsx
index 9b45cdc63..e3f05b8dd 100644
--- a/packages/web/src/components/jobs/generation-progress-wrapper.tsx
+++ b/packages/web/src/components/jobs/generation-progress-wrapper.tsx
@@ -7,6 +7,7 @@ import { useJob } from "@/lib/hooks/use-job";
import { cancelJob } from "@/lib/api/jobs";
import { formatNumber } from "@repowise-dev/ui/lib/format";
import { computeElapsedMs } from "@/lib/jobs/progress";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
interface Props {
jobId: string;
@@ -89,7 +90,7 @@ export function GenerationProgressWrapper({ jobId, repoName, onDone, onRetry, qu
// owns the toast so cancel-from-button and cancel-from-elsewhere match.
} catch (e) {
toast.error("Couldn't cancel job", {
- description: e instanceof Error ? e.message : "Unknown error",
+ description: toFriendlyMessage(e),
});
} finally {
setCancelling(false);
diff --git a/packages/web/src/components/repos/coordinator-health-panel.tsx b/packages/web/src/components/repos/coordinator-health-panel.tsx
index 723c5446c..74b3faaad 100644
--- a/packages/web/src/components/repos/coordinator-health-panel.tsx
+++ b/packages/web/src/components/repos/coordinator-health-panel.tsx
@@ -4,6 +4,7 @@ import { useState } from "react";
import { RefreshCw } from "lucide-react";
import { Button } from "@repowise-dev/ui/ui/button";
import { getCoordinatorHealth, type CoordinatorHealth } from "@/lib/api/health";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
interface Props {
repoId: string;
@@ -42,7 +43,7 @@ export function CoordinatorHealthPanel({ repoId, initial }: Props) {
const result = await getCoordinatorHealth(repoId);
setData(result);
} catch (e) {
- setError(e instanceof Error ? e.message : "Failed to fetch health");
+ setError(toFriendlyMessage(e, "Failed to fetch health"));
} finally {
setLoading(false);
}
diff --git a/packages/web/src/components/repos/delete-repo-button.tsx b/packages/web/src/components/repos/delete-repo-button.tsx
index 3e672035b..79f483c59 100644
--- a/packages/web/src/components/repos/delete-repo-button.tsx
+++ b/packages/web/src/components/repos/delete-repo-button.tsx
@@ -13,6 +13,7 @@ import {
DialogTitle,
DialogFooter,
} from "@repowise-dev/ui/ui/dialog";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
interface DeleteRepoButtonProps {
repoId: string;
@@ -43,7 +44,7 @@ export function DeleteRepoButton({
router.refresh();
}
} catch (err) {
- toast.error(`Failed to delete: ${err instanceof Error ? err.message : "Unknown error"}`);
+ toast.error(`Failed to delete: ${toFriendlyMessage(err)}`);
} finally {
setDeleting(false);
}
diff --git a/packages/web/src/components/repos/operations-panel.tsx b/packages/web/src/components/repos/operations-panel.tsx
index 54ebb1e34..d56b86d18 100644
--- a/packages/web/src/components/repos/operations-panel.tsx
+++ b/packages/web/src/components/repos/operations-panel.tsx
@@ -14,6 +14,7 @@ import {
DialogFooter,
} from "@repowise-dev/ui/ui/dialog";
import { GenerationProgressWrapper as GenerationProgress } from "@/components/jobs/generation-progress-wrapper";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
interface Props {
repoId: string;
@@ -33,7 +34,7 @@ export function OperationsPanel({ repoId, repoName }: Props) {
toast.info(`Sync started — ${repoName}`);
} catch (e) {
toast.error("Sync failed", {
- description: e instanceof Error ? e.message : "Unknown error",
+ description: toFriendlyMessage(e),
});
} finally {
setLoading(null);
@@ -49,7 +50,7 @@ export function OperationsPanel({ repoId, repoName }: Props) {
toast.info(`Full resync started — ${repoName}`);
} catch (e) {
toast.error("Resync failed", {
- description: e instanceof Error ? e.message : "Unknown error",
+ description: toFriendlyMessage(e),
});
} finally {
setLoading(null);
diff --git a/packages/web/src/components/repos/repo-settings-form-wrapper.tsx b/packages/web/src/components/repos/repo-settings-form-wrapper.tsx
index 3c002a9e9..746049bae 100644
--- a/packages/web/src/components/repos/repo-settings-form-wrapper.tsx
+++ b/packages/web/src/components/repos/repo-settings-form-wrapper.tsx
@@ -8,6 +8,7 @@ import { fullResyncRepo, updateRepo } from "@/lib/api/repos";
import type { RepoResponse } from "@/lib/api/types";
import { DEFAULT_WIKI_STYLE } from "@repowise-dev/types";
import type { RepoSettingsValue, WikiStyle } from "@repowise-dev/types/settings";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
interface Props {
repo: RepoResponse;
@@ -49,7 +50,7 @@ export function RepoSettingsFormWrapper({ repo }: Props) {
setRegenOpen(true);
}
} catch (err) {
- toast.error(err instanceof Error ? err.message : "Failed to save settings");
+ toast.error(toFriendlyMessage(err, "Failed to save settings"));
throw err;
}
}
@@ -62,7 +63,7 @@ export function RepoSettingsFormWrapper({ repo }: Props) {
setRegenOpen(false);
} catch (err) {
toast.error(
- err instanceof Error ? err.message : "Failed to queue regeneration",
+ toFriendlyMessage(err, "Failed to queue regeneration"),
);
} finally {
setRegenLoading(false);
diff --git a/packages/web/src/components/risk/security-tab.tsx b/packages/web/src/components/risk/security-tab.tsx
index 18c61b58b..7e8124003 100644
--- a/packages/web/src/components/risk/security-tab.tsx
+++ b/packages/web/src/components/risk/security-tab.tsx
@@ -15,6 +15,7 @@ import { listSecurityFindings, type SecurityFinding } from "@/lib/api/security";
import { syncRepo } from "@/lib/api/repos";
import { useFileCardHost } from "@/components/shared/file-card-host";
import type { FileCardData } from "@repowise-dev/ui/shared/file-card";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
export function SecurityTab({ repoId }: { repoId: string }) {
const { data: findings, isLoading, error } = useSWR<SecurityFinding[]>(
@@ -31,7 +32,7 @@ export function SecurityTab({ repoId }: { repoId: string }) {
await syncRepo(repoId);
toast.success("Sync started — findings refresh when it completes");
} catch (err) {
- toast.error(err instanceof Error ? err.message : "Couldn't start a sync");
+ toast.error(toFriendlyMessage(err, "Couldn't start a sync"));
} finally {
setRescanning(false);
}
diff --git a/packages/web/src/components/settings/connection-section.tsx b/packages/web/src/components/settings/connection-section.tsx
index 3adc2e599..d583da791 100644
--- a/packages/web/src/components/settings/connection-section.tsx
+++ b/packages/web/src/components/settings/connection-section.tsx
@@ -10,6 +10,7 @@ import { Label } from "@repowise-dev/ui/ui/label";
import { Input } from "@repowise-dev/ui/ui/input";
import { Button } from "@repowise-dev/ui/ui/button";
import type { HealthResponse } from "@/lib/api/types";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
export function ConnectionSection() {
const [apiUrl, setApiUrl] = useState("");
@@ -52,7 +53,7 @@ export function ConnectionSection() {
const h = await getHealth();
setHealth(h);
} catch (e) {
- setError(e instanceof Error ? e.message : "Connection failed");
+ setError(toFriendlyMessage(e, "Connection failed"));
} finally {
setTesting(false);
}
diff --git a/packages/web/src/components/symbols/hotspot-top-symbols-host.tsx b/packages/web/src/components/symbols/hotspot-top-symbols-host.tsx
index 4167af13c..397d6e3be 100644
--- a/packages/web/src/components/symbols/hotspot-top-symbols-host.tsx
+++ b/packages/web/src/components/symbols/hotspot-top-symbols-host.tsx
@@ -4,6 +4,7 @@ import useSWR from "swr";
import { TopSymbolsRow } from "@repowise-dev/ui/symbols/top-symbols-row";
import { listSymbolsPage } from "@/lib/api/symbols";
import type { SymbolResponse } from "@/lib/api/types";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
interface Props {
repoId: string;
@@ -36,7 +37,7 @@ export function HotspotTopSymbolsHost({ repoId, filePath, onSelectSymbol }: Prop
<TopSymbolsRow
symbols={data?.items}
loading={isLoading}
- error={error instanceof Error ? error.message : error ? String(error) : undefined}
+ error={error ? toFriendlyMessage(error) : undefined}
onSelect={onSelectSymbol}
seeAllHref={seeAllHref}
/>
diff --git a/packages/web/src/components/wiki/human-notes.tsx b/packages/web/src/components/wiki/human-notes.tsx
index cb21da771..c53d86e96 100644
--- a/packages/web/src/components/wiki/human-notes.tsx
+++ b/packages/web/src/components/wiki/human-notes.tsx
@@ -3,6 +3,7 @@
import { toast } from "sonner";
import { HumanNotes as HumanNotesShell } from "@repowise-dev/ui/wiki/human-notes";
import { updatePageNotes } from "@/lib/api/pages";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
/**
* Web data wrapper around the presentational ``HumanNotes`` ui shell — owns the
@@ -25,7 +26,7 @@ export function HumanNotes({
return updated.human_notes;
} catch (e) {
toast.error("Couldn't save note", {
- description: e instanceof Error ? e.message : undefined,
+ description: toFriendlyMessage(e),
});
throw e;
}
diff --git a/packages/web/src/components/wiki/regenerate-button.tsx b/packages/web/src/components/wiki/regenerate-button.tsx
index 81e56c0f2..0c7b62a75 100644
--- a/packages/web/src/components/wiki/regenerate-button.tsx
+++ b/packages/web/src/components/wiki/regenerate-button.tsx
@@ -9,6 +9,7 @@ import { formatTokens } from "@repowise-dev/ui/lib/format";
import { getPageById, regeneratePage } from "@/lib/api/pages";
import { GenerationProgressWrapper as GenerationProgress } from "@/components/jobs/generation-progress-wrapper";
import { WIKI_STYLES } from "@repowise-dev/types";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
interface Props {
pageId: string;
@@ -50,7 +51,7 @@ export function RegenerateButtonWrapper({ pageId }: Props) {
toast.info("Regeneration queued");
} catch (e) {
toast.error("Failed to queue regeneration", {
- description: e instanceof Error ? e.message : undefined,
+ description: toFriendlyMessage(e),
});
} finally {
setLoading(false);
diff --git a/packages/web/src/lib/hooks/use-chat.ts b/packages/web/src/lib/hooks/use-chat.ts
index 21cad5330..0b145c626 100644
--- a/packages/web/src/lib/hooks/use-chat.ts
+++ b/packages/web/src/lib/hooks/use-chat.ts
@@ -7,6 +7,7 @@ import type {
ChatUIToolCall as ChatToolCall,
ChatUIMessage as ChatMessage,
} from "@repowise-dev/types/chat";
+import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
export type { ChatToolCall, ChatMessage };
@@ -104,7 +105,7 @@ export function useChat(repoId: string) {
setState((prev) => ({
...prev,
isStreaming: false,
- error: err instanceof Error ? err.message : String(err),
+ error: toFriendlyMessage(err),
messages: prev.messages.map((m) =>
m.id === asstMsgId ? { ...m, isStreaming: false } : m,
),
@@ -206,7 +207,7 @@ export function useChat(repoId: string) {
} catch (err) {
setState((prev) => ({
...prev,
- error: err instanceof Error ? err.message : String(err),
+ error: toFriendlyMessage(err),
}));
}
},