Skip to content

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

feat(ui): wiki hover previews, tooltip delay setting, tooltip breakdowns

Martin Vogel9c9e35379514
diff --git a/graph-ui/src/components/DisplaySettingsMenu.tsx b/graph-ui/src/components/DisplaySettingsMenu.tsx
index 7b817da06..fe66cfea8 100644
--- a/graph-ui/src/components/DisplaySettingsMenu.tsx
+++ b/graph-ui/src/components/DisplaySettingsMenu.tsx
@@ -17,23 +17,35 @@ interface SliderRowProps {
value: number;
min: number;
max: number;
+ /* Multiplier rows use the defaults; the ms row overrides both. */
+ step?: number;
+ format?: (value: number) => string;
onChange: (value: number) => void;
}
-function SliderRow({ label, hint, value, min, max, onChange }: SliderRowProps) {
+function SliderRow({
+ label,
+ hint,
+ value,
+ min,
+ max,
+ step = 0.05,
+ format = (v) => `${v.toFixed(2)}×`,
+ onChange,
+}: SliderRowProps) {
return (
<label className="block">
<div className="flex items-center justify-between mb-1">
<span className="text-[13px] text-foreground/70">{label}</span>
<span className="text-[12px] font-mono text-cyan-300/70 tabular-nums">
- {value.toFixed(2)}×
+ {format(value)}
</span>
</div>
<input
type="range"
min={min}
max={max}
- step={0.05}
+ step={step}
value={value}
onChange={(e) => onChange(parseFloat(e.target.value))}
className="w-full accent-cyan-400 cursor-pointer"
@@ -79,7 +91,8 @@ export function DisplaySettingsMenu({
const isDefault =
settings.edgeBrightness === DEFAULT_DISPLAY_SETTINGS.edgeBrightness &&
settings.nodeGlow === DEFAULT_DISPLAY_SETTINGS.nodeGlow &&
- settings.bloom === DEFAULT_DISPLAY_SETTINGS.bloom;
+ settings.bloom === DEFAULT_DISPLAY_SETTINGS.bloom &&
+ settings.tooltipDelayMs === DEFAULT_DISPLAY_SETTINGS.tooltipDelayMs;
return (
<div ref={rootRef} className="relative">
@@ -137,6 +150,16 @@ export function DisplaySettingsMenu({
max={DISPLAY_LIMITS.bloom.max}
onChange={(bloom) => set({ bloom })}
/>
+ <SliderRow
+ label="Tooltip delay"
+ hint="Hover dwell before help cards appear"
+ value={settings.tooltipDelayMs}
+ min={DISPLAY_LIMITS.tooltipDelayMs.min}
+ max={DISPLAY_LIMITS.tooltipDelayMs.max}
+ step={50}
+ format={(v) => `${Math.round(v)} ms`}
+ onChange={(tooltipDelayMs) => set({ tooltipDelayMs })}
+ />
<p className="text-[12px] text-foreground/45 pt-1 border-t border-border/30">
1.00× follows the automatic density compensation. Lower the
diff --git a/graph-ui/src/components/MetricChip.tsx b/graph-ui/src/components/MetricChip.tsx
index 79d6eba22..0a9c984b6 100644
--- a/graph-ui/src/components/MetricChip.tsx
+++ b/graph-ui/src/components/MetricChip.tsx
@@ -1,9 +1,12 @@
/* The wiki affordance: any metric name in the UI becomes a dotted-underline
* chip that opens the metric wiki panel — the label itself is the door to
* the definition. Inherits the surrounding typography so wrapping an
- * existing label changes nothing but the underline. */
-import { type ReactNode } from "react";
+ * existing label changes nothing but the underline. Dwelling (or focusing)
+ * shows a WikiHoverCard preview of the entry, which replaces the old native
+ * title tooltip — two tooltips on one chip would fight. */
+import { useRef, type ReactNode } from "react";
import { wikiEntry } from "../wiki/entries";
+import { WikiHoverCard } from "./WikiHoverCard";
export function MetricChip({
slug,
@@ -14,14 +17,18 @@ export function MetricChip({
onOpen: (slug: string) => void;
children?: ReactNode;
}) {
+ const anchorRef = useRef<HTMLButtonElement | null>(null);
return (
- <button
- type="button"
- onClick={() => onOpen(slug)}
- className="[font:inherit] [letter-spacing:inherit] text-inherit align-baseline text-left border-b border-dotted border-foreground/40 hover:border-primary hover:text-primary transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary rounded-none"
- title="What does this mean? Open the metric wiki"
- >
- {children ?? wikiEntry(slug)?.term ?? slug}
- </button>
+ <>
+ <button
+ ref={anchorRef}
+ type="button"
+ onClick={() => onOpen(slug)}
+ className="[font:inherit] [letter-spacing:inherit] text-inherit align-baseline text-left border-b border-dotted border-foreground/40 hover:border-primary hover:text-primary transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary rounded-none"
+ >
+ {children ?? wikiEntry(slug)?.term ?? slug}
+ </button>
+ <WikiHoverCard slug={slug} anchorRef={anchorRef} />
+ </>
);
}
diff --git a/graph-ui/src/components/NodeTooltip.tsx b/graph-ui/src/components/NodeTooltip.tsx
index 185983e09..f84116367 100644
--- a/graph-ui/src/components/NodeTooltip.tsx
+++ b/graph-ui/src/components/NodeTooltip.tsx
@@ -13,7 +13,27 @@ function lineRange(node: GraphNode): string | null {
return `L${node.start_line}`;
}
+/* The arithmetic behind the node, from the facts the scene payload already
+ * carries — no fetch on hover, ever (jitter). "fan" is a wiki term, but this
+ * tooltip follows the cursor with pointer-events off, so a MetricChip here
+ * would be an unclickable target — labels stay plain text; the wiki remains
+ * reachable from the panels. */
+function breakdownRows(node: GraphNode): [string, string][] {
+ const rows: [string, string][] = [];
+ if (node.in_calls !== undefined)
+ rows.push(["fan-in", node.in_calls.toLocaleString("en-US")]);
+ if (node.out_calls !== undefined)
+ rows.push(["fan-out", node.out_calls.toLocaleString("en-US")]);
+ if (node.start_line && node.end_line && node.end_line >= node.start_line)
+ rows.push([
+ "lines",
+ (node.end_line - node.start_line + 1).toLocaleString("en-US"),
+ ]);
+ return rows;
+}
+
export function NodeTooltip({ node }: NodeTooltipProps) {
+ const rows = breakdownRows(node);
return (
<Html
position={[node.x, node.y + node.size * 0.7, node.z]}
@@ -35,6 +55,20 @@ export function NodeTooltip({ node }: NodeTooltipProps) {
{lineRange(node) && <span className="text-foreground/40"> · {lineRange(node)}</span>}
</p>
)}
+ {rows.length > 0 && (
+ <table className="mt-1">
+ <tbody>
+ {rows.map(([label, value]) => (
+ <tr key={label}>
+ <td className="pr-4 text-foreground/45">{label}</td>
+ <td className="text-right tabular-nums text-foreground/70">
+ {value}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ )}
{node.status && node.status !== "structural" && (
<div className="flex items-center gap-1.5 mt-1">
<span
@@ -42,12 +76,6 @@ export function NodeTooltip({ node }: NodeTooltipProps) {
style={{ backgroundColor: colorForStatus(node.status) }}
/>
<span className="text-foreground/45">{node.status}</span>
- {node.in_calls !== undefined && (
- <span className="text-foreground/40 tabular-nums">
- · in {node.in_calls}
- {node.out_calls !== undefined && ` · out ${node.out_calls}`}
- </span>
- )}
</div>
)}
<p className="text-foreground/35 mt-1 text-[12px]">click for code →</p>
diff --git a/graph-ui/src/components/RegionTooltip.tsx b/graph-ui/src/components/RegionTooltip.tsx
index ff6577d81..e8a4048f3 100644
--- a/graph-ui/src/components/RegionTooltip.tsx
+++ b/graph-ui/src/components/RegionTooltip.tsx
@@ -3,8 +3,20 @@ import type { GraphNode, Region } from "../lib/types";
import { cohesionWord } from "../lib/regions";
/* Hover card for a region blob in the coarsest galaxy view: what a human
- * needs before deciding to drill — size, cohesion in words, the hub. */
+ * needs before deciding to drill — the region's arithmetic as scannable
+ * rows, cohesion in words, the hub. Only facts the regions payload already
+ * carries are shown — no fetch on hover, ever (jitter); internal/external
+ * share and the top external tie are not in the payload today and stay in
+ * the RegionPanel. "cohesion" is a wiki term, but this tooltip follows the
+ * cursor with pointer-events off, so a MetricChip here would be an
+ * unclickable target — labels stay plain text; the wiki remains reachable
+ * from the panels. */
export function RegionTooltip({ region, node }: { region: Region; node: GraphNode }) {
+ const rows: [string, string][] = [
+ ["symbols", region.members.toLocaleString("en-US")],
+ ["files", region.files.toLocaleString("en-US")],
+ ["cohesion", region.cohesion.toFixed(2)],
+ ];
return (
<Html
position={[node.x, node.y + node.size * 0.7, node.z]}
@@ -19,11 +31,19 @@ export function RegionTooltip({ region, node }: { region: Region; node: GraphNod
/>
<span className="text-foreground font-medium truncate">{region.name}</span>
</div>
- <p className="text-foreground/50 tabular-nums">
- {region.members.toLocaleString("en-US")} symbols ·{" "}
- {region.files.toLocaleString("en-US")} files ·{" "}
- {cohesionWord(region.cohesion)} ({region.cohesion.toFixed(2)})
- </p>
+ <table>
+ <tbody>
+ {rows.map(([label, value]) => (
+ <tr key={label}>
+ <td className="pr-4 text-foreground/45">{label}</td>
+ <td className="text-right tabular-nums text-foreground/70">
+ {value}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ <p className="text-foreground/45 mt-0.5">{cohesionWord(region.cohesion)}</p>
{region.hub && (
<p className="text-foreground/45 font-mono truncate mt-0.5">hub: {region.hub}</p>
)}
diff --git a/graph-ui/src/components/WikiHoverCard.test.tsx b/graph-ui/src/components/WikiHoverCard.test.tsx
new file mode 100644
index 000000000..255b1fc60
--- /dev/null
+++ b/graph-ui/src/components/WikiHoverCard.test.tsx
@@ -0,0 +1,139 @@
+/* @vitest-environment jsdom */
+import "@testing-library/jest-dom/vitest";
+import { act, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { MetricChip } from "./MetricChip";
+import { WikiPanel } from "./WikiPanel";
+import {
+ DEFAULT_DISPLAY_SETTINGS,
+ loadDisplaySettings,
+ saveDisplaySettings,
+} from "../lib/density";
+
+/* The hover card is exercised through MetricChip — the integration every
+ * chip everywhere actually gets. Timing is deterministic via fake timers. */
+describe("WikiHoverCard", () => {
+ beforeEach(() => {
+ localStorage.clear();
+ vi.useFakeTimers();
+ });
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ const hoverChip = () => {
+ const chip = screen.getByRole("button", { name: "hotspot" });
+ fireEvent.mouseEnter(chip);
+ return chip;
+ };
+
+ it("shows the entry preview after the default dwell on hover", () => {
+ render(<MetricChip slug="hotspot" onOpen={() => {}} />);
+ hoverChip();
+
+ act(() => vi.advanceTimersByTime(349));
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
+
+ act(() => vi.advanceTimersByTime(1));
+ const card = screen.getByRole("tooltip");
+ expect(card).toBeInTheDocument();
+ /* term + tier chip + the single-source sentence + the hint line */
+ expect(card).toHaveTextContent("hotspot");
+ expect(card).toHaveTextContent("first-class");
+ expect(card).toHaveTextContent(/where fixes cluster/);
+ expect(card).toHaveTextContent("click for more →");
+ });
+
+ it("never shows when the pointer leaves before the dwell elapses", () => {
+ render(<MetricChip slug="hotspot" onOpen={() => {}} />);
+ const chip = hoverChip();
+
+ act(() => vi.advanceTimersByTime(200));
+ fireEvent.mouseLeave(chip);
+ act(() => vi.advanceTimersByTime(5000));
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
+ });
+
+ it("shows on keyboard focus and closes after blur (symmetric with hover)", () => {
+ render(<MetricChip slug="hotspot" onOpen={() => {}} />);
+ const chip = screen.getByRole("button", { name: "hotspot" });
+
+ fireEvent.focus(chip);
+ act(() => vi.advanceTimersByTime(350));
+ expect(screen.getByRole("tooltip")).toBeInTheDocument();
+
+ fireEvent.blur(chip);
+ act(() => vi.advanceTimersByTime(150));
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
+ });
+
+ it("stays open when the pointer moves into the card, with no auto-timeout", () => {
+ render(<MetricChip slug="hotspot" onOpen={() => {}} />);
+ const chip = hoverChip();
+ act(() => vi.advanceTimersByTime(350));
+
+ /* Leave the chip within the grace, land on the card — it must survive. */
+ fireEvent.mouseLeave(chip);
+ fireEvent.mouseEnter(screen.getByRole("tooltip"));
+ act(() => vi.advanceTimersByTime(60_000)); /* persistent: no timeout */
+ expect(screen.getByRole("tooltip")).toBeInTheDocument();
+
+ /* Leaving the card closes after the grace. */
+ fireEvent.mouseLeave(screen.getByRole("tooltip"));
+ act(() => vi.advanceTimersByTime(150));
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
+ });
+
+ it("Escape dismisses the card without closing the panel underneath", () => {
+ const onClose = vi.fn();
+ render(<WikiPanel slug="hotspot" onClose={onClose} onNavigate={() => {}} />);
+
+ /* hotspot's footer pairs it with tested — hover that chip. */
+ fireEvent.mouseEnter(screen.getByRole("button", { name: "tested" }));
+ act(() => vi.advanceTimersByTime(350));
+ expect(screen.getByRole("tooltip")).toBeInTheDocument();
+
+ fireEvent.keyDown(document, { key: "Escape" });
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
+ expect(onClose).not.toHaveBeenCalled();
+ });
+
+ it("keeps the click behavior: opens the wiki and yields the preview", () => {
+ const onOpen = vi.fn();
+ render(<MetricChip slug="hotspot" onOpen={onOpen} />);
+ const chip = hoverChip();
+ act(() => vi.advanceTimersByTime(350));
+ expect(screen.getByRole("tooltip")).toBeInTheDocument();
+
+ fireEvent.click(chip);
+ expect(onOpen).toHaveBeenCalledWith("hotspot");
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
+ });
+
+ it("respects the delay configured in Display settings", () => {
+ saveDisplaySettings({ ...DEFAULT_DISPLAY_SETTINGS, tooltipDelayMs: 600 });
+ render(<MetricChip slug="hotspot" onOpen={() => {}} />);
+ hoverChip();
+
+ act(() => vi.advanceTimersByTime(599));
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
+ act(() => vi.advanceTimersByTime(1));
+ expect(screen.getByRole("tooltip")).toBeInTheDocument();
+ });
+});
+
+describe("tooltip delay setting", () => {
+ beforeEach(() => localStorage.clear());
+
+ it("round-trips localStorage", () => {
+ saveDisplaySettings({ ...DEFAULT_DISPLAY_SETTINGS, tooltipDelayMs: 500 });
+ expect(loadDisplaySettings().tooltipDelayMs).toBe(500);
+ });
+
+ it("falls back to the default when an older payload lacks the key", () => {
+ localStorage.setItem("cbm-display", JSON.stringify({ edgeBrightness: 2 }));
+ const settings = loadDisplaySettings();
+ expect(settings.edgeBrightness).toBe(2);
+ expect(settings.tooltipDelayMs).toBe(DEFAULT_DISPLAY_SETTINGS.tooltipDelayMs);
+ });
+});
diff --git a/graph-ui/src/components/WikiHoverCard.tsx b/graph-ui/src/components/WikiHoverCard.tsx
new file mode 100644
index 000000000..065087f31
--- /dev/null
+++ b/graph-ui/src/components/WikiHoverCard.tsx
@@ -0,0 +1,186 @@
+/* Hover preview of a wiki entry — the single-source sentence surfaced at the
+ * point of curiosity, before the click. Appears after a dwell on the anchor
+ * chip (configurable in Display settings) and follows WCAG 1.4.13:
+ * dismissible (Esc closes just the card, not the panel underneath),
+ * hoverable (a short grace lets the pointer travel into the card),
+ * persistent (no auto-timeout while hovered or focused).
+ *
+ * The card is portaled to <body> — the same fix ProjectSwitcher needed: the
+ * header's backdrop-filter makes it a stacking context, so anything left
+ * inside paints as one atomic layer and gets dimmed by body-level overlays. */
+import {
+ useCallback,
+ useEffect,
+ useId,
+ useLayoutEffect,
+ useRef,
+ useState,
+} from "react";
+import { createPortal } from "react-dom";
+import { loadTooltipDelayMs } from "../lib/density";
+import { useUiMessages } from "../lib/i18n";
+import { wikiEntry } from "../wiki/entries";
+import { TIER_TONE } from "./wikiTier";
+
+/* Leaving the chip closes after this grace — long enough to reach the card,
+ * short enough that the card never lingers over unrelated content. */
+const HOVER_GRACE_MS = 150;
+const ANCHOR_GAP = 6;
+const VIEWPORT_PAD = 8;
+
+interface WikiHoverCardProps {
+ slug: string;
+ /* The chip the card anchors to; the component wires its own hover/focus
+ * listeners so call sites stay one-line. */
+ anchorRef: React.RefObject<HTMLElement | null>;
+ /* Dwell before showing; defaults to the persisted display setting. */
+ delayMs?: number;
+}
+
+export function WikiHoverCard({ slug, anchorRef, delayMs }: WikiHoverCardProps) {
+ const [pos, setPos] = useState<{ top: number; left: number } | null>(null);
+ const cardRef = useRef<HTMLDivElement | null>(null);
+ const showTimer = useRef<number | null>(null);
+ const hideTimer = useRef<number | null>(null);
+ const cardId = useId();
+ const t = useUiMessages();
+ const entry = wikiEntry(slug);
+ const open = pos !== null;
+
+ const cancelHide = useCallback(() => {
+ if (hideTimer.current !== null) {
+ clearTimeout(hideTimer.current);
+ hideTimer.current = null;
+ }
+ }, []);
+ const armHide = useCallback(() => {
+ cancelHide();
+ hideTimer.current = window.setTimeout(() => {
+ hideTimer.current = null;
+ setPos(null);
+ }, HOVER_GRACE_MS);
+ }, [cancelHide]);
+ const dismiss = useCallback(() => {
+ if (showTimer.current !== null) {
+ clearTimeout(showTimer.current);
+ showTimer.current = null;
+ }
+ cancelHide();
+ setPos(null);
+ }, [cancelHide]);
+
+ /* Anchor wiring: dwell on hover AND focus (symmetric), grace on leave and
+ * blur, immediate close on click — the click opens the full panel, so the
+ * preview yields. The delay is read when the timer is armed, so a change
+ * in the Display menu applies to the very next hover. */
+ useEffect(() => {
+ const anchor = anchorRef.current;
+ if (!anchor || !entry) return;
+ const show = () => {
+ const rect = anchor.getBoundingClientRect();
+ setPos({ top: rect.bottom + ANCHOR_GAP, left: rect.left });
+ };
+ const enter = () => {
+ cancelHide();
+ if (showTimer.current !== null) return;
+ showTimer.current = window.setTimeout(() => {
+ showTimer.current = null;
+ show();
+ }, delayMs ?? loadTooltipDelayMs());
+ };
+ const leave = () => {
+ if (showTimer.current !== null) {
+ clearTimeout(showTimer.current);
+ showTimer.current = null;
+ }
+ armHide();
+ };
+ anchor.addEventListener("mouseenter", enter);
+ anchor.addEventListener("mouseleave", leave);
+ anchor.addEventListener("focus", enter);
+ anchor.addEventListener("blur", leave);
+ anchor.addEventListener("click", dismiss);
+ return () => {
+ anchor.removeEventListener("mouseenter", enter);
+ anchor.removeEventListener("mouseleave", leave);
+ anchor.removeEventListener("focus", enter);
+ anchor.removeEventListener("blur", leave);
+ anchor.removeEventListener("click", dismiss);
+ dismiss();
+ };
+ }, [entry, delayMs, anchorRef, armHide, cancelHide, dismiss]);
+
+ /* While open: Esc dismisses, scroll/resize would desync the fixed anchor
+ * so they close, and the card describes its trigger for screen readers. */
+ useEffect(() => {
+ if (!open) return;
+ const anchor = anchorRef.current;
+ anchor?.setAttribute("aria-describedby", cardId);
+ const onKey = (event: KeyboardEvent) => {
+ if (event.key !== "Escape") return;
+ /* Capture + stopPropagation: Esc dismisses ONLY the topmost hover
+ * content, not the wiki panel listening for the same key beneath. */
+ event.stopPropagation();
+ dismiss();
+ };
+ const close = () => dismiss();
+ document.addEventListener("keydown", onKey, true);
+ window.addEventListener("scroll", close, true);
+ window.addEventListener("resize", close);
+ return () => {
+ anchor?.removeAttribute("aria-describedby");
+ document.removeEventListener("keydown", onKey, true);
+ window.removeEventListener("scroll", close, true);
+ window.removeEventListener("resize", close);
+ };
+ }, [open, anchorRef, cardId, dismiss]);
+
+ /* Clamp within the viewport once the rendered size is known — the card has
+ * no fixed width (i18n), only a max-w, so measure rather than estimate. */
+ useLayoutEffect(() => {
+ if (!open) return;
+ const card = cardRef.current;
+ const anchor = anchorRef.current;
+ if (!card || !anchor) return;
+ const box = card.getBoundingClientRect();
+ const at = anchor.getBoundingClientRect();
+ let top = at.bottom + ANCHOR_GAP;
+ let left = at.left;
+ if (left + box.width > window.innerWidth - VIEWPORT_PAD)
+ left = Math.max(VIEWPORT_PAD, window.innerWidth - VIEWPORT_PAD - box.width);
+ if (
+ top + box.height > window.innerHeight - VIEWPORT_PAD &&
+ at.top - box.height - ANCHOR_GAP >= VIEWPORT_PAD
+ )
+ top = at.top - box.height - ANCHOR_GAP; /* flip above the chip */
+ setPos((prev) =>
+ prev && prev.top === top && prev.left === left ? prev : { top, left },
+ );
+ }, [open, anchorRef]);
+
+ if (!entry || !pos) return null;
+
+ return createPortal(
+ <div
+ ref={cardRef}
+ id={cardId}
+ role="tooltip"
+ className="fixed z-50 max-w-[34ch] bg-popover/95 backdrop-blur border border-border/60 rounded-md px-3 py-2 text-xs shadow-xl"
+ style={{ top: pos.top, left: pos.left }}
+ onMouseEnter={cancelHide}
+ onMouseLeave={armHide}
+ >
+ <div className="flex items-center gap-2 mb-1">
+ <span className="text-foreground/90 font-medium">{entry.term}</span>
+ <span
+ className={`px-1.5 py-px rounded text-[11px] font-medium ${TIER_TONE[entry.tier]}`}
+ >
+ {entry.tier}
+ </span>
+ </div>
+ <p className="text-foreground/70 leading-relaxed">{entry.sentence}</p>
+ <p className="text-foreground/35 mt-1 text-[12px]">{t.wiki.clickForMore}</p>
+ </div>,
+ document.body,
+ );
+}
diff --git a/graph-ui/src/components/WikiPanel.tsx b/graph-ui/src/components/WikiPanel.tsx
index f26f6f071..4a5b24bef 100644
--- a/graph-ui/src/components/WikiPanel.tsx
+++ b/graph-ui/src/components/WikiPanel.tsx
@@ -7,8 +7,9 @@
import { useEffect, useState } from "react";
import { ScrollArea } from "@/components/ui/scroll-area";
import { useUiMessages } from "../lib/i18n";
-import { wikiEntry, type WikiTier } from "../wiki/entries";
+import { wikiEntry } from "../wiki/entries";
import { MetricChip } from "./MetricChip";
+import { TIER_TONE } from "./wikiTier";
interface WikiPanelProps {
slug: string;
@@ -16,12 +17,6 @@ interface WikiPanelProps {
onNavigate: (slug: string) => void;
}
-const TIER_TONE: Record<WikiTier, string> = {
- "first-class": "bg-emerald-400/10 text-emerald-300/80",
- caveated: "bg-amber-400/10 text-amber-300/80",
- refused: "bg-surface-3 text-foreground/40 border border-border/40",
-};
-
function SectionHeading({ children }: { children: string }) {
return (
<p className="text-[12px] uppercase tracking-widest text-foreground/40 mb-1.5">
diff --git a/graph-ui/src/components/wikiTier.ts b/graph-ui/src/components/wikiTier.ts
new file mode 100644
index 000000000..27e2acbdd
--- /dev/null
+++ b/graph-ui/src/components/wikiTier.ts
@@ -0,0 +1,9 @@
+/* Tier → chip tone, shared by the wiki panel and the hover preview so the
+ * two surfaces can never drift apart. */
+import type { WikiTier } from "../wiki/entries";
+
+export const TIER_TONE: Record<WikiTier, string> = {
+ "first-class": "bg-emerald-400/10 text-emerald-300/80",
+ caveated: "bg-amber-400/10 text-amber-300/80",
+ refused: "bg-surface-3 text-foreground/40 border border-border/40",
+};
diff --git a/graph-ui/src/lib/density.test.ts b/graph-ui/src/lib/density.test.ts
index 28a0b9095..1944776d3 100644
--- a/graph-ui/src/lib/density.test.ts
+++ b/graph-ui/src/lib/density.test.ts
@@ -100,9 +100,11 @@ describe("clampDisplaySettings", () => {
expect(clampDisplaySettings({})).toEqual(DEFAULT_DISPLAY_SETTINGS);
expect(
clampDisplaySettings({ edgeBrightness: 99, nodeGlow: -5, bloom: 1.5 }),
- ).toEqual({ edgeBrightness: 3, nodeGlow: 0, bloom: 1.5 });
+ ).toEqual({ edgeBrightness: 3, nodeGlow: 0, bloom: 1.5, tooltipDelayMs: 350 });
expect(clampDisplaySettings({ bloom: Number.NaN }).bloom).toBe(
DEFAULT_DISPLAY_SETTINGS.bloom,
);
+ expect(clampDisplaySettings({ tooltipDelayMs: 50 }).tooltipDelayMs).toBe(150);
+ expect(clampDisplaySettings({ tooltipDelayMs: 5000 }).tooltipDelayMs).toBe(800);
});
});
diff --git a/graph-ui/src/lib/density.ts b/graph-ui/src/lib/density.ts
index 63bea4893..9660711f7 100644
--- a/graph-ui/src/lib/density.ts
+++ b/graph-ui/src/lib/density.ts
@@ -86,18 +86,22 @@ export interface DisplaySettings {
nodeGlow: number;
/** Bloom intensity multiplier (0–2, default 1). */
bloom: number;
+ /** Hover dwell before wiki help cards appear, ms (150–800, default 350). */
+ tooltipDelayMs: number;
}
export const DEFAULT_DISPLAY_SETTINGS: DisplaySettings = {
edgeBrightness: 1,
nodeGlow: 1,
bloom: 1,
+ tooltipDelayMs: 350,
};
export const DISPLAY_LIMITS = {
edgeBrightness: { min: 0.1, max: 3 },
nodeGlow: { min: 0, max: 2 },
bloom: { min: 0, max: 2 },
+ tooltipDelayMs: { min: 150, max: 800 },
} as const;
const DISPLAY_STORAGE_KEY = "cbm-display";
@@ -116,6 +120,7 @@ export function clampDisplaySettings(
edgeBrightness: clampSetting("edgeBrightness", raw.edgeBrightness),
nodeGlow: clampSetting("nodeGlow", raw.nodeGlow),
bloom: clampSetting("bloom", raw.bloom),
+ tooltipDelayMs: clampSetting("tooltipDelayMs", raw.tooltipDelayMs),
};
}
@@ -132,3 +137,10 @@ export function saveDisplaySettings(settings: DisplaySettings) {
localStorage.setItem(DISPLAY_STORAGE_KEY, JSON.stringify(settings));
} catch { /* ignore */ }
}
+
+/* Read lazily at hover-start (WikiHoverCard arms its dwell timer with this),
+ * so a change in the Display menu applies to the very next hover without any
+ * subscription plumbing between the menu and every chip. */
+export function loadTooltipDelayMs(): number {
+ return loadDisplaySettings().tooltipDelayMs;
+}
diff --git a/graph-ui/src/lib/i18n.ts b/graph-ui/src/lib/i18n.ts
index dab80c0c2..63b8680b9 100644
--- a/graph-ui/src/lib/i18n.ts
+++ b/graph-ui/src/lib/i18n.ts
@@ -78,6 +78,7 @@ export const messages = {
pairedWith: "Paired with",
back: "Back",
close: "Close",
+ clickForMore: "click for more →",
},
control: {
panel: "Control Panel",
@@ -168,6 +169,7 @@ export const messages = {
pairedWith: "配对指标",
back: "返回",
close: "关闭",
+ clickForMore: "点击查看更多 →",
},
control: {
panel: "控制面板",
diff --git a/graph-ui/src/test/setup.ts b/graph-ui/src/test/setup.ts
new file mode 100644
index 000000000..36b99c3c8
--- /dev/null
+++ b/graph-ui/src/test/setup.ts
@@ -0,0 +1,16 @@
+/* Node ≥22 ships an experimental `localStorage` global that reads as
+ * undefined unless --localstorage-file is passed. Vitest's jsdom environment
+ * only overrides globals on its known-keys list, so Node's dead global
+ * shadows jsdom's working Storage — and because the app treats storage as
+ * best-effort (try/catch everywhere), every persistence path silently
+ * no-ops in tests. Restore jsdom's real Storage objects. */
+const g = globalThis as typeof globalThis & { jsdom?: { window: Window } };
+if (g.jsdom && typeof g.localStorage === "undefined") {
+ for (const key of ["localStorage", "sessionStorage"] as const) {
+ Object.defineProperty(globalThis, key, {
+ value: g.jsdom.window[key],
+ configurable: true,
+ writable: true,
+ });
+ }
+}
diff --git a/graph-ui/tsconfig.tsbuildinfo b/graph-ui/tsconfig.tsbuildinfo
index 26070f32e..7a0ebc233 100644
--- a/graph-ui/tsconfig.tsbuildinfo
+++ b/graph-ui/tsconfig.tsbuildinfo
@@ -1 +1 @@
-{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/rpc.ts","./src/components/changestab.tsx","./src/components/commandk.tsx","./src/components/controltab.tsx","./src/components/dashboardtab.tsx","./src/components/displaysettingsmenu.tsx","./src/components/edgelines.tsx","./src/components/errorboundary.tsx","./src/components/filterpanel.tsx","./src/components/flowstab.tsx","./src/components/graphloader.tsx","./src/components/graphscene.test.ts","./src/components/graphscene.tsx","./src/components/graphtab.deadcode.test.tsx","./src/components/graphtab.filters.test.tsx","./src/components/graphtab.regions.test.tsx","./src/components/graphtab.test.ts","./src/components/graphtab.tsx","./src/components/halolayer.tsx","./src/components/metricchip.tsx","./src/components/minimap.tsx","./src/components/missedcallout.tsx","./src/components/modulestab.tsx","./src/components/nodecloud.tsx","./src/components/nodedetailpanel.showmore.test.tsx","./src/components/nodedetailpanel.test.tsx","./src/components/nodedetailpanel.tsx","./src/components/nodelabels.tsx","./src/components/nodetooltip.tsx","./src/components/overviewtab.tsx","./src/components/projectcard.tsx","./src/components/projectswitcher.tsx","./src/components/promptbasket.tsx","./src/components/regionpanel.tsx","./src/components/regiontooltip.tsx","./src/components/resizehandle.tsx","./src/components/sidebar.tsx","./src/components/statstab.test.tsx","./src/components/statstab.tsx","./src/components/symboltab.tsx","./src/components/tabbar.tsx","./src/components/triggertree.tsx","./src/components/wikipanel.test.tsx","./src/components/wikipanel.tsx","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/input.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/separator.tsx","./src/hooks/usegraphdata.test.ts","./src/hooks/usegraphdata.ts","./src/hooks/useprojects.ts","./src/lib/atlas.test.ts","./src/lib/atlas.ts","./src/lib/colors.ts","./src/lib/complexity.test.ts","./src/lib/complexity.ts","./src/lib/composer.ts","./src/lib/density.test.ts","./src/lib/density.ts","./src/lib/findings.test.ts","./src/lib/findings.ts","./src/lib/firstread.ts","./src/lib/flowgroup.test.ts","./src/lib/flowgroup.ts","./src/lib/i18n.test.ts","./src/lib/i18n.ts","./src/lib/regions.test.ts","./src/lib/regions.ts","./src/lib/treemap.ts","./src/lib/types.ts","./src/lib/utils.ts","./src/lib/why.test.ts","./src/lib/why.ts","./src/lib/whyfetch.ts","./src/wiki/entries.test.ts","./src/wiki/entries.ts"],"version":"5.9.3"}
\ No newline at end of file
+{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/rpc.ts","./src/components/changestab.tsx","./src/components/commandk.tsx","./src/components/controltab.tsx","./src/components/dashboardtab.tsx","./src/components/displaysettingsmenu.tsx","./src/components/edgelines.tsx","./src/components/errorboundary.tsx","./src/components/filterpanel.tsx","./src/components/flowstab.tsx","./src/components/graphloader.tsx","./src/components/graphscene.test.ts","./src/components/graphscene.tsx","./src/components/graphtab.deadcode.test.tsx","./src/components/graphtab.filters.test.tsx","./src/components/graphtab.regions.test.tsx","./src/components/graphtab.test.ts","./src/components/graphtab.tsx","./src/components/halolayer.tsx","./src/components/metricchip.tsx","./src/components/minimap.tsx","./src/components/missedcallout.tsx","./src/components/modulestab.tsx","./src/components/nodecloud.tsx","./src/components/nodedetailpanel.showmore.test.tsx","./src/components/nodedetailpanel.test.tsx","./src/components/nodedetailpanel.tsx","./src/components/nodelabels.tsx","./src/components/nodetooltip.tsx","./src/components/overviewtab.tsx","./src/components/projectcard.tsx","./src/components/projectswitcher.tsx","./src/components/promptbasket.tsx","./src/components/regionpanel.tsx","./src/components/regiontooltip.tsx","./src/components/resizehandle.tsx","./src/components/sidebar.tsx","./src/components/statstab.test.tsx","./src/components/statstab.tsx","./src/components/symboltab.tsx","./src/components/tabbar.tsx","./src/components/triggertree.tsx","./src/components/wikihovercard.test.tsx","./src/components/wikihovercard.tsx","./src/components/wikipanel.test.tsx","./src/components/wikipanel.tsx","./src/components/wikitier.ts","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/input.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/separator.tsx","./src/hooks/usegraphdata.test.ts","./src/hooks/usegraphdata.ts","./src/hooks/useprojects.ts","./src/lib/atlas.test.ts","./src/lib/atlas.ts","./src/lib/colors.ts","./src/lib/complexity.test.ts","./src/lib/complexity.ts","./src/lib/composer.ts","./src/lib/density.test.ts","./src/lib/density.ts","./src/lib/findings.test.ts","./src/lib/findings.ts","./src/lib/firstread.ts","./src/lib/flowgroup.test.ts","./src/lib/flowgroup.ts","./src/lib/i18n.test.ts","./src/lib/i18n.ts","./src/lib/regions.test.ts","./src/lib/regions.ts","./src/lib/treemap.ts","./src/lib/types.ts","./src/lib/utils.ts","./src/lib/why.test.ts","./src/lib/why.ts","./src/lib/whyfetch.ts","./src/test/setup.ts","./src/wiki/entries.test.ts","./src/wiki/entries.ts"],"version":"5.9.3"}
\ No newline at end of file
diff --git a/graph-ui/vite.config.ts b/graph-ui/vite.config.ts
index fe59c23c1..66201a0fc 100644
--- a/graph-ui/vite.config.ts
+++ b/graph-ui/vite.config.ts
@@ -35,6 +35,7 @@ export default defineConfig({
test: {
environment: "jsdom",
globals: true,
+ setupFiles: ["./src/test/setup.ts"],
},
build: {
outDir: "dist",