Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

fix(dashboard): register design edge types in the edge-category filter

Lum1104251f5f1c3d82
diff --git a/understand-anything-plugin/packages/dashboard/src/__tests__/edgeCategories.test.ts b/understand-anything-plugin/packages/dashboard/src/__tests__/edgeCategories.test.ts
new file mode 100644
index 00000000..eea6ef6a
--- /dev/null
+++ b/understand-anything-plugin/packages/dashboard/src/__tests__/edgeCategories.test.ts
@@ -0,0 +1,62 @@
+import { describe, it, expect } from "vitest";
+import { EDGE_CATEGORY_MAP, ALL_EDGE_CATEGORIES } from "../store";
+import type { EdgeType as CoreEdgeType } from "@understand-anything/core/types";
+
+/**
+ * Guard for the edge-category FILTER path — the edge analog of
+ * allNodeTypes.test.ts.
+ *
+ * filterEdges() keeps edges whose type maps to no category, so a missing
+ * entry doesn't drop edges — but it does make them invisible to the
+ * FilterPanel edge-category toggles (which is exactly what happened to the
+ * design edges instance_of/variant_of/uses_token before this fix).
+ *
+ * EXPECTED_EDGE_TYPES is compile-time exhaustive over the core EdgeType union
+ * via `satisfies Record<CoreEdgeType, true>`: add an EdgeType to core and the
+ * dashboard build fails until it is listed here, then the runtime checks fail
+ * until it is also placed in EDGE_CATEGORY_MAP.
+ */
+const EXPECTED_EDGE_TYPES = {
+ // structural (5)
+ imports: true, exports: true, contains: true, inherits: true, implements: true,
+ // behavioral (4)
+ calls: true, subscribes: true, publishes: true, middleware: true,
+ // data-flow (4)
+ reads_from: true, writes_to: true, transforms: true, validates: true,
+ // dependencies (3)
+ depends_on: true, tested_by: true, configures: true,
+ // semantic (2)
+ related: true, similar_to: true,
+ // infrastructure (8)
+ deploys: true, serves: true, provisions: true, triggers: true,
+ migrates: true, documents: true, routes: true, defines_schema: true,
+ // domain (3)
+ contains_flow: true, flow_step: true, cross_domain: true,
+ // knowledge (6)
+ cites: true, contradicts: true, builds_on: true, exemplifies: true,
+ categorized_under: true, authored_by: true,
+ // design (3) — Figma edges must be reachable from the edge-category filter
+ instance_of: true, variant_of: true, uses_token: true,
+} satisfies Record<CoreEdgeType, true>;
+
+describe("EDGE_CATEGORY_MAP (edge-category filter)", () => {
+ const mapped = Object.values(EDGE_CATEGORY_MAP).flat();
+
+ it("covers every core EdgeType (regression guard)", () => {
+ for (const t of Object.keys(EXPECTED_EDGE_TYPES)) {
+ expect(mapped).toContain(t);
+ }
+ });
+
+ it("maps each edge type to exactly one category", () => {
+ expect(new Set(mapped).size).toBe(mapped.length);
+ expect(mapped.length).toBe(Object.keys(EXPECTED_EDGE_TYPES).length);
+ });
+
+ it("lists every map key in ALL_EDGE_CATEGORIES so the FilterPanel renders it", () => {
+ for (const category of Object.keys(EDGE_CATEGORY_MAP)) {
+ expect(ALL_EDGE_CATEGORIES).toContain(category);
+ }
+ expect(ALL_EDGE_CATEGORIES.length).toBe(Object.keys(EDGE_CATEGORY_MAP).length);
+ });
+});
diff --git a/understand-anything-plugin/packages/dashboard/src/store.ts b/understand-anything-plugin/packages/dashboard/src/store.ts
index 8f78ca70..884f428e 100644
--- a/understand-anything-plugin/packages/dashboard/src/store.ts
+++ b/understand-anything-plugin/packages/dashboard/src/store.ts
@@ -13,7 +13,7 @@ export type Persona = "non-technical" | "junior" | "experienced";
export type NavigationLevel = "overview" | "layer-detail";
export type NodeType = "file" | "function" | "class" | "module" | "concept" | "config" | "document" | "service" | "table" | "endpoint" | "pipeline" | "schema" | "resource" | "domain" | "flow" | "step" | "article" | "entity" | "topic" | "claim" | "source" | "page" | "screen" | "component" | "componentSet" | "instance" | "token";
export type Complexity = "simple" | "moderate" | "complex";
-export type EdgeCategory = "structural" | "behavioral" | "data-flow" | "dependencies" | "semantic" | "infrastructure" | "domain" | "knowledge";
+export type EdgeCategory = "structural" | "behavioral" | "data-flow" | "dependencies" | "semantic" | "infrastructure" | "domain" | "knowledge" | "design";
export type ViewMode = "structural" | "domain" | "knowledge";
export type DetailLevel = "file" | "class";
@@ -26,7 +26,7 @@ export interface FilterState {
export const ALL_NODE_TYPES: NodeType[] = ["file", "function", "class", "module", "concept", "config", "document", "service", "table", "endpoint", "pipeline", "schema", "resource", "domain", "flow", "step", "article", "entity", "topic", "claim", "source", "page", "screen", "component", "componentSet", "instance", "token"];
export const ALL_COMPLEXITIES: Complexity[] = ["simple", "moderate", "complex"];
-export const ALL_EDGE_CATEGORIES: EdgeCategory[] = ["structural", "behavioral", "data-flow", "dependencies", "semantic", "infrastructure", "domain", "knowledge"];
+export const ALL_EDGE_CATEGORIES: EdgeCategory[] = ["structural", "behavioral", "data-flow", "dependencies", "semantic", "infrastructure", "domain", "knowledge", "design"];
export const EDGE_CATEGORY_MAP: Record<EdgeCategory, string[]> = {
structural: ["imports", "exports", "contains", "inherits", "implements"],
@@ -37,6 +37,7 @@ export const EDGE_CATEGORY_MAP: Record<EdgeCategory, string[]> = {
infrastructure: ["deploys", "serves", "provisions", "triggers", "migrates", "documents", "routes", "defines_schema"],
domain: ["contains_flow", "flow_step", "cross_domain"],
knowledge: ["cites", "contradicts", "builds_on", "exemplifies", "categorized_under", "authored_by"],
+ design: ["instance_of", "variant_of", "uses_token"],
};
export const DOMAIN_EDGE_TYPES = EDGE_CATEGORY_MAP.domain;