diff --git a/apps/x/apps/renderer/src/components/graph-view.tsx b/apps/x/apps/renderer/src/components/graph-view.tsx index 049e96ff..a1295406 100644 --- a/apps/x/apps/renderer/src/components/graph-view.tsx +++ b/apps/x/apps/renderer/src/components/graph-view.tsx @@ -71,6 +71,7 @@ export function GraphView({ nodes, edges, isLoading, error, onSelectNode }: Grap const [zoom, setZoom] = useState(1) const [hoveredNodeId, setHoveredNodeId] = useState(null) const [searchQuery, setSearchQuery] = useState('') + const [selectedGroup, setSelectedGroup] = useState(null) const [, forceRender] = useState(0) const edgeList = useMemo( @@ -83,11 +84,12 @@ export function GraphView({ nodes, edges, isLoading, error, onSelectNode }: Grap return map }, [nodes]) const legendItems = useMemo(() => { - const grouped = new Map() + const grouped = new Map() nodes.forEach((node) => { const group = node.group || 'root' if (grouped.has(group)) return grouped.set(group, { + group, label: group === 'root' ? 'knowledge' : group, color: node.color, stroke: node.stroke, @@ -483,16 +485,26 @@ export function GraphView({ nodes, edges, isLoading, error, onSelectNode }: Grap
Folders
-
- {legendItems.map((item) => ( -
- - {item.label} -
- ))} +
+ {legendItems.map((item) => { + const isSelected = selectedGroup === item.group + return ( + + ) + })}
) : null} @@ -532,15 +544,23 @@ export function GraphView({ nodes, edges, isLoading, error, onSelectNode }: Grap const source = displayPositions.get(edge.source) const target = displayPositions.get(edge.target) if (!source || !target) return null + const sourceGroup = nodeGroupMap.get(edge.source) ?? 'root' + const targetGroup = nodeGroupMap.get(edge.target) ?? 'root' const isActiveEdge = activeNodeId ? edge.source === activeNodeId || edge.target === activeNodeId : false const isSearchEdge = searchMatchingNodes ? searchMatchingNodes.matches.has(edge.source) && searchMatchingNodes.matches.has(edge.target) : false + const isGroupEdge = selectedGroup + ? sourceGroup === selectedGroup && targetGroup === selectedGroup + : false let strokeOpacity = 0.4 let strokeWidth = 1 - if (searchMatchingNodes) { + if (selectedGroup) { + strokeOpacity = isGroupEdge ? 0.6 : 0.05 + strokeWidth = isGroupEdge ? 1.5 : 1 + } else if (searchMatchingNodes) { strokeOpacity = isSearchEdge ? 0.6 : 0.05 strokeWidth = isSearchEdge ? 1.5 : 1 } else if (activeNodeId) { @@ -569,12 +589,16 @@ export function GraphView({ nodes, edges, isLoading, error, onSelectNode }: Grap {nodes.map((node) => { const pos = displayPositions.get(node.id) if (!pos) return null + const nodeGroup = node.group || 'root' const isConnected = connectedNodes ? connectedNodes.has(node.id) : true const isSearchMatch = searchMatchingNodes ? searchMatchingNodes.matches.has(node.id) : true const isDirectMatch = searchMatchingNodes ? searchMatchingNodes.directMatches.has(node.id) : false - const isPrimary = activeNodeId === node.id || isDirectMatch + const isGroupMatch = selectedGroup ? nodeGroup === selectedGroup : true + const isPrimary = activeNodeId === node.id || isDirectMatch || (selectedGroup && isGroupMatch) let nodeOpacity = 1 - if (searchMatchingNodes) { + if (selectedGroup) { + nodeOpacity = isGroupMatch ? 1 : 0.1 + } else if (searchMatchingNodes) { if (isDirectMatch) { nodeOpacity = 1 } else if (isSearchMatch) {