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: highlight connected edges on node selection in knowledge view

Lum11041d1585190588
diff --git a/understand-anything-plugin/packages/dashboard/src/components/KnowledgeGraphView.tsx b/understand-anything-plugin/packages/dashboard/src/components/KnowledgeGraphView.tsx
index 1d05f487..f53e5778 100644
--- a/understand-anything-plugin/packages/dashboard/src/components/KnowledgeGraphView.tsx
+++ b/understand-anything-plugin/packages/dashboard/src/components/KnowledgeGraphView.tsx
@@ -195,15 +195,36 @@ function KnowledgeGraphViewInner() {
};
});
+ const activeId = focusNodeId ?? selectedNodeId;
const rfEdges: Edge[] = filteredGraph.edges.map((e) => {
- const style = EDGE_STYLES[e.type] ?? EDGE_STYLES.related;
+ const baseStyle = EDGE_STYLES[e.type] ?? EDGE_STYLES.related;
+ const isConnected = activeId && (e.source === activeId || e.target === activeId);
+
+ // When a node is selected: highlight connected edges, dim the rest
+ let style: React.CSSProperties;
+ if (activeId) {
+ if (isConnected) {
+ style = {
+ ...baseStyle,
+ strokeWidth: Math.max(2, (baseStyle.strokeWidth as number ?? 1) * 1.5),
+ opacity: 1,
+ };
+ } else {
+ style = { ...baseStyle, opacity: 0.04 };
+ }
+ } else {
+ style = baseStyle;
+ }
+
return {
id: `ke-${e.source}-${e.target}-${e.type}`,
source: e.source,
target: e.target,
style,
- animated: e.type === "contradicts",
- label: e.type !== "related" && e.type !== "categorized_under" ? e.type.replace(/_/g, " ") : undefined,
+ animated: e.type === "contradicts" && (!activeId || !!isConnected),
+ label: isConnected && e.type !== "related" && e.type !== "categorized_under"
+ ? e.type.replace(/_/g, " ")
+ : undefined,
labelStyle: { fill: "var(--color-text-muted)", fontSize: 9, opacity: 0.7 },
labelBgStyle: { fill: "var(--color-surface)", fillOpacity: 0.9 },
labelBgPadding: [4, 2] as [number, number],