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): semantic zoom, flow-hop confidence, honest caps, tri-state filter

Martin Vogele14624d681ed
diff --git a/graph-ui/src/components/DashboardTab.tsx b/graph-ui/src/components/DashboardTab.tsx
index 554cebd40..380387c23 100644
--- a/graph-ui/src/components/DashboardTab.tsx
+++ b/graph-ui/src/components/DashboardTab.tsx
@@ -116,16 +116,28 @@ function TopList({
title,
entries,
unit,
+ total,
onOpenSymbol,
}: {
title: string;
entries: MetricEntry[];
unit: string;
+ /* Size of the population the list was ranked over — only when the payload
+ * carries a real total; never estimated. Absent → the cap reads "top N". */
+ total?: number;
onOpenSymbol?: (ref: { qn: string }) => void;
}) {
return (
<div className="bg-card border border-border/50 rounded-md p-4">
- <p className="text-[12px] uppercase tracking-widest text-foreground/40 mb-2">{title}</p>
+ <p className="text-[12px] uppercase tracking-widest text-foreground/40 mb-2 flex items-baseline justify-between gap-2">
+ <span className="truncate">{title}</span>
+ {entries.length > 0 && (
+ <span className="text-foreground/30 tabular-nums shrink-0">
+ top {entries.length.toLocaleString("en-US")}
+ {total !== undefined && ` of ${total.toLocaleString("en-US")}`}
+ </span>
+ )}
+ </p>
<div className="space-y-px">
{entries.map((entry, index) => {
const label = entry.name ?? entry.file ?? "?";
@@ -260,6 +272,11 @@ export function DashboardTab({ project, onOpenSymbol, onOpenModulesPath }: Dashb
<h2 className="text-[17px] font-semibold text-foreground/90">
Where the bugs live — churn × complexity
</h2>
+ {metrics.top_churn_complex.length > 0 && (
+ <span className="text-[12px] uppercase tracking-widest text-foreground/35 tabular-nums">
+ top {metrics.top_churn_complex.length.toLocaleString("en-US")}
+ </span>
+ )}
{hero.mutedCount > 0 && (
<button
onClick={() => setShowMuted((value) => !value)}
@@ -380,6 +397,7 @@ export function DashboardTab({ project, onOpenSymbol, onOpenModulesPath }: Dashb
title="Most churned files (1y)"
entries={metrics.top_churn}
unit="commits"
+ total={metrics.churn_total_files}
/>
</div>
@@ -389,18 +407,21 @@ export function DashboardTab({ project, onOpenSymbol, onOpenModulesPath }: Dashb
title="Most complex"
entries={metrics.top_complex}
unit="cyclo"
+ total={totals.callables}
onOpenSymbol={onOpenSymbol}
/>
<TopList
title="Hardest to follow"
entries={metrics.top_cognitive}
unit="cog"
+ total={totals.callables}
onOpenSymbol={onOpenSymbol}
/>
<TopList
title="Longest"
entries={metrics.top_long}
unit="lines"
+ total={totals.callables}
onOpenSymbol={onOpenSymbol}
/>
</div>
diff --git a/graph-ui/src/components/FilterPanel.tsx b/graph-ui/src/components/FilterPanel.tsx
index cb70a95b3..aa1348bad 100644
--- a/graph-ui/src/components/FilterPanel.tsx
+++ b/graph-ui/src/components/FilterPanel.tsx
@@ -101,6 +101,19 @@ export function FilterPanel({
const deadCount = statusCounts.get("dead") ?? 0;
+ /* Tri-state master over everything the panel lists (node types + edge
+ * types — the same global scope enableAll/disableAll always had). */
+ const filterCount = labelCounts.length + edgeTypeCounts.length;
+ let enabledCount = 0;
+ for (const [label] of labelCounts) if (enabledLabels.has(label)) enabledCount++;
+ for (const [type] of edgeTypeCounts) if (enabledEdgeTypes.has(type)) enabledCount++;
+ const master: "all" | "none" | "some" =
+ filterCount > 0 && enabledCount === filterCount
+ ? "all"
+ : enabledCount === 0
+ ? "none"
+ : "some";
+
return (
<div className="flex flex-col shrink-0 max-h-[45%] border-b border-border/40">
{/* Header row — always visible */}
@@ -108,11 +121,25 @@ export function FilterPanel({
<span className="text-[13px] font-medium text-foreground/50 uppercase tracking-widest">
Filters
</span>
- <div className="flex items-center gap-2">
- <button onClick={onEnableAll} className="text-[12px] text-primary/70 hover:text-primary transition-colors">All</button>
- <span className="text-foreground/30">|</span>
- <button onClick={onDisableAll} className="text-[12px] text-primary/70 hover:text-primary transition-colors">None</button>
- </div>
+ <button
+ role="checkbox"
+ aria-checked={master === "all" ? "true" : master === "none" ? "false" : "mixed"}
+ aria-label="All filters"
+ onClick={master === "all" ? onDisableAll : onEnableAll}
+ className={`flex items-center gap-1.5 text-[12px] font-medium transition-all ${
+ master === "none" ? "text-foreground/40" : "text-primary"
+ }`}
+ >
+ <span
+ className={`w-3.5 h-3.5 rounded border flex items-center justify-center transition-all ${
+ master === "none" ? "border-foreground/15" : "border-primary bg-primary/20"
+ }`}
+ >
+ {master === "all" && <span className="text-primary text-[12px]">✓</span>}
+ {master === "some" && <span className="w-2 h-[2px] rounded-full bg-primary" />}
+ </span>
+ All
+ </button>
</div>
{/* Scrollable filter groups */}
diff --git a/graph-ui/src/components/FlowsTab.tsx b/graph-ui/src/components/FlowsTab.tsx
index f79efe5d1..a78eff392 100644
--- a/graph-ui/src/components/FlowsTab.tsx
+++ b/graph-ui/src/components/FlowsTab.tsx
@@ -431,6 +431,14 @@ export function FlowsTab({ project, flowId, onOpenFlow, onOpenSymbol }: FlowsTab
<span className="text-[12px] font-mono text-foreground/70 group-hover:text-primary transition-colors truncate">
{step.name}
</span>
+ {step.confidence !== undefined && step.confidence < 0.75 && (
+ <span
+ className="text-[11px] text-warn/80 shrink-0"
+ title={`resolver confidence ${Math.round(step.confidence * 100)}% — this hop may be misresolved`}
+ >
+ ≈{Math.round(step.confidence * 100)}%
+ </span>
+ )}
{(step.guards ?? []).slice(0, 3).map((guard, gi) => (
<span
key={gi}
diff --git a/graph-ui/src/components/GraphScene.tsx b/graph-ui/src/components/GraphScene.tsx
index 2b89758dc..46eee8005 100644
--- a/graph-ui/src/components/GraphScene.tsx
+++ b/graph-ui/src/components/GraphScene.tsx
@@ -109,6 +109,65 @@ function IdleAutoRotate({
return null;
}
+/* ── Semantic-zoom approach watcher ──────────────────────────
+ * Auto-open fires only when ALL guards pass (the anti-annoyance set from
+ * the Understand-Anything study): (1) the movement is user-driven — a
+ * wheel/pinch happened within the last 600 ms, so programmatic fly-tos
+ * never trigger it; (2) the camera is APPROACHING (distance decreasing);
+ * (3) debounced — the same node fires once, with a 1.5 s global grace
+ * period so backing out doesn't bounce straight back in. */
+
+function ApproachWatcher({
+ nodes,
+ onApproachNode,
+}: {
+ nodes: GraphNode[];
+ onApproachNode: (node: GraphNode) => void;
+}) {
+ const { camera, gl } = useThree();
+ const lastWheel = useRef(0);
+ const lastDist = useRef(Infinity);
+ const lastFiredAt = useRef(0);
+ const lastCheck = useRef(0);
+
+ useEffect(() => {
+ const canvas = gl.domElement;
+ const onWheel = () => {
+ lastWheel.current = performance.now();
+ };
+ canvas.addEventListener("wheel", onWheel, { passive: true });
+ return () => canvas.removeEventListener("wheel", onWheel);
+ }, [gl]);
+
+ useFrame(() => {
+ const now = performance.now();
+ if (now - lastCheck.current < 200) return;
+ lastCheck.current = now;
+ if (now - lastWheel.current > 600) return; /* guard 1: user-driven */
+ if (now - lastFiredAt.current < 1500) return; /* guard 3: grace */
+
+ let nearest: GraphNode | null = null;
+ let nearestDist = Infinity;
+ for (const node of nodes) {
+ const dx = camera.position.x - node.x;
+ const dy = camera.position.y - node.y;
+ const dz = camera.position.z - node.z;
+ const dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
+ if (dist < nearestDist) {
+ nearestDist = dist;
+ nearest = node;
+ }
+ }
+ const approaching = nearestDist < lastDist.current - 0.5; /* guard 2 */
+ lastDist.current = nearestDist;
+ if (!nearest || !approaching) return;
+ if (nearestDist > Math.max(nearest.size * 2.2, 30)) return;
+ lastFiredAt.current = now;
+ onApproachNode(nearest);
+ });
+ return null;
+}
+
/* ── Orbit-target reporter (throttled) ───────────────────── */
function ViewTargetReporter({
@@ -163,6 +222,9 @@ interface GraphSceneProps {
/* Reports the orbit target (throttled) so the 2D minimap can show where
* the camera is looking. */
onViewTarget?: (x: number, y: number) => void;
+ /* Semantic zoom: fired once when the USER zooms close onto a node (the
+ * region scene opens that region). Guards live in ApproachWatcher. */
+ onApproachNode?: (node: GraphNode) => void;
}
export type { CameraTarget };
@@ -180,6 +242,7 @@ export function GraphScene({
renderTooltip,
landmarks = false,
onViewTarget,
+ onApproachNode,
}: GraphSceneProps) {
const [hovered, setHovered] = useState<GraphNode | null>(null);
const controlsRef = useRef<OrbitControlsImpl | null>(null);
@@ -314,6 +377,9 @@ export function GraphScene({
{onViewTarget && (
<ViewTargetReporter controlsRef={controlsRef} onViewTarget={onViewTarget} />
)}
+ {onApproachNode && (
+ <ApproachWatcher nodes={data.nodes} onApproachNode={onApproachNode} />
+ )}
<IdleAutoRotate controlsRef={controlsRef} />
<EffectComposer multisampling={GRAPH_COMPOSER_MULTISAMPLING}>
diff --git a/graph-ui/src/components/GraphTab.filters.test.tsx b/graph-ui/src/components/GraphTab.filters.test.tsx
index bba467595..c1ab5a167 100644
--- a/graph-ui/src/components/GraphTab.filters.test.tsx
+++ b/graph-ui/src/components/GraphTab.filters.test.tsx
@@ -62,8 +62,11 @@ describe("GraphTab filters", () => {
/* Wait for the layout to load — the filter panel header appears. */
expect(await screen.findByText("Filters")).toBeInTheDocument();
- /* Disable every filter via the "None" shortcut. */
- fireEvent.click(screen.getByRole("button", { name: "None" }));
+ /* Everything starts enabled — the tri-state master reads checked.
+ One click cycles all-on → all-off. */
+ const master = screen.getByRole("checkbox", { name: "All filters" });
+ expect(master).toHaveAttribute("aria-checked", "true");
+ fireEvent.click(master);
/* The graph area reports that everything is filtered out… */
expect(screen.getByText("All nodes filtered out")).toBeInTheDocument();
@@ -71,7 +74,9 @@ describe("GraphTab filters", () => {
/* …but the filter sidebar must stay so the user can re-enable filters
instead of being forced to reset everything. */
expect(screen.getByText("Filters")).toBeInTheDocument();
- expect(screen.getByRole("button", { name: "All" })).toBeInTheDocument();
- expect(screen.getByRole("button", { name: "None" })).toBeInTheDocument();
+ expect(screen.getByRole("checkbox", { name: "All filters" })).toHaveAttribute(
+ "aria-checked",
+ "false",
+ );
});
});
diff --git a/graph-ui/src/components/GraphTab.tsx b/graph-ui/src/components/GraphTab.tsx
index 2bdde10aa..75d19aa22 100644
--- a/graph-ui/src/components/GraphTab.tsx
+++ b/graph-ui/src/components/GraphTab.tsx
@@ -680,6 +680,10 @@ export function GraphTab({
);
}}
onViewTarget={(x, y) => setViewTarget({ x, y })}
+ onApproachNode={(node) => {
+ const region = displayRegions.find((r) => r.id === node.id);
+ if (region) openRegion(region);
+ }}
/>
</ErrorBoundary>
@@ -705,7 +709,7 @@ export function GraphTab({
{regionsPayload?.total_nodes.toLocaleString("en-US")} nodes
</p>
<p className="text-foreground/35 mt-0.5">
- double-click a region (or use its panel) to open it
+ double-click a region — or just zoom into it — to open it
</p>
</div>
diff --git a/graph-ui/src/lib/atlas.ts b/graph-ui/src/lib/atlas.ts
index 84b90ae18..38c0102c0 100644
--- a/graph-ui/src/lib/atlas.ts
+++ b/graph-ui/src/lib/atlas.ts
@@ -142,6 +142,8 @@ export interface FlowStep {
depth: number;
parent: number;
guards?: { kind: string; cond?: string; negated?: boolean }[];
+ /* Resolver confidence of the edge from the parent step (0..1). */
+ confidence?: number;
}
export interface FlowDetail {
diff --git a/src/ui/atlas_flows.c b/src/ui/atlas_flows.c
index 37eb446d7..6364065ca 100644
--- a/src/ui/atlas_flows.c
+++ b/src/ui/atlas_flows.c
@@ -653,6 +653,16 @@ char *cbm_atlas_flow_json(cbm_store_t *store, const char *project, int flow_id)
yyjson_mut_obj_add_bool(doc, root, "cross_region", flow->cross_region);
if (flow->steps_capped > 0)
yyjson_mut_obj_add_int(doc, root, "steps_capped", flow->steps_capped);
+ /* Per-step resolver confidence: the CALLS edge from the parent step.
+ * A low value marks steps the resolver was unsure about (e.g. a short
+ * name matched across languages) — shown, never hidden. */
+ struct sqlite3 *conf_db = cbm_store_get_db(store);
+ sqlite3_stmt *conf_st = NULL;
+ if (conf_db)
+ sqlite3_prepare_v2(conf_db,
+ "SELECT properties FROM edges WHERE project=?1 AND source_id=?2 "
+ "AND target_id=?3 AND type='CALLS' LIMIT 1",
+ -1, &conf_st, NULL);
yyjson_mut_val *steps = yyjson_mut_arr(doc);
for (int s = 0; s < flow->step_count; s++) {
const flow_node_t *node = &g_flow_cache.nodes[flow->steps[s]];
@@ -663,8 +673,28 @@ char *cbm_atlas_flow_json(cbm_store_t *store, const char *project, int flow_id)
yyjson_mut_obj_add_strcpy(doc, obj, "file_path", node->file_path);
yyjson_mut_obj_add_int(doc, obj, "depth", flow->depth[s]);
yyjson_mut_obj_add_int(doc, obj, "parent", flow->parent[s]);
+ if (conf_st && flow->parent[s] >= 0) {
+ sqlite3_reset(conf_st);
+ sqlite3_bind_text(conf_st, 1, project, -1, SQLITE_STATIC);
+ sqlite3_bind_int64(conf_st, 2, g_flow_cache.nodes[flow->steps[flow->parent[s]]].id);
+ sqlite3_bind_int64(conf_st, 3, node->id);
+ if (sqlite3_step(conf_st) == SQLITE_ROW) {
+ const char *props = (const char *)sqlite3_column_text(conf_st, 0);
+ if (props) {
+ yyjson_doc *pd = yyjson_read(props, strlen(props), 0);
+ if (pd) {
+ yyjson_val *cv = yyjson_obj_get(yyjson_doc_get_root(pd), "confidence");
+ if (cv)
+ yyjson_mut_obj_add_real(doc, obj, "confidence", yyjson_get_num(cv));
+ yyjson_doc_free(pd);
+ }
+ }
+ }
+ }
yyjson_mut_arr_append(steps, obj);
}
+ if (conf_st)
+ sqlite3_finalize(conf_st);
yyjson_mut_obj_add_val(doc, root, "steps", steps);
pthread_mutex_unlock(&g_flow_mu);
char *json = yyjson_mut_write(doc, 0, NULL);