diff --git a/understand-anything-plugin/packages/dashboard/src/components/NodeInfo.tsx b/understand-anything-plugin/packages/dashboard/src/components/NodeInfo.tsx index a06bf08..0f332a2 100644 --- a/understand-anything-plugin/packages/dashboard/src/components/NodeInfo.tsx +++ b/understand-anything-plugin/packages/dashboard/src/components/NodeInfo.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; import { useDashboardStore } from "../store"; -import type { NodeType, EdgeType } from "@understand-anything/core/types"; +import type { NodeType, EdgeType, KnowledgeGraph, GraphNode } from "@understand-anything/core/types"; // Badge color classes keyed by NodeType — must be kept in sync with core NodeType union. const typeBadgeColors: Record = { @@ -78,6 +78,127 @@ function getDirectionalLabel(edgeType: string, isSource: boolean): string { return isSource ? labels.forward : labels.backward; } +function DomainNodeDetails({ node, graph }: { node: GraphNode; graph: KnowledgeGraph }) { + const navigateToDomain = useDashboardStore((s) => s.navigateToDomain); + const selectNode = useDashboardStore((s) => s.selectNode); + const meta = (node as any).domainMeta as Record | undefined; + + if (node.type === "domain") { + const flows = graph.edges + .filter((e) => e.type === "contains_flow" && e.source === node.id) + .map((e) => graph.nodes.find((n) => n.id === e.target)) + .filter(Boolean); + + return ( +
+ {meta?.entities && (meta.entities as string[]).length > 0 ? ( +
+

Entities

+
+ {(meta.entities as string[]).map((e) => ( + {e} + ))} +
+
+ ) : null} + {meta?.businessRules && (meta.businessRules as string[]).length > 0 ? ( +
+

Business Rules

+
    + {(meta.businessRules as string[]).map((r, i) => ( +
  • -{r}
  • + ))} +
+
+ ) : null} + {meta?.crossDomainInteractions && (meta.crossDomainInteractions as string[]).length > 0 ? ( +
+

Cross-Domain

+
    + {(meta.crossDomainInteractions as string[]).map((c, i) => ( +
  • {c}
  • + ))} +
+
+ ) : null} + {flows.length > 0 && ( +
+

Flows

+
+ {flows.map((f) => ( + + ))} +
+
+ )} +
+ ); + } + + if (node.type === "flow") { + const steps = graph.edges + .filter((e) => e.type === "flow_step" && e.source === node.id) + .sort((a, b) => a.weight - b.weight) + .map((e) => graph.nodes.find((n) => n.id === e.target)) + .filter(Boolean); + + return ( +
+ {meta?.entryPoint ? ( +
+

Entry Point

+
{meta.entryPoint as string}
+
+ ) : null} + {steps.length > 0 && ( +
+

Steps

+
    + {steps.map((s, i) => ( +
  1. + +
  2. + ))} +
+
+ )} +
+ ); + } + + if (node.type === "step") { + return ( +
+ {node.filePath && ( +
+

Implementation

+
+ {node.filePath} + {node.lineRange && :{node.lineRange[0]}-{node.lineRange[1]}} +
+
+ )} +
+ ); + } + + return null; +} + export default function NodeInfo() { const graph = useDashboardStore((s) => s.graph); const selectedNodeId = useDashboardStore((s) => s.selectedNodeId); @@ -89,7 +210,11 @@ export default function NodeInfo() { const navigateToHistoryIndex = useDashboardStore((s) => s.navigateToHistoryIndex); const setFocusNode = useDashboardStore((s) => s.setFocusNode); const focusNodeId = useDashboardStore((s) => s.focusNodeId); - const node = graph?.nodes.find((n) => n.id === selectedNodeId) ?? null; + const viewMode = useDashboardStore((s) => s.viewMode); + const domainGraph = useDashboardStore((s) => s.domainGraph); + + const activeGraph = viewMode === "domain" && domainGraph ? domainGraph : graph; + const node = activeGraph?.nodes.find((n) => n.id === selectedNodeId) ?? null; // Resolve history node names for the breadcrumb trail const historyNodes = nodeHistory.map((id) => { @@ -105,7 +230,7 @@ export default function NodeInfo() { ); } - const allEdges = graph?.edges ?? []; + const allEdges = activeGraph?.edges ?? []; const connections = allEdges.filter( (e) => e.source === node.id || e.target === node.id, ); @@ -256,6 +381,11 @@ export default function NodeInfo() { )} + {/* Domain-specific details */} + {activeGraph && node && (node.type === "domain" || node.type === "flow" || node.type === "step") && ( + + )} + {/* Child classes/functions within this file */} {childNodes.length > 0 && (
@@ -304,7 +434,7 @@ export default function NodeInfo() { {otherConnections.map((edge, i) => { const isSource = edge.source === node.id; const otherId = isSource ? edge.target : edge.source; - const otherNode = graph?.nodes.find((n) => n.id === otherId); + const otherNode = activeGraph?.nodes.find((n) => n.id === otherId); const dirLabel = getDirectionalLabel(edge.type, isSource); const arrow = isSource ? "\u2192" : "\u2190";