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.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
Merge main into feat/dashboard-export-filtering
Lum11044d92381da191
diff --cc understand-anything-plugin/packages/dashboard/src/App.tsxindex 4f541f89,c32e098f..a17dbf5d--- a/understand-anything-plugin/packages/dashboard/src/App.tsx+++ b/understand-anything-plugin/packages/dashboard/src/App.tsx@@@ -26,10 -72,21 +75,23 @@@ function Dashboard({ accessToken }: { aconst codeViewerOpen = useDashboardStore((s) => s.codeViewerOpen);const closeCodeViewer = useDashboardStore((s) => s.closeCodeViewer);const setDiffOverlay = useDashboardStore((s) => s.setDiffOverlay);+ const pathFinderOpen = useDashboardStore((s) => s.pathFinderOpen);+ const togglePathFinder = useDashboardStore((s) => s.togglePathFinder);+ const nodeTypeFilters = useDashboardStore((s) => s.nodeTypeFilters);+ const toggleNodeTypeFilter = useDashboardStore((s) => s.toggleNodeTypeFilter);const [loadError, setLoadError] = useState<string | null>(null);+ const [graphIssues, setGraphIssues] = useState<GraphIssue[]>([]);const [showKeyboardHelp, setShowKeyboardHelp] = useState(false);+ const [metaTheme, setMetaTheme] = useState<ThemeConfig | null>(null);++ useEffect(() => {+ fetch(tokenUrl("/meta.json", accessToken))+ .then((r) => (r.ok ? r.json() : null))+ .then((meta) => {+ if (meta?.theme) setMetaTheme(meta.theme);+ })+ .catch(() => {});+ }, []);// Define keyboard shortcutsconst shortcuts = useMemo<KeyboardShortcut[]>(@@@ -45,7 -102,7 +107,7 @@@// Navigation{key: "Escape",- description: "Close panels and modals",- description: "Close panels / go back to overview",++ description: "Close panels and modals / go back to overview",action: () => {// Read from store at invocation time to avoid stale closuresconst state = useDashboardStore.getState();@@@ -222,32 -252,40 +290,62 @@@</div><div className="flex items-center gap-4"><DiffToggle />+ <div className="flex items-center gap-1">+ {([+ { key: "code", label: "Code", color: "var(--color-node-file)" },+ { key: "config", label: "Config", color: "var(--color-node-config)" },+ { key: "docs", label: "Docs", color: "var(--color-node-document)" },+ { key: "infra", label: "Infra", color: "var(--color-node-service)" },+ { key: "data", label: "Data", color: "var(--color-node-table)" },+ ] as const).map((cat) => (+ <button+ key={cat.key}+ onClick={() => toggleNodeTypeFilter(cat.key)}+ className={`text-[10px] font-semibold uppercase tracking-wider px-2 py-1 rounded border transition-colors flex items-center gap-1.5 ${+ nodeTypeFilters[cat.key] !== false+ ? "border-border-medium bg-elevated text-text-secondary hover:text-text-primary"+ : "border-transparent bg-transparent text-text-muted/40 line-through hover:text-text-muted"+ }`}+ title={`${nodeTypeFilters[cat.key] !== false ? "Hide" : "Show"} ${cat.label} nodes`}+ >+ <span+ className="w-2 h-2 rounded-full shrink-0"+ style={{+ backgroundColor: cat.color,+ opacity: nodeTypeFilters[cat.key] !== false ? 1 : 0.3,+ }}+ />+ {cat.label}+ </button>+ ))}+ </div><LayerLegend />+ <FilterPanel />+ <ExportMenu />+ <button+ onClick={togglePathFinder}+ className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm bg-elevated text-text-secondary hover:text-text-primary transition-colors"+ title="Find path between nodes (P)"+ >+ <svg+ className="w-4 h-4"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ >+ <path+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth={2}+ d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"+ />+ </svg>+ Path+ </button>+ <ThemePicker /><buttononClick={() => setShowKeyboardHelp(true)}- className="text-text-muted hover:text-gold transition-colors"+ className="text-text-muted hover:text-accent transition-colors"title="Keyboard shortcuts (Shift + ?)"><svg@@@ -319,13 -362,8 +422,14 @@@onClose={() => setShowKeyboardHelp(false)}/>)}++ {/* Path Finder Modal */}+ <PathFinderModal+ isOpen={pathFinderOpen}+ onClose={togglePathFinder}+ /></div>+ </ThemeProvider>);}diff --cc understand-anything-plugin/packages/dashboard/src/components/CustomNode.tsxindex 14b1a83f,f8de4083..1cae9706--- a/understand-anything-plugin/packages/dashboard/src/components/CustomNode.tsx+++ b/understand-anything-plugin/packages/dashboard/src/components/CustomNode.tsx@@@ -36,10 -54,9 +54,12 @@@ export interface CustomNodeData extendisDiffChanged: boolean;isDiffAffected: boolean;isDiffFaded: boolean;+ isNeighbor: boolean;+ isSelectionFaded: boolean;onNodeClick?: (nodeId: string) => void;+ incomingCount?: number;+ outgoingCount?: number;+ tags?: string[];}export type CustomFlowNode = Node<CustomNodeData, "custom">;diff --cc understand-anything-plugin/packages/dashboard/src/components/ExportMenu.tsxindex adc7ce00,00000000..4b15fdd6mode 100644,000000..100644--- a/understand-anything-plugin/packages/dashboard/src/components/ExportMenu.tsx+++ b/understand-anything-plugin/packages/dashboard/src/components/ExportMenu.tsx@@@ -1,302 -1,0 +1,315 @@@+import { useEffect, useRef } from "react";+import { useDashboardStore } from "../store";+import type { KnowledgeGraph } from "@understand-anything/core/types";+import { filterNodes, filterEdges } from "../utils/filters";+++function escapeXml(s: string): string {++ return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);++}+++function downloadBlob(blob: Blob, filename: string) {+ const url = URL.createObjectURL(blob);+ const a = document.createElement("a");+ a.href = url;+ a.download = filename;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ URL.revokeObjectURL(url);+}++export default function ExportMenu() {+ const graph = useDashboardStore((s) => s.graph);+ const filters = useDashboardStore((s) => s.filters);+ const exportMenuOpen = useDashboardStore((s) => s.exportMenuOpen);+ const toggleExportMenu = useDashboardStore((s) => s.toggleExportMenu);+ const reactFlowInstance = useDashboardStore((s) => s.reactFlowInstance);+ const persona = useDashboardStore((s) => s.persona);++ const containerRef = useRef<HTMLDivElement>(null);++ // Close dropdown on outside click+ useEffect(() => {+ const handleClickOutside = (e: MouseEvent) => {+ if (containerRef.current && !containerRef.current.contains(e.target as Node)) {+ if (exportMenuOpen) {+ toggleExportMenu();+ }+ }+ };+ document.addEventListener("mousedown", handleClickOutside);+ return () => document.removeEventListener("mousedown", handleClickOutside);+ }, [exportMenuOpen, toggleExportMenu]);++ const exportPNG = async () => {+ if (!reactFlowInstance) {+ alert("Graph not ready for export");+ return;+ }++ try {+ // Get the viewport element+ const viewport = document.querySelector(".react-flow__viewport") as HTMLElement;+ if (!viewport) {+ throw new Error("Viewport not found");+ }++ // Get the bounding box of all nodes+ const nodes = reactFlowInstance.getNodes();+ if (nodes.length === 0) {+ alert("No nodes to export");+ return;+ }++ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;+ nodes.forEach((node) => {+ const x = node.position.x;+ const y = node.position.y;+ const width = (node.width ?? 200);+ const height = (node.height ?? 80);+ minX = Math.min(minX, x);+ minY = Math.min(minY, y);+ maxX = Math.max(maxX, x + width);+ maxY = Math.max(maxY, y + height);+ });++ const padding = 40;+ const width = maxX - minX + padding * 2;+ const height = maxY - minY + padding * 2;++ // Clone the viewport+ const clone = viewport.cloneNode(true) as HTMLElement;+ clone.style.transform = `translate(${-minX + padding}px, ${-minY + padding}px)`;++ // Create an SVG with foreignObject+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");+ svg.setAttribute("width", String(width * 2));+ svg.setAttribute("height", String(height * 2));+ svg.setAttribute("viewBox", `0 0 ${width} ${height}`);+ svg.style.backgroundColor = "#0a0a0a";++ const foreignObject = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");+ foreignObject.setAttribute("width", "100%");+ foreignObject.setAttribute("height", "100%");+ foreignObject.appendChild(clone);+ svg.appendChild(foreignObject);++ // Serialize SVG to string+ const svgString = new XMLSerializer().serializeToString(svg);+ const svgBlob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" });+ const url = URL.createObjectURL(svgBlob);++ // Create an image and draw to canvas+ const img = new Image();++ img.onerror = () => {++ URL.revokeObjectURL(url);++ console.error("PNG export failed: Image failed to load from SVG blob");++ alert("Failed to export PNG: could not render graph as image. Try SVG export instead.");++ };+ img.onload = () => {+ const canvas = document.createElement("canvas");+ canvas.width = width * 2;+ canvas.height = height * 2;+ const ctx = canvas.getContext("2d");+ if (!ctx) {++ URL.revokeObjectURL(url);+ alert("Failed to create canvas context");+ return;+ }+ ctx.drawImage(img, 0, 0);+ URL.revokeObjectURL(url);+++ const filename = `${graph?.project.name ?? "knowledge-graph"}-export.png`;+ canvas.toBlob((blob) => {+ if (blob) {- const filename = `${graph?.project.name ?? "knowledge-graph"}-export.png`;+ downloadBlob(blob, filename);+ toggleExportMenu();++ } else {++ console.error("PNG export failed: canvas.toBlob returned null (canvas may be tainted)");++ alert("Failed to export PNG: image encoding failed. Try SVG export instead.");+ }+ }, "image/png");+ };+ img.src = url;+ } catch (error) {+ console.error("PNG export failed:", error);+ alert(`Failed to export PNG: ${error instanceof Error ? error.message : String(error)}`);+ }+ };++ const exportSVG = () => {+ if (!reactFlowInstance) {+ alert("Graph not ready for export");+ return;+ }++ try {+ const nodes = reactFlowInstance.getNodes();+ const edges = reactFlowInstance.getEdges();++ if (nodes.length === 0) {+ alert("No nodes to export");+ return;+ }++ // Calculate bounding box+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;+ nodes.forEach((node) => {+ const x = node.position.x;+ const y = node.position.y;+ const width = (node.width ?? 200);+ const height = (node.height ?? 80);+ minX = Math.min(minX, x);+ minY = Math.min(minY, y);+ maxX = Math.max(maxX, x + width);+ maxY = Math.max(maxY, y + height);+ });++ const padding = 40;+ const width = maxX - minX + padding * 2;+ const height = maxY - minY + padding * 2;+ const offsetX = -minX + padding;+ const offsetY = -minY + padding;++ // Build SVG manually+ let svgContent = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">`;+ svgContent += `<rect width="100%" height="100%" fill="#0a0a0a"/>`;++ // Draw edges+ edges.forEach((edge) => {+ const sourceNode = nodes.find((n) => n.id === edge.source);+ const targetNode = nodes.find((n) => n.id === edge.target);+ if (!sourceNode || !targetNode) return;++ const sx = sourceNode.position.x + (sourceNode.width ?? 200) / 2 + offsetX;+ const sy = sourceNode.position.y + (sourceNode.height ?? 80) / 2 + offsetY;+ const tx = targetNode.position.x + (targetNode.width ?? 200) / 2 + offsetX;+ const ty = targetNode.position.y + (targetNode.height ?? 80) / 2 + offsetY;++ svgContent += `<line x1="${sx}" y1="${sy}" x2="${tx}" y2="${ty}" stroke="rgba(212,165,116,0.3)" stroke-width="1.5"/>`;+ });++ // Draw nodes+ nodes.forEach((node) => {+ if (node.type === "group") return; // Skip group nodes++ const x = node.position.x + offsetX;+ const y = node.position.y + offsetY;+ const w = node.width ?? 200;+ const h = node.height ?? 80;++ svgContent += `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="8" fill="#1a1a1a" stroke="rgba(212,165,116,0.2)" stroke-width="1"/>`;- svgContent += `<text x="${x + w / 2}" y="${y + h / 2}" fill="#d4a574" text-anchor="middle" dominant-baseline="middle" font-size="12">${node.data.label ?? node.id}</text>`;++ svgContent += `<text x="${x + w / 2}" y="${y + h / 2}" fill="#d4a574" text-anchor="middle" dominant-baseline="middle" font-size="12">${escapeXml(String(node.data.label ?? node.id))}</text>`;+ });++ svgContent += `</svg>`;++ const blob = new Blob([svgContent], { type: "image/svg+xml;charset=utf-8" });+ const filename = `${graph?.project.name ?? "knowledge-graph"}-export.svg`;+ downloadBlob(blob, filename);+ toggleExportMenu();+ } catch (error) {+ console.error("SVG export failed:", error);+ alert(`Failed to export SVG: ${error instanceof Error ? error.message : String(error)}`);+ }+ };++ const exportJSON = () => {+ if (!graph) {+ alert("No graph loaded");+ return;+ }++ try {+ // Apply persona and filters to create filtered graph+ let filteredGraphNodes = persona === "non-technical"+ ? graph.nodes.filter((n) => n.type === "concept" || n.type === "module" || n.type === "file")+ : graph.nodes;++ filteredGraphNodes = filterNodes(filteredGraphNodes, graph.layers ?? [], filters);+ const filteredNodeIds = new Set(filteredGraphNodes.map((n) => n.id));++ let filteredGraphEdges = graph.edges.filter(+ (e) => filteredNodeIds.has(e.source) && filteredNodeIds.has(e.target)+ );+ filteredGraphEdges = filterEdges(filteredGraphEdges, filteredNodeIds, filters);++ const filteredGraph: KnowledgeGraph = {+ ...graph,+ nodes: filteredGraphNodes,+ edges: filteredGraphEdges,+ };++ const json = JSON.stringify(filteredGraph, null, 2);+ const blob = new Blob([json], { type: "application/json" });+ const filename = `${graph.project.name ?? "knowledge-graph"}-export.json`;+ downloadBlob(blob, filename);+ toggleExportMenu();+ } catch (error) {+ console.error("JSON export failed:", error);+ alert(`Failed to export JSON: ${error instanceof Error ? error.message : String(error)}`);+ }+ };++ return (+ <div ref={containerRef} className="relative">+ <button+ onClick={toggleExportMenu}+ className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm bg-elevated text-text-secondary hover:text-text-primary transition-colors"+ title="Export graph (E)"+ >+ <svg+ className="w-4 h-4"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ >+ <path+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth={2}+ d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"+ />+ </svg>+ Export+ </button>++ {exportMenuOpen && (+ <div className="absolute right-0 top-full mt-2 w-52 glass rounded-lg shadow-xl overflow-hidden animate-fade-slide-in z-50">+ <div className="p-2">+ <button+ onClick={exportPNG}+ disabled={!reactFlowInstance}+ className="w-full flex items-center gap-3 px-3 py-2 text-sm text-text-primary hover:bg-elevated transition-colors rounded-lg text-left disabled:opacity-50 disabled:cursor-not-allowed"+ >+ <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />+ </svg>+ <span>Export as PNG</span>+ </button>+ <button+ onClick={exportSVG}+ disabled={!reactFlowInstance}+ className="w-full flex items-center gap-3 px-3 py-2 text-sm text-text-primary hover:bg-elevated transition-colors rounded-lg text-left disabled:opacity-50 disabled:cursor-not-allowed"+ >+ <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01" />+ </svg>+ <span>Export as SVG</span>+ </button>+ <button+ onClick={exportJSON}+ disabled={!graph}+ className="w-full flex items-center gap-3 px-3 py-2 text-sm text-text-primary hover:bg-elevated transition-colors rounded-lg text-left disabled:opacity-50 disabled:cursor-not-allowed"+ >+ <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />+ </svg>+ <span>Export as JSON</span>+ </button>+ </div>+ </div>+ )}+ </div>+ );+}diff --cc understand-anything-plugin/packages/dashboard/src/components/FilterPanel.tsxindex e4f5c23b,00000000..fe5df090mode 100644,000000..100644--- a/understand-anything-plugin/packages/dashboard/src/components/FilterPanel.tsx+++ b/understand-anything-plugin/packages/dashboard/src/components/FilterPanel.tsx@@@ -1,217 -1,0 +1,217 @@@+import { useEffect, useRef } from "react";- import { useDashboardStore } from "../store";++import { useDashboardStore, ALL_NODE_TYPES, ALL_COMPLEXITIES, ALL_EDGE_CATEGORIES } from "../store";+import type { NodeType, Complexity, EdgeCategory } from "../store";++export default function FilterPanel() {+ const graph = useDashboardStore((s) => s.graph);+ const filters = useDashboardStore((s) => s.filters);+ const setFilters = useDashboardStore((s) => s.setFilters);+ const resetFilters = useDashboardStore((s) => s.resetFilters);+ const hasActiveFilters = useDashboardStore((s) => s.hasActiveFilters);+ const filterPanelOpen = useDashboardStore((s) => s.filterPanelOpen);+ const toggleFilterPanel = useDashboardStore((s) => s.toggleFilterPanel);++ const containerRef = useRef<HTMLDivElement>(null);+- const allNodeTypes: NodeType[] = ["file", "function", "class", "module", "concept"];- const allComplexities: Complexity[] = ["simple", "moderate", "complex"];- const allEdgeCategories: EdgeCategory[] = ["structural", "behavioral", "data-flow", "dependencies", "semantic"];++ const allNodeTypes = ALL_NODE_TYPES;++ const allComplexities = ALL_COMPLEXITIES;++ const allEdgeCategories = ALL_EDGE_CATEGORIES;+ const layers = graph?.layers ?? [];++ // Close dropdown on outside click+ useEffect(() => {+ const handleClickOutside = (e: MouseEvent) => {+ if (containerRef.current && !containerRef.current.contains(e.target as Node)) {+ if (filterPanelOpen) {+ toggleFilterPanel();+ }+ }+ };+ document.addEventListener("mousedown", handleClickOutside);+ return () => document.removeEventListener("mousedown", handleClickOutside);+ }, [filterPanelOpen, toggleFilterPanel]);++ const toggleNodeType = (type: NodeType) => {+ const newTypes = new Set(filters.nodeTypes);+ if (newTypes.has(type)) {+ newTypes.delete(type);+ } else {+ newTypes.add(type);+ }+ setFilters({ nodeTypes: newTypes });+ };++ const toggleComplexity = (complexity: Complexity) => {+ const newComplexities = new Set(filters.complexities);+ if (newComplexities.has(complexity)) {+ newComplexities.delete(complexity);+ } else {+ newComplexities.add(complexity);+ }+ setFilters({ complexities: newComplexities });+ };++ const toggleLayer = (layerId: string) => {+ const newLayers = new Set(filters.layerIds);+ if (newLayers.has(layerId)) {+ newLayers.delete(layerId);+ } else {+ newLayers.add(layerId);+ }+ setFilters({ layerIds: newLayers });+ };++ const toggleEdgeCategory = (category: EdgeCategory) => {+ const newCategories = new Set(filters.edgeCategories);+ if (newCategories.has(category)) {+ newCategories.delete(category);+ } else {+ newCategories.add(category);+ }+ setFilters({ edgeCategories: newCategories });+ };++ const isActive = hasActiveFilters();++ return (+ <div ref={containerRef} className="relative">+ <button+ onClick={toggleFilterPanel}+ className={`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors ${+ isActive+ ? "bg-gold/20 text-gold hover:bg-gold/30"+ : "bg-elevated text-text-secondary hover:text-text-primary"+ }`}+ title="Filter graph (F)"+ >+ <svg+ className="w-4 h-4"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ >+ <path+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth={2}+ d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"+ />+ </svg>+ Filter+ </button>++ {filterPanelOpen && (+ <div className="absolute right-0 top-full mt-2 w-72 glass rounded-lg shadow-xl overflow-hidden animate-fade-slide-in z-50">+ <div className="p-4 space-y-4">+ {/* Node Types */}+ <div>+ <h3 className="text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2">+ Node Types+ </h3>+ <div className="space-y-1.5">+ {allNodeTypes.map((type) => (+ <label+ key={type}+ className="flex items-center gap-2 cursor-pointer hover:bg-elevated/50 rounded px-2 py-1 transition-colors"+ >+ <input+ type="checkbox"+ checked={filters.nodeTypes.has(type)}+ onChange={() => toggleNodeType(type)}+ className="w-3.5 h-3.5 rounded border-border-subtle bg-elevated checked:bg-gold checked:border-gold focus:ring-0 focus:ring-offset-0 cursor-pointer"+ />+ <span className="text-sm text-text-primary capitalize">{type}</span>+ </label>+ ))}+ </div>+ </div>++ {/* Complexity */}+ <div>+ <h3 className="text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2">+ Complexity+ </h3>+ <div className="space-y-1.5">+ {allComplexities.map((complexity) => (+ <label+ key={complexity}+ className="flex items-center gap-2 cursor-pointer hover:bg-elevated/50 rounded px-2 py-1 transition-colors"+ >+ <input+ type="checkbox"+ checked={filters.complexities.has(complexity)}+ onChange={() => toggleComplexity(complexity)}+ className="w-3.5 h-3.5 rounded border-border-subtle bg-elevated checked:bg-gold checked:border-gold focus:ring-0 focus:ring-offset-0 cursor-pointer"+ />+ <span className="text-sm text-text-primary capitalize">{complexity}</span>+ </label>+ ))}+ </div>+ </div>++ {/* Layers */}+ {layers.length > 0 && (+ <div>+ <h3 className="text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2">+ Layers+ </h3>+ <div className="space-y-1.5">+ {layers.map((layer) => (+ <label+ key={layer.id}+ className="flex items-center gap-2 cursor-pointer hover:bg-elevated/50 rounded px-2 py-1 transition-colors"+ >+ <input+ type="checkbox"+ checked={filters.layerIds.has(layer.id)}+ onChange={() => toggleLayer(layer.id)}+ className="w-3.5 h-3.5 rounded border-border-subtle bg-elevated checked:bg-gold checked:border-gold focus:ring-0 focus:ring-offset-0 cursor-pointer"+ />+ <div className="w-2 h-2 rounded-full bg-gold/50 shrink-0" />+ <span className="text-sm text-text-primary">{layer.name}</span>+ </label>+ ))}+ </div>+ </div>+ )}++ {/* Edge Categories */}+ <div>+ <h3 className="text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2">+ Edge Categories+ </h3>+ <div className="space-y-1.5">+ {allEdgeCategories.map((category) => (+ <label+ key={category}+ className="flex items-center gap-2 cursor-pointer hover:bg-elevated/50 rounded px-2 py-1 transition-colors"+ >+ <input+ type="checkbox"+ checked={filters.edgeCategories.has(category)}+ onChange={() => toggleEdgeCategory(category)}+ className="w-3.5 h-3.5 rounded border-border-subtle bg-elevated checked:bg-gold checked:border-gold focus:ring-0 focus:ring-offset-0 cursor-pointer"+ />+ <span className="text-sm text-text-primary capitalize">- {category.replace("-", " ")}++ {category.replace(/-/g, " ")}+ </span>+ </label>+ ))}+ </div>+ </div>++ {/* Reset Button */}+ {isActive && (+ <button+ onClick={resetFilters}+ className="w-full px-3 py-1.5 text-sm bg-elevated hover:bg-gold/20 text-text-secondary hover:text-gold rounded-lg transition-colors"+ >+ Reset All+ </button>+ )}+ </div>+ </div>+ )}+ </div>+ );+}diff --cc understand-anything-plugin/packages/dashboard/src/components/GraphView.tsxindex bc4780ed,66c47dac..7e61e51d--- a/understand-anything-plugin/packages/dashboard/src/components/GraphView.tsx+++ b/understand-anything-plugin/packages/dashboard/src/components/GraphView.tsx@@@ -92,335 -114,404 +114,405 @@@ function SelectedNodeFitView()return null;}- /**- * Build topology-only flow data: nodes and edges without visual-only state- * (selection, tour highlights, search results). This output drives dagre- * layout and should only recompute when the graph structure changes.- */- function buildTopologyData(- graph: NonNullable<ReturnType<typeof useDashboardStore.getState>["graph"]>,- persona: string,- diffMode: boolean,- changedNodeIds: Set<string>,- affectedNodeIds: Set<string>,- handleNodeSelect: (nodeId: string) => void,- filters: FilterState,- ) {- // Step 1: Apply persona filtering- let filteredGraphNodes =- persona === "non-technical"- ? graph.nodes.filter(- (n) =>- n.type === "concept" || n.type === "module" || n.type === "file",- )- : graph.nodes;+ // ── Overview level: layers as cluster nodes ────────────────────────────- // Step 2: Apply filter panel filters- filteredGraphNodes = filterNodes(filteredGraphNodes, graph.layers ?? [], filters);+ function useOverviewGraph() {+ const graph = useDashboardStore((s) => s.graph);+ const searchResults = useDashboardStore((s) => s.searchResults);+ const drillIntoLayer = useDashboardStore((s) => s.drillIntoLayer);- const filteredNodeIds = new Set(filteredGraphNodes.map((n) => n.id));+ return useMemo(() => {+ if (!graph) return { nodes: [] as Node[], edges: [] as Edge[] };- // Step 3: Filter edges based on visible nodes and edge categories- let filteredGraphEdges = graph.edges.filter(- (e) => filteredNodeIds.has(e.source) && filteredNodeIds.has(e.target),- );- filteredGraphEdges = filterEdges(filteredGraphEdges, filteredNodeIds, filters);-- // Compute connection counts for each node- const incomingCounts = new Map<string, number>();- const outgoingCounts = new Map<string, number>();- for (const edge of filteredGraphEdges) {- outgoingCounts.set(edge.source, (outgoingCounts.get(edge.source) ?? 0) + 1);- incomingCounts.set(edge.target, (incomingCounts.get(edge.target) ?? 0) + 1);- }+ const layers = graph.layers ?? [];+ if (layers.length === 0) return { nodes: [] as Node[], edges: [] as Edge[] };++ // Build search match counts per layer+ const searchMatchByLayer = new Map<string, number>();+ if (searchResults.length > 0) {+ const nodeToLayer = new Map<string, string>();+ for (const layer of layers) {+ for (const nid of layer.nodeIds) {+ nodeToLayer.set(nid, layer.id);+ }+ }+ for (const result of searchResults) {+ const lid = nodeToLayer.get(result.nodeId);+ if (lid) {+ searchMatchByLayer.set(lid, (searchMatchByLayer.get(lid) ?? 0) + 1);+ }+ }+ }- const flowNodes: CustomFlowNode[] = filteredGraphNodes.map((node) => ({- id: node.id,- type: "custom" as const,- position: { x: 0, y: 0 },- data: {- label: node.name ?? node.filePath?.split("/").pop() ?? node.id,- nodeType: node.type,- summary: node.summary,- complexity: node.complexity,- isHighlighted: false,- searchScore: undefined,- isSelected: false,- isTourHighlighted: false,- isDiffChanged: diffMode && changedNodeIds.has(node.id),- isDiffAffected: diffMode && affectedNodeIds.has(node.id),- isDiffFaded: diffMode && !changedNodeIds.has(node.id) && !affectedNodeIds.has(node.id),- onNodeClick: handleNodeSelect,- incomingCount: incomingCounts.get(node.id) ?? 0,- outgoingCount: outgoingCounts.get(node.id) ?? 0,- tags: node.tags ?? [],- },- }));-- const diffNodeIds = diffMode ? new Set([...changedNodeIds, ...affectedNodeIds]) : new Set<string>();- const flowEdges: Edge[] = filteredGraphEdges.map((edge, i) => {- const sourceInDiff = diffMode && diffNodeIds.has(edge.source);- const targetInDiff = diffMode && diffNodeIds.has(edge.target);- const isImpacted = diffMode && (sourceInDiff || targetInDiff);-- return {- id: `e-${i}`,- source: edge.source,- target: edge.target,- label: edge.type,- animated: edge.type === "calls" || isImpacted,- style: isImpacted- ? {- stroke: sourceInDiff && targetInDiff- ? "rgba(224, 82, 82, 0.7)"- : "rgba(212, 160, 48, 0.5)",- strokeWidth: 2.5,- }- : diffMode- ? { stroke: "rgba(212,165,116,0.08)", strokeWidth: 1 }- : { stroke: "rgba(212,165,116,0.3)", strokeWidth: 1.5 },- labelStyle: diffMode && !isImpacted- ? { fill: "rgba(163,151,135,0.3)", fontSize: 10 }- : { fill: "#a39787", fontSize: 10 },- };- });-- return { flowNodes, flowEdges };+ // Create cluster nodes+ const clusterNodes: LayerClusterFlowNode[] = layers.map((layer, i) => {+ const memberNodes = graph.nodes.filter((n) => layer.nodeIds.includes(n.id));+ const complexCounts = { simple: 0, moderate: 0, complex: 0 };+ for (const n of memberNodes) {+ complexCounts[n.complexity]++;+ }+ const aggregateComplexity =+ complexCounts.complex > memberNodes.length * 0.3+ ? "complex"+ : complexCounts.moderate > memberNodes.length * 0.3+ ? "moderate"+ : "simple";++ return {+ id: layer.id,+ type: "layer-cluster" as const,+ position: { x: 0, y: 0 },+ data: {+ layerId: layer.id,+ layerName: layer.name,+ layerDescription: layer.description,+ fileCount: layer.nodeIds.length,+ aggregateComplexity,+ layerColorIndex: i,+ searchMatchCount: searchMatchByLayer.get(layer.id),+ onDrillIn: drillIntoLayer,+ },+ };+ });++ // Aggregate edges between layers+ const aggregated = aggregateLayerEdges(graph);+ const flowEdges: Edge[] = aggregated.map((agg, i) => ({+ id: `le-${i}`,+ source: agg.sourceLayerId,+ target: agg.targetLayerId,+ label: `${agg.count}`,+ style: {+ stroke: "rgba(212,165,116,0.4)",+ strokeWidth: Math.min(1 + Math.log2(agg.count + 1), 5),+ },+ labelStyle: { fill: "#a39787", fontSize: 11, fontWeight: 600 },+ }));++ const dims = new Map<string, { width: number; height: number }>();+ for (const n of clusterNodes) {+ dims.set(n.id, { width: LAYER_CLUSTER_WIDTH, height: LAYER_CLUSTER_HEIGHT });+ }+ const laid = applyDagreLayout(clusterNodes as unknown as Node[], flowEdges, "TB", dims);+ return { nodes: laid.nodes, edges: laid.edges };+ }, [graph, searchResults, drillIntoLayer]);}+ // ── Layer detail level: topology (dagre) + visual overlay ───────────────+/**- * Lightweight overlay of visual-only state onto already-positioned nodes.- * This is O(n) object spreads — cheap even for thousands of nodes — and- * avoids triggering a dagre relayout when selection/highlight/search changes.+ * Topology memo: computes node positions via dagre. Only recomputes when+ * the graph structure, active layer, persona, diff, or focus changes.+ * Does NOT depend on selectedNodeId, searchResults, or tourHighlightedNodeIds.*/- function applyVisualState(- nodes: (CustomFlowNode | Node)[],- selectedNodeId: string | null,- tourHighlightedNodeIds: string[],- searchResults: Array<{ nodeId: string; score: number }>,- ): (CustomFlowNode | Node)[] {- const searchMap = new Map(searchResults.map((r) => [r.nodeId, r.score]));- const tourSet = new Set(tourHighlightedNodeIds);-- return nodes.map((node) => {- // Skip group nodes (layer containers) — they have no CustomNodeData- if (node.type === "group") return node;-- const searchScore = searchMap.get(node.id);- const isHighlighted = searchScore !== undefined;- const isSelected = selectedNodeId === node.id;- const isTourHighlighted = tourSet.has(node.id);-- const data = node.data as CustomFlowNode["data"];-- // Skip creating a new object if nothing visual changed- if (- data.isHighlighted === isHighlighted &&- data.searchScore === searchScore &&- data.isSelected === isSelected &&- data.isTourHighlighted === isTourHighlighted- ) {- return node;- }+ function useLayerDetailTopology() {+ const graph = useDashboardStore((s) => s.graph);+ const activeLayerId = useDashboardStore((s) => s.activeLayerId);+ const selectNode = useDashboardStore((s) => s.selectNode);+ const persona = useDashboardStore((s) => s.persona);+ const diffMode = useDashboardStore((s) => s.diffMode);+ const changedNodeIds = useDashboardStore((s) => s.changedNodeIds);+ const affectedNodeIds = useDashboardStore((s) => s.affectedNodeIds);+ const focusNodeId = useDashboardStore((s) => s.focusNodeId);+ const nodeTypeFilters = useDashboardStore((s) => s.nodeTypeFilters);+ const drillIntoLayer = useDashboardStore((s) => s.drillIntoLayer);- return {- ...node,- data: {- ...data,- isHighlighted,- searchScore,- isSelected,- isTourHighlighted,- },- };- });- }+ const handleNodeSelect = useCallback(+ (nodeId: string) => {+ selectNode(nodeId);+ },+ [selectNode],+ );- function applyLayerGroups(- laidNodes: CustomFlowNode[],- edges: Edge[],- layers: Array<{ id: string; name: string; nodeIds: string[] }>,- showLayers: boolean,- ): { initialNodes: (CustomFlowNode | Node)[]; initialEdges: Edge[] } {- if (!showLayers || layers.length === 0) {- return { initialNodes: laidNodes, initialEdges: edges };- }+ return useMemo(() => {+ if (!graph || !activeLayerId)+ return { nodes: [] as CustomFlowNode[], edges: [] as Edge[], portalNodes: [] as PortalFlowNode[], portalEdges: [] as Edge[], filteredEdges: [] as KnowledgeGraph["edges"] };- const nodeToLayer = new Map<string, string>();- for (const layer of layers) {- for (const nodeId of layer.nodeIds) {- nodeToLayer.set(nodeId, layer.id);- }- }+ const activeLayer = graph.layers.find((l) => l.id === activeLayerId);+ if (!activeLayer) return { nodes: [] as CustomFlowNode[], edges: [] as Edge[], portalNodes: [] as PortalFlowNode[], portalEdges: [] as Edge[], filteredEdges: [] as KnowledgeGraph["edges"] };++ const layerNodeIds = new Set(activeLayer.nodeIds);++ // 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([+ "file", "config", "document", "service", "table",+ "endpoint", "pipeline", "schema", "resource",+ ]);++ // Non-technical persona: show module, concept, and file-level types (hide function/class)+ // 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)),+ )+ : graph.nodes.filter((n) => layerNodeIds.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) => {+ const category = NODE_TYPE_TO_CATEGORY[n.type as NodeType];+ if (!category) {+ if (import.meta.env.DEV) {+ console.warn(`[GraphView] Unknown node type "${n.type}" — defaulting to "code" category`);+ }+ }+ const effectiveCategory = category ?? "code";+ return nodeTypeFilters[effectiveCategory] !== false;+ });- const groupNodes: Node[] = [];- const adjustedNodes: (CustomFlowNode | Node)[] = [];+ let filteredNodeIds = new Set(filteredGraphNodes.map((n) => n.id));- for (const layer of layers) {- const memberNodes = laidNodes.filter((n) => layer.nodeIds.includes(n.id));- if (memberNodes.length === 0) continue;+ let filteredGraphEdges = graph.edges.filter(+ (e) => filteredNodeIds.has(e.source) && filteredNodeIds.has(e.target),+ );- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;- for (const node of memberNodes) {- minX = Math.min(minX, node.position.x);- minY = Math.min(minY, node.position.y);- maxX = Math.max(maxX, node.position.x + NODE_WIDTH);- maxY = Math.max(maxY, node.position.y + NODE_HEIGHT);+ // Focus mode: 1-hop neighborhood within the layer+ if (focusNodeId && filteredNodeIds.has(focusNodeId)) {+ const focusNeighborIds = new Set<string>([focusNodeId]);+ for (const edge of filteredGraphEdges) {+ if (edge.source === focusNodeId) focusNeighborIds.add(edge.target);+ if (edge.target === focusNodeId) focusNeighborIds.add(edge.source);+ }+ filteredGraphNodes = filteredGraphNodes.filter((n) =>+ focusNeighborIds.has(n.id),+ );+ filteredNodeIds = new Set(filteredGraphNodes.map((n) => n.id));+ filteredGraphEdges = filteredGraphEdges.filter(+ (e) => filteredNodeIds.has(e.source) && filteredNodeIds.has(e.target),+ );}- const groupX = minX - LAYER_PADDING;- const groupY = minY - LAYER_PADDING - 24;- const groupWidth = maxX - minX + LAYER_PADDING * 2;- const groupHeight = maxY - minY + LAYER_PADDING * 2 + 24;+ const diffNodeIds = diffMode+ ? new Set([...changedNodeIds, ...affectedNodeIds])+ : new Set<string>();- groupNodes.push({- id: layer.id,- type: "group",- position: { x: groupX, y: groupY },- data: { label: layer.name },- style: {- width: groupWidth,- height: groupHeight,- backgroundColor: "rgba(212,165,116,0.05)",- borderRadius: 12,- border: "2px dashed rgba(212,165,116,0.25)",- padding: 8,- fontSize: 13,- fontWeight: 600,- color: "#d4a574",+ const flowNodes: CustomFlowNode[] = filteredGraphNodes.map((node) => ({+ id: node.id,+ type: "custom" as const,+ position: { x: 0, y: 0 },+ data: {+ label: node.name ?? node.filePath?.split("/").pop() ?? node.id,+ nodeType: node.type,+ summary: node.summary,+ complexity: node.complexity,+ isHighlighted: false,+ searchScore: undefined,+ isSelected: false,+ isTourHighlighted: false,+ isDiffChanged: diffMode && changedNodeIds.has(node.id),+ isDiffAffected: diffMode && affectedNodeIds.has(node.id),+ isDiffFaded: diffMode && !changedNodeIds.has(node.id) && !affectedNodeIds.has(node.id),+ isNeighbor: false,+ isSelectionFaded: false,+ onNodeClick: handleNodeSelect,},+ }));++ const flowEdges: Edge[] = filteredGraphEdges.map((edge, i) => {+ const sourceInDiff = diffMode && diffNodeIds.has(edge.source);+ const targetInDiff = diffMode && diffNodeIds.has(edge.target);+ const isImpacted = diffMode && (sourceInDiff || targetInDiff);++ let edgeStyle: React.CSSProperties;+ let edgeLabelStyle: React.CSSProperties;+ let edgeAnimated: boolean;++ if (isImpacted) {+ edgeStyle = {+ stroke: sourceInDiff && targetInDiff ? "rgba(224, 82, 82, 0.7)" : "rgba(212, 160, 48, 0.5)",+ strokeWidth: 2.5,+ };+ edgeLabelStyle = { fill: "#a39787", fontSize: 10 };+ edgeAnimated = true;+ } else if (diffMode) {+ edgeStyle = { stroke: "rgba(212,165,116,0.08)", strokeWidth: 1 };+ edgeLabelStyle = { fill: "rgba(163,151,135,0.3)", fontSize: 10 };+ edgeAnimated = false;+ } else {+ edgeStyle = { stroke: "rgba(212,165,116,0.3)", strokeWidth: 1.5 };+ edgeLabelStyle = { fill: "#a39787", fontSize: 10 };+ edgeAnimated = edge.type === "calls";+ }++ return {+ id: `e-${i}`,+ source: edge.source,+ target: edge.target,+ label: edge.type,+ animated: edgeAnimated,+ style: edgeStyle,+ labelStyle: edgeLabelStyle,+ };});- for (const node of memberNodes) {- adjustedNodes.push({- ...node,- parentId: layer.id,- extent: "parent" as const,- position: {- x: node.position.x - groupX,- y: node.position.y - groupY,- },- });+ // Portal nodes for connected external layers+ const portals = computePortals(graph, activeLayerId);+ const layerIndexMap = new Map(graph.layers.map((l, i) => [l.id, i]));++ const portalNodes: PortalFlowNode[] = portals.map((portal) => ({+ id: `portal:${portal.layerId}`,+ type: "portal" as const,+ position: { x: 0, y: 0 },+ data: {+ targetLayerId: portal.layerId,+ targetLayerName: portal.layerName,+ connectionCount: portal.connectionCount,+ layerColorIndex: layerIndexMap.get(portal.layerId) ?? 0,+ onNavigate: drillIntoLayer,+ },+ }));++ const portalEdges: Edge[] = [];+ let portalEdgeIdx = flowEdges.length;+ for (const portal of portals) {+ const crossFiles = findCrossLayerFileNodes(graph, activeLayerId, portal.layerId);+ for (const fileId of crossFiles) {+ if (filteredNodeIds.has(fileId)) {+ portalEdges.push({+ id: `e-${portalEdgeIdx++}`,+ source: fileId,+ target: `portal:${portal.layerId}`,+ style: { stroke: "rgba(212,165,116,0.2)", strokeWidth: 1, strokeDasharray: "4 4" },+ animated: false,+ });+ }+ }}- }- for (const node of laidNodes) {- if (!nodeToLayer.has(node.id)) {- adjustedNodes.push(node);+ const allFlowNodes: Node[] = [+ ...(flowNodes as unknown as Node[]),+ ...(portalNodes as unknown as Node[]),+ ];+ const allFlowEdges = [...flowEdges, ...portalEdges];++ const dims = new Map<string, { width: number; height: number }>();+ for (const n of flowNodes) {+ dims.set(n.id, { width: NODE_WIDTH, height: NODE_HEIGHT });+ }+ for (const n of portalNodes) {+ dims.set(n.id, { width: PORTAL_NODE_WIDTH, height: PORTAL_NODE_HEIGHT });}- }- return {- initialNodes: [...groupNodes, ...adjustedNodes],- initialEdges: edges,- };+ const laid = applyDagreLayout(allFlowNodes, allFlowEdges, "TB", dims);+ return { nodes: laid.nodes, edges: laid.edges, portalNodes, portalEdges, filteredEdges: filteredGraphEdges };+ }, [graph, activeLayerId, persona, handleNodeSelect, diffMode, changedNodeIds, affectedNodeIds, focusNodeId, nodeTypeFilters, drillIntoLayer]);}- function GraphViewInner() {- const graph = useDashboardStore((s) => s.graph);+ /**+ * Visual overlay: cheap O(n) pass that applies selection, search, and tour+ * state onto already-positioned nodes. Avoids triggering dagre relayout.+ */+ function useLayerDetailGraph() {const selectedNodeId = useDashboardStore((s) => s.selectedNodeId);const searchResults = useDashboardStore((s) => s.searchResults);- const selectNode = useDashboardStore((s) => s.selectNode);- const openCodeViewer = useDashboardStore((s) => s.openCodeViewer);- const showLayers = useDashboardStore((s) => s.showLayers);const tourHighlightedNodeIds = useDashboardStore((s) => s.tourHighlightedNodeIds);- const persona = useDashboardStore((s) => s.persona);- const diffMode = useDashboardStore((s) => s.diffMode);- const changedNodeIds = useDashboardStore((s) => s.changedNodeIds);- const affectedNodeIds = useDashboardStore((s) => s.affectedNodeIds);- const filters = useDashboardStore((s) => s.filters);- const setReactFlowInstance = useDashboardStore((s) => s.setReactFlowInstance);- const [layouting, setLayouting] = useState(false);+ const topo = useLayerDetailTopology();- const handleNodeSelect = useCallback(- (nodeId: string) => {- selectNode(nodeId);- openCodeViewer(nodeId);- },- [selectNode, openCodeViewer],- );+ const nodes = useMemo(() => {+ const searchMap = new Map(searchResults.map((r) => [r.nodeId, r.score]));+ const tourSet = new Set(tourHighlightedNodeIds);- // ── Topology memo: only recomputes when graph structure changes ──- // Does NOT depend on selectedNodeId, tourHighlightedNodeIds, or searchResults.- const { topoNodes, topoEdges, needsAsyncLayout } = useMemo(() => {- if (!graph) {- return { topoNodes: [] as CustomFlowNode[], topoEdges: [] as Edge[], needsAsyncLayout: false };+ // Build neighbor set for selection highlighting+ const neighborNodeIds = new Set<string>();+ if (selectedNodeId) {+ for (const edge of topo.filteredEdges) {+ if (edge.source === selectedNodeId) neighborNodeIds.add(edge.target);+ if (edge.target === selectedNodeId) neighborNodeIds.add(edge.source);+ }+ neighborNodeIds.add(selectedNodeId);}- const { flowNodes, flowEdges } = buildTopologyData(- graph, persona, diffMode, changedNodeIds, affectedNodeIds,- handleNodeSelect, filters,- );- return { topoNodes: flowNodes, topoEdges: flowEdges, needsAsyncLayout: flowNodes.length > ASYNC_LAYOUT_THRESHOLD };- }, [graph, persona, handleNodeSelect, diffMode, changedNodeIds, affectedNodeIds, filters]);- // ── Laid-out nodes from the last completed layout pass ──- // Stored in a ref so layout results persist across visual-state changes.- const laidOutRef = useRef<{ initialNodes: (CustomFlowNode | Node)[]; initialEdges: Edge[] } | null>(null);+ return topo.nodes.map((node) => {+ // Skip portal nodes — they have no CustomNodeData+ if (node.type === "portal") return node;++ const searchScore = searchMap.get(node.id);+ const isHighlighted = searchScore !== undefined;+ const isSelected = selectedNodeId === node.id;+ const isTourHighlighted = tourSet.has(node.id);+ const hasSelection = !!selectedNodeId;+ const isNeighbor = hasSelection && neighborNodeIds.has(node.id) && !isSelected;+ const isSelectionFaded = hasSelection && !neighborNodeIds.has(node.id);++ const data = node.data as CustomFlowNode["data"];++ // Skip creating a new object if nothing visual changed+ if (+ data.isHighlighted === isHighlighted &&+ data.searchScore === searchScore &&+ data.isSelected === isSelected &&+ data.isTourHighlighted === isTourHighlighted &&+ data.isNeighbor === isNeighbor &&+ data.isSelectionFaded === isSelectionFaded+ ) {+ return node;+ }++ return { ...node, data: { ...data, isHighlighted, searchScore, isSelected, isTourHighlighted, isNeighbor, isSelectionFaded } };+ });+ }, [topo.nodes, topo.filteredEdges, selectedNodeId, searchResults, tourHighlightedNodeIds]);++ const edges = useMemo(() => {+ if (!selectedNodeId) return topo.edges;++ // Apply selection-based edge styling on top of topology edges+ return topo.edges.map((edge) => {+ const isSelectedEdge = edge.source === selectedNodeId || edge.target === selectedNodeId;+ // Don't restyle diff-impacted or portal edges+ if ((edge.style as Record<string, unknown>)?.strokeDasharray) return edge;++ if (isSelectedEdge) {+ return { ...edge, animated: true, style: { stroke: "rgba(212,165,116,0.8)", strokeWidth: 2.5 }, labelStyle: { fill: "#d4a574", fontSize: 11, fontWeight: 600 } };+ }+ // Fade unrelated edges+ return { ...edge, animated: false, style: { stroke: "rgba(212,165,116,0.08)", strokeWidth: 1 }, labelStyle: { fill: "rgba(163,151,135,0.2)", fontSize: 10 } };+ });+ }, [topo.edges, selectedNodeId]);++ return { nodes, edges };+ }- // ── Sync layout: for small graphs, run dagre on the main thread ──- const syncResult = useMemo(() => {- if (!graph || needsAsyncLayout || topoNodes.length === 0) return null;- const laid = applyDagreLayout(topoNodes, topoEdges);- const layers = graph.layers ?? [];- return applyLayerGroups(laid.nodes as CustomFlowNode[], laid.edges, layers, showLayers);- }, [graph, topoNodes, topoEdges, needsAsyncLayout, showLayers]);+ // ── Main inner component (must be inside ReactFlowProvider) ────────────- // Keep laidOutRef in sync with sync layout results- if (syncResult) {- laidOutRef.current = syncResult;- }+ function GraphViewInner() {+ const graph = useDashboardStore((s) => s.graph);+ const navigationLevel = useDashboardStore((s) => s.navigationLevel);+ const activeLayerId = useDashboardStore((s) => s.activeLayerId);+ const selectNode = useDashboardStore((s) => s.selectNode);+ const openCodeViewer = useDashboardStore((s) => s.openCodeViewer);+ const drillIntoLayer = useDashboardStore((s) => s.drillIntoLayer);+ const focusNodeId = useDashboardStore((s) => s.focusNodeId);+ const setFocusNode = useDashboardStore((s) => s.setFocusNode);++ const setReactFlowInstance = useDashboardStore((s) => s.setReactFlowInstance);+ const { preset } = useTheme();- // ── Visual memo: cheap overlay of selection/highlight/search state ──- const visualNodes = useMemo(() => {- const base = laidOutRef.current;- if (!base) return [] as (CustomFlowNode | Node)[];- return applyVisualState(base.initialNodes, selectedNodeId, tourHighlightedNodeIds, searchResults);- }, [laidOutRef.current, selectedNodeId, tourHighlightedNodeIds, searchResults]);+ const overviewGraph = useOverviewGraph();+ const detailGraph = useLayerDetailGraph();- const [nodes, setNodes, onNodesChange] = useNodesState(visualNodes);- const [edges, setEdges, onEdgesChange] = useEdgesState(laidOutRef.current?.initialEdges ?? []);+ const { nodes: initialNodes, edges: initialEdges } =+ navigationLevel === "overview" ? overviewGraph : detailGraph;- // ── Push sync layout + visual state to ReactFlow ──- useEffect(() => {- if (syncResult) {- const withVisual = applyVisualState(syncResult.initialNodes, selectedNodeId, tourHighlightedNodeIds, searchResults);- setNodes(withVisual);- setEdges(syncResult.initialEdges);- }- }, [syncResult, selectedNodeId, tourHighlightedNodeIds, searchResults, setNodes, setEdges]);+ const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);+ const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);++ const { fitView } = useReactFlow();- // ── Push visual-only changes (no relayout) ──useEffect(() => {- if (laidOutRef.current && !layouting) {- const withVisual = applyVisualState(laidOutRef.current.initialNodes, selectedNodeId, tourHighlightedNodeIds, searchResults);- setNodes(withVisual);- }- }, [selectedNodeId, tourHighlightedNodeIds, searchResults, setNodes, layouting]);+ setNodes(initialNodes);+ }, [initialNodes, setNodes]);- // ── Async layout: for large graphs, run dagre in a Web Worker ──useEffect(() => {- if (!graph || !needsAsyncLayout || topoNodes.length === 0) return;-- let cancelled = false;- setLayouting(true);-- applyDagreLayoutAsync(topoNodes, topoEdges).then((laid) => {- if (cancelled) return;- const layers = graph.layers ?? [];- const result = applyLayerGroups(laid.nodes as CustomFlowNode[], laid.edges, layers, showLayers);- laidOutRef.current = result;- const withVisual = applyVisualState(result.initialNodes, selectedNodeId, tourHighlightedNodeIds, searchResults);- setNodes(withVisual);- setEdges(result.initialEdges);- setLayouting(false);- }).catch(() => {- if (cancelled) return;- setLayouting(false);- });+ setEdges(initialEdges);+ }, [initialEdges, setEdges]);- return () => { cancelled = true; setLayouting(false); };- }, [graph, topoNodes, topoEdges, needsAsyncLayout, showLayers, setNodes, setEdges]);+ // Fit view on level/layer transitions+ useEffect(() => {+ const timer = setTimeout(() => {+ fitView({ duration: 400, padding: 0.2 });+ }, 50);+ return () => clearTimeout(timer);+ }, [navigationLevel, activeLayerId, fitView]);const onNodeClick = useCallback((_: React.MouseEvent, node: { id: string }) => {diff --cc understand-anything-plugin/packages/dashboard/src/components/NodeTooltip.tsxindex a8212282,00000000..8d581596mode 100644,000000..100644--- a/understand-anything-plugin/packages/dashboard/src/components/NodeTooltip.tsx+++ b/understand-anything-plugin/packages/dashboard/src/components/NodeTooltip.tsx@@@ -1,123 -1,0 +1,124 @@@+import { useEffect, useState } from "react";+import type { CustomNodeData } from "./CustomNode";++interface NodeTooltipProps {+ data: CustomNodeData;+ nodeId: string;+ incomingCount: number;+ outgoingCount: number;+ tags?: string[];+}++export default function NodeTooltip({+ data,+ nodeId,+ incomingCount,+ outgoingCount,+ tags = [],+}: NodeTooltipProps) {+ const [position, setPosition] = useState({ x: 0, y: 0 });+ const [visible, setVisible] = useState(false);++ useEffect(() => {- const handleMouseMove = (e: MouseEvent) => {- setPosition({ x: e.clientX, y: e.clientY });++ const handleMouseMove = (e: Event) => {++ const me = e as globalThis.MouseEvent;++ setPosition({ x: me.clientX, y: me.clientY });+ };++ const showTooltip = () => setVisible(true);+ const hideTooltip = () => setVisible(false);+- // Find the node element- const nodeElement = document.querySelector(`[data-id="${nodeId}"]`);++ // Find the node element via data-id (React Flow convention)++ const nodeElement = document.querySelector(`[data-id="${CSS.escape(nodeId)}"]`);+ if (nodeElement) {+ nodeElement.addEventListener("mouseenter", showTooltip);+ nodeElement.addEventListener("mouseleave", hideTooltip);+ nodeElement.addEventListener("mousemove", handleMouseMove);++ return () => {+ nodeElement.removeEventListener("mouseenter", showTooltip);+ nodeElement.removeEventListener("mouseleave", hideTooltip);+ nodeElement.removeEventListener("mousemove", handleMouseMove);+ };+ }+ }, [nodeId]);++ if (!visible) return null;++ const totalConnections = incomingCount + outgoingCount;++ return (+ <div+ className="fixed z-[9999] pointer-events-none"+ style={{+ left: position.x + 16,+ top: position.y + 16,+ }}+ >+ <div className="glass-heavy rounded-lg shadow-2xl p-3 max-w-xs animate-fade-slide-in">+ {/* Header */}+ <div className="flex items-center gap-2 mb-2 pb-2 border-b border-border-subtle">+ <span className="text-[10px] font-semibold uppercase tracking-wider text-gold">+ {data.nodeType}+ </span>+ {data.complexity && (+ <span className="text-[9px] px-1.5 py-0.5 rounded bg-elevated text-text-muted font-mono">+ {data.complexity}+ </span>+ )}+ </div>++ {/* Name */}+ <h4 className="text-sm font-serif text-text-primary mb-2 break-words">+ {data.label}+ </h4>++ {/* Connections */}+ <div className="flex items-center gap-4 mb-2 text-xs">+ <div className="flex items-center gap-1">+ <svg className="w-3 h-3 text-blue-400" fill="currentColor" viewBox="0 0 20 20">+ <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v3.586L7.707 9.293a1 1 0 00-1.414 1.414l3 3a1 1 0 001.414 0l3-3a1 1 0 00-1.414-1.414L11 10.586V7z" clipRule="evenodd" />+ </svg>+ <span className="text-text-secondary">{incomingCount} in</span>+ </div>+ <div className="flex items-center gap-1">+ <svg className="w-3 h-3 text-green-400" fill="currentColor" viewBox="0 0 20 20">+ <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v3.586L7.707 9.293a1 1 0 00-1.414 1.414l3 3a1 1 0 001.414 0l3-3a1 1 0 00-1.414-1.414L11 10.586V7z" clipRule="evenodd" transform="rotate(180 10 10)" />+ </svg>+ <span className="text-text-secondary">{outgoingCount} out</span>+ </div>+ <div className="flex items-center gap-1">+ <svg className="w-3 h-3 text-gold" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />+ </svg>+ <span className="text-gold font-medium">{totalConnections}</span>+ </div>+ </div>++ {/* Summary */}+ {data.summary && (+ <p className="text-xs text-text-secondary leading-relaxed mb-2">+ {data.summary.length > 120 ? data.summary.slice(0, 120) + "..." : data.summary}+ </p>+ )}++ {/* Tags */}+ {tags.length > 0 && (+ <div className="flex flex-wrap gap-1 pt-2 border-t border-border-subtle">+ {tags.slice(0, 3).map((tag) => (+ <span+ key={tag}+ className="text-[9px] px-1.5 py-0.5 rounded-full bg-gold/10 text-gold border border-gold/30"+ >+ {tag}+ </span>+ ))}+ {tags.length > 3 && (+ <span className="text-[9px] text-text-muted">+{tags.length - 3}</span>+ )}+ </div>+ )}+ </div>+ </div>+ );+}diff --cc understand-anything-plugin/packages/dashboard/src/components/ProjectOverview.tsxindex 073d8380,81d40187..ae799f13--- a/understand-anything-plugin/packages/dashboard/src/components/ProjectOverview.tsx+++ b/understand-anything-plugin/packages/dashboard/src/components/ProjectOverview.tsx@@@ -21,30 -21,16 +21,40 @@@ export default function ProjectOverviewtypeCounts[node.type] = (typeCounts[node.type] ?? 0) + 1;}+ // Count complexity+ const complexityCounts: Record<string, number> = { simple: 0, moderate: 0, complex: 0 };+ for (const node of nodes) {+ if (node.complexity) {+ complexityCounts[node.complexity] = (complexityCounts[node.complexity] ?? 0) + 1;+ }+ }++ // Find top connected nodes+ const nodeConnections = new Map<string, number>();+ for (const edge of edges) {+ nodeConnections.set(edge.source, (nodeConnections.get(edge.source) ?? 0) + 1);+ nodeConnections.set(edge.target, (nodeConnections.get(edge.target) ?? 0) + 1);+ }+ const topNodes = Array.from(nodeConnections.entries())+ .sort((a, b) => b[1] - a[1])+ .slice(0, 5)+ .map(([nodeId, count]) => {+ const node = nodes.find((n) => n.id === nodeId);+ return { id: nodeId, name: node?.name ?? nodeId, count };+ });++ const avgConnections = nodes.length > 0 ? (edges.length * 2 / nodes.length).toFixed(1) : "0";++ // Category breakdowns+ const categoryBreakdown = [+ { label: "Code", color: "var(--color-node-file)", count: (typeCounts["file"] ?? 0) + (typeCounts["function"] ?? 0) + (typeCounts["class"] ?? 0) },+ { label: "Config", color: "var(--color-node-config)", count: typeCounts["config"] ?? 0 },+ { label: "Docs", color: "var(--color-node-document)", count: typeCounts["document"] ?? 0 },+ { label: "Infra", color: "var(--color-node-service)", count: (typeCounts["service"] ?? 0) + (typeCounts["resource"] ?? 0) + (typeCounts["pipeline"] ?? 0) },+ { label: "Data", color: "var(--color-node-table)", count: (typeCounts["table"] ?? 0) + (typeCounts["endpoint"] ?? 0) + (typeCounts["schema"] ?? 0) },+ ];+ const hasNonCodeNodes = categoryBreakdown.some((c) => c.label !== "Code" && c.count > 0);+return (<div className="h-full w-full overflow-auto p-5 animate-fade-slide-in">{/* Project name */}@@@ -99,82 -104,6 +128,82 @@@</div>)}+ {/* Node Type Breakdown */}+ <div className="mb-5">- <h3 className="text-[11px] font-semibold text-gold uppercase tracking-wider mb-3">Node Type Distribution</h3>++ <h3 className="text-[11px] font-semibold text-accent uppercase tracking-wider mb-3">Node Type Distribution</h3>+ <div className="space-y-2">+ {Object.entries(typeCounts)+ .sort((a, b) => b[1] - a[1])+ .map(([type, count]) => {+ const percentage = ((count / nodes.length) * 100).toFixed(0);+ return (+ <div key={type}>+ <div className="flex items-center justify-between text-xs mb-1">+ <span className="text-text-secondary capitalize">{type}</span>+ <span className="text-text-muted font-mono">{count} ({percentage}%)</span>+ </div>+ <div className="w-full h-1.5 bg-elevated rounded-full overflow-hidden">+ <div- className="h-full bg-gold/50 rounded-full transition-all duration-500"++ className="h-full bg-accent/50 rounded-full transition-all duration-500"+ style={{ width: `${percentage}%` }}+ />+ </div>+ </div>+ );+ })}+ </div>+ </div>++ {/* Complexity Breakdown */}+ {Object.values(complexityCounts).some((c) => c > 0) && (+ <div className="mb-5">- <h3 className="text-[11px] font-semibold text-gold uppercase tracking-wider mb-3">Complexity Distribution</h3>++ <h3 className="text-[11px] font-semibold text-accent uppercase tracking-wider mb-3">Complexity Distribution</h3>+ <div className="grid grid-cols-3 gap-2">+ <div className="bg-elevated rounded-lg p-2 border border-border-subtle text-center">+ <div className="text-lg font-mono font-medium text-green-400">{complexityCounts.simple}</div>+ <div className="text-[10px] text-text-muted uppercase tracking-wider mt-0.5">Simple</div>+ </div>+ <div className="bg-elevated rounded-lg p-2 border border-border-subtle text-center">+ <div className="text-lg font-mono font-medium text-yellow-400">{complexityCounts.moderate}</div>+ <div className="text-[10px] text-text-muted uppercase tracking-wider mt-0.5">Moderate</div>+ </div>+ <div className="bg-elevated rounded-lg p-2 border border-border-subtle text-center">+ <div className="text-lg font-mono font-medium text-red-400">{complexityCounts.complex}</div>+ <div className="text-[10px] text-text-muted uppercase tracking-wider mt-0.5">Complex</div>+ </div>+ </div>+ </div>+ )}++ {/* Top Connected Nodes */}+ {topNodes.length > 0 && (+ <div className="mb-5">- <h3 className="text-[11px] font-semibold text-gold uppercase tracking-wider mb-3">Most Connected Nodes</h3>++ <h3 className="text-[11px] font-semibold text-accent uppercase tracking-wider mb-3">Most Connected Nodes</h3>+ <div className="space-y-2">+ {topNodes.map((node, idx) => (+ <div+ key={node.id}+ className="flex items-center gap-2 text-xs bg-elevated rounded-lg p-2 border border-border-subtle"+ >- <div className="w-5 h-5 shrink-0 rounded-full bg-gold/20 flex items-center justify-center text-[10px] font-bold text-gold">++ <div className="w-5 h-5 shrink-0 rounded-full bg-accent/20 flex items-center justify-center text-[10px] font-bold text-accent">+ {idx + 1}+ </div>+ <span className="flex-1 text-text-primary truncate">{node.name}</span>+ <span className="text-text-muted font-mono shrink-0">{node.count}</span>+ </div>+ ))}+ </div>+ </div>+ )}++ {/* Average Connections */}+ <div className="mb-5 bg-elevated rounded-lg p-3 border border-border-subtle">+ <div className="flex items-center justify-between">+ <span className="text-xs text-text-secondary">Avg Connections per Node</span>- <span className="text-lg font-mono font-medium text-gold">{avgConnections}</span>++ <span className="text-lg font-mono font-medium text-accent">{avgConnections}</span>+ </div>+ </div>+{/* Analyzed at */}<div className="text-[11px] text-text-muted mb-6">Analyzed: {new Date(project.analyzedAt).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}diff --cc understand-anything-plugin/packages/dashboard/src/store.tsindex e912e4b2,61f310fe..a2c10518--- a/understand-anything-plugin/packages/dashboard/src/store.ts+++ b/understand-anything-plugin/packages/dashboard/src/store.ts@@@ -5,28 -5,24 +5,54 @@@ import typeKnowledgeGraph,TourStep,} from "@understand-anything/core/types";+import type { ReactFlowInstance } from "@xyflow/react";export type Persona = "non-technical" | "junior" | "experienced";- export type NodeType = "file" | "function" | "class" | "module" | "concept";+ export type NavigationLevel = "overview" | "layer-detail";++export type NodeType = "file" | "function" | "class" | "module" | "concept" | "config" | "document" | "service" | "table" | "endpoint" | "pipeline" | "schema" | "resource";+export type Complexity = "simple" | "moderate" | "complex";+export type EdgeCategory = "structural" | "behavioral" | "data-flow" | "dependencies" | "semantic";++export interface FilterState {+ nodeTypes: Set<NodeType>;+ complexities: Set<Complexity>;+ layerIds: Set<string>;+ edgeCategories: Set<EdgeCategory>;+}+++export const ALL_NODE_TYPES: NodeType[] = ["file", "function", "class", "module", "concept", "config", "document", "service", "table", "endpoint", "pipeline", "schema", "resource"];++export const ALL_COMPLEXITIES: Complexity[] = ["simple", "moderate", "complex"];++export const ALL_EDGE_CATEGORIES: EdgeCategory[] = ["structural", "behavioral", "data-flow", "dependencies", "semantic"];+++export const EDGE_CATEGORY_MAP: Record<EdgeCategory, string[]> = {+ structural: ["imports", "exports", "contains", "inherits", "implements"],+ behavioral: ["calls", "subscribes", "publishes", "middleware"],+ "data-flow": ["reads_from", "writes_to", "transforms", "validates"],+ dependencies: ["depends_on", "tested_by", "configures"],+ semantic: ["related", "similar_to"],+};+++const DEFAULT_FILTERS: FilterState = {++ nodeTypes: new Set<NodeType>(ALL_NODE_TYPES),++ complexities: new Set<Complexity>(ALL_COMPLEXITIES),++ layerIds: new Set<string>(),++ edgeCategories: new Set<EdgeCategory>(ALL_EDGE_CATEGORIES),++};++ /** Categories used for node type filter toggles. Single source of truth for NodeCategory. */+ export type NodeCategory = "code" | "config" | "docs" | "infra" | "data";++ /** Find which layer a node belongs to. Returns layerId or null. */+ function findNodeLayer(graph: KnowledgeGraph, nodeId: string): string | null {+ for (const layer of graph.layers) {+ if (layer.nodeIds.includes(nodeId)) return layer.id;+ }+ return null;+ }++ /** Maximum number of entries in the sidebar navigation history. */+ const MAX_HISTORY = 50;+interface DashboardStore {graph: KnowledgeGraph | null;selectedNodeId: string | null;@@@ -51,16 -49,26 +79,33 @@@changedNodeIds: Set<string>;affectedNodeIds: Set<string>;+ // Focus mode: isolate a node's 1-hop neighborhood+ focusNodeId: string | null;++ // Sidebar navigation history (stack of visited node IDs)+ nodeHistory: string[];+++ // Filter & Export features+ filters: FilterState;+ filterPanelOpen: boolean;+ exportMenuOpen: boolean;+ pathFinderOpen: boolean;+ reactFlowInstance: ReactFlowInstance | null;++ // Node type category filters+ nodeTypeFilters: Record<NodeCategory, boolean>;+ toggleNodeTypeFilter: (category: NodeCategory) => void;+setGraph: (graph: KnowledgeGraph) => void;selectNode: (nodeId: string | null) => void;+ navigateToNode: (nodeId: string) => void;+ navigateToNodeInLayer: (nodeId: string) => void;+ navigateToHistoryIndex: (index: number) => void;+ goBackNode: () => void;+ drillIntoLayer: (layerId: string) => void;+ navigateToOverview: () => void;+ setFocusNode: (nodeId: string | null) => void;setSearchQuery: (query: string) => void;- toggleLayers: () => void;setPersona: (persona: Persona) => void;openCodeViewer: (nodeId: string) => void;closeCodeViewer: () => void;@@@ -112,17 -128,19 +173,25 @@@ export const useDashboardStore = createchangedNodeIds: new Set<string>(),affectedNodeIds: new Set<string>(),- filters: {- nodeTypes: new Set<NodeType>(["file", "function", "class", "module", "concept"]),- complexities: new Set<Complexity>(["simple", "moderate", "complex"]),- layerIds: new Set<string>(),- edgeCategories: new Set<EdgeCategory>(["structural", "behavioral", "data-flow", "dependencies", "semantic"]),- },+ focusNodeId: null,+ nodeHistory: [],+++ filters: { ...DEFAULT_FILTERS, nodeTypes: new Set(DEFAULT_FILTERS.nodeTypes), complexities: new Set(DEFAULT_FILTERS.complexities), layerIds: new Set(DEFAULT_FILTERS.layerIds), edgeCategories: new Set(DEFAULT_FILTERS.edgeCategories) },+ filterPanelOpen: false,+ exportMenuOpen: false,+ pathFinderOpen: false,+ reactFlowInstance: null,++ nodeTypeFilters: { code: true, config: true, docs: true, infra: true, data: true },++ toggleNodeTypeFilter: (category) =>+ set((state) => ({+ nodeTypeFilters: {+ ...state.nodeTypeFilters,+ [category]: !state.nodeTypeFilters[category],+ },+ })),+setGraph: (graph) => {const searchEngine = new SearchEngine(graph.nodes);const query = get().searchQuery;@@@ -168,49 -291,6 +342,43 @@@affectedNodeIds: new Set<string>(),}),+ toggleFilterPanel: () => set((state) => ({+ filterPanelOpen: !state.filterPanelOpen,+ exportMenuOpen: false,+ })),++ toggleExportMenu: () => set((state) => ({+ exportMenuOpen: !state.exportMenuOpen,+ filterPanelOpen: false,+ })),++ togglePathFinder: () => set((state) => ({+ pathFinderOpen: !state.pathFinderOpen,+ })),++ setReactFlowInstance: (instance) => set({ reactFlowInstance: instance }),++ setFilters: (newFilters) => set((state) => ({+ filters: { ...state.filters, ...newFilters },+ })),++ resetFilters: () => set({+ filters: {- nodeTypes: new Set<NodeType>(["file", "function", "class", "module", "concept"]),- complexities: new Set<Complexity>(["simple", "moderate", "complex"]),++ nodeTypes: new Set<NodeType>(ALL_NODE_TYPES),++ complexities: new Set<Complexity>(ALL_COMPLEXITIES),+ layerIds: new Set<string>(),- edgeCategories: new Set<EdgeCategory>(["structural", "behavioral", "data-flow", "dependencies", "semantic"]),++ edgeCategories: new Set<EdgeCategory>(ALL_EDGE_CATEGORIES),+ },+ }),++ hasActiveFilters: () => {+ const { filters } = get();- const allNodeTypes = new Set<NodeType>(["file", "function", "class", "module", "concept"]);- const allComplexities = new Set<Complexity>(["simple", "moderate", "complex"]);- const allEdgeCategories = new Set<EdgeCategory>(["structural", "behavioral", "data-flow", "dependencies", "semantic"]);-- const hasNodeTypeFilter = filters.nodeTypes.size !== allNodeTypes.size;- const hasComplexityFilter = filters.complexities.size !== allComplexities.size;- const hasLayerFilter = filters.layerIds.size > 0;- const hasEdgeCategoryFilter = filters.edgeCategories.size !== allEdgeCategories.size;-- return hasNodeTypeFilter || hasComplexityFilter || hasLayerFilter || hasEdgeCategoryFilter;++ return filters.nodeTypes.size !== ALL_NODE_TYPES.length++ || filters.complexities.size !== ALL_COMPLEXITIES.length++ || filters.layerIds.size > 0++ || filters.edgeCategories.size !== ALL_EDGE_CATEGORIES.length;+ },+startTour: () => {const { graph } = get();if (!graph || !graph.tour || graph.tour.length === 0) return;