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(core): keep componentSet nodes through validateGraph sanitize lowercasing

gruming07473deb2398
diff --git a/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts b/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts
index 4cab6344..bb19279c 100644
--- a/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts
+++ b/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts
@@ -768,4 +768,16 @@ describe("design graph schema", () => {
const res = validateGraph(g);
expect(res.data!.nodes.find((n) => n.id === "screen:1:2")!.type).toBe("screen");
});
+
+ it("keeps componentSet (the only camelCase node type) through sanitize lowercasing", () => {
+ const g = designGraph();
+ g.nodes.push({ id: "componentSet:7:8", type: "componentSet", name: "Button", summary: "s", tags: ["ds"], complexity: "simple" });
+ g.edges.push({ source: "component:3:4", target: "componentSet:7:8", type: "variant_of", direction: "forward", weight: 0.9 });
+ const res = validateGraph(g);
+ const set = res.data!.nodes.find((n) => n.id === "componentSet:7:8");
+ expect(set).toBeTruthy();
+ expect(set!.type).toBe("componentSet");
+ // the variant_of edge must survive (its target was not dropped)
+ expect(res.data!.edges.some((e) => e.target === "componentSet:7:8" && e.type === "variant_of")).toBe(true);
+ });
});
diff --git a/understand-anything-plugin/packages/core/src/schema.ts b/understand-anything-plugin/packages/core/src/schema.ts
index a9f9fc63..90c2f48d 100644
--- a/understand-anything-plugin/packages/core/src/schema.ts
+++ b/understand-anything-plugin/packages/core/src/schema.ts
@@ -81,6 +81,10 @@ export const NODE_TYPE_ALIASES: Record<string, string> = {
main_component: "component",
component_set: "componentSet",
variant_set: "componentSet",
+ // sanitizeGraph lowercases every node type, and "componentSet" is the only
+ // camelCase canonical NodeType — so it arrives here as "componentset" and
+ // must be mapped back, otherwise it fails the enum check and gets dropped.
+ componentset: "componentSet",
design_token: "token",
style: "token",
};