From d52dd933ee60d045f784d041dd449750e66b51dc Mon Sep 17 00:00:00 2001 From: Lum1104 Date: Thu, 2 Apr 2026 23:56:34 +0800 Subject: [PATCH] fix(dashboard): show function/class nodes in layer detail view Function and class nodes were invisible in the graph because they are not directly assigned to layers (only file-level nodes are). Expand layer membership by following `contains` edges from file nodes in the active layer to include their child function/class nodes. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../dashboard/src/components/GraphView.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/understand-anything-plugin/packages/dashboard/src/components/GraphView.tsx b/understand-anything-plugin/packages/dashboard/src/components/GraphView.tsx index 925ea87..3d86de6 100644 --- a/understand-anything-plugin/packages/dashboard/src/components/GraphView.tsx +++ b/understand-anything-plugin/packages/dashboard/src/components/GraphView.tsx @@ -234,6 +234,16 @@ function useLayerDetailTopology() { const layerNodeIds = new Set(activeLayer.nodeIds); + // Expand layer membership to include sub-file nodes (function/class) whose + // parent file is in this layer. These nodes aren't in layer.nodeIds directly + // but belong to the layer via their "contains" edge from a file node. + const expandedLayerNodeIds = new Set(layerNodeIds); + for (const edge of graph.edges) { + if (edge.type === "contains" && layerNodeIds.has(edge.source)) { + expandedLayerNodeIds.add(edge.target); + } + } + // All top-level (file-level) node types that should appear in the graph. // This includes the 8 new non-code types plus the original "file" type. const fileLevelTypes = new Set([ @@ -246,9 +256,9 @@ function useLayerDetailTopology() { // Junior/experienced persona: show everything including function/class let filteredGraphNodes = persona === "non-technical" ? graph.nodes.filter( - (n) => layerNodeIds.has(n.id) && (n.type === "concept" || n.type === "module" || fileLevelTypes.has(n.type)), + (n) => expandedLayerNodeIds.has(n.id) && (n.type === "concept" || n.type === "module" || fileLevelTypes.has(n.type)), ) - : graph.nodes.filter((n) => layerNodeIds.has(n.id) && (fileLevelTypes.has(n.type) || n.type === "module" || n.type === "concept" || n.type === "function" || n.type === "class")); + : graph.nodes.filter((n) => expandedLayerNodeIds.has(n.id) && (fileLevelTypes.has(n.type) || n.type === "module" || n.type === "concept" || n.type === "function" || n.type === "class")); // Apply node type category filters filteredGraphNodes = filteredGraphNodes.filter((n) => {