diff --git a/lightrag_webui/src/components/graph/GraphControl.tsx b/lightrag_webui/src/components/graph/GraphControl.tsx index e4e0a96a..20d6d603 100644 --- a/lightrag_webui/src/components/graph/GraphControl.tsx +++ b/lightrag_webui/src/components/graph/GraphControl.tsx @@ -218,7 +218,7 @@ const GraphControl = ({ disableHoverEffect }: { disableHoverEffect?: boolean }) // Node reducer for node appearance nodeReducer: (node, data) => { const graph = sigma.getGraph() - + // Add defensive check for node existence during theme switching if (!graph.hasNode(node)) { console.warn(`Node ${node} not found in graph during theme switch, returning default data`) @@ -275,7 +275,7 @@ const GraphControl = ({ disableHoverEffect }: { disableHoverEffect?: boolean }) // Edge reducer for edge appearance edgeReducer: (edge, data) => { const graph = sigma.getGraph() - + // Add defensive check for edge existence during theme switching if (!graph.hasEdge(edge)) { console.warn(`Edge ${edge} not found in graph during theme switch, returning default data`) diff --git a/lightrag_webui/src/components/graph/GraphSearch.tsx b/lightrag_webui/src/components/graph/GraphSearch.tsx index d181c6b3..0b7c2577 100644 --- a/lightrag_webui/src/components/graph/GraphSearch.tsx +++ b/lightrag_webui/src/components/graph/GraphSearch.tsx @@ -22,21 +22,21 @@ export interface OptionItem { const NodeOption = ({ id }: { id: string }) => { const graph = useGraphStore.use.sigmaGraph() - + // Early return if no graph or node doesn't exist if (!graph?.hasNode(id)) { return null } - + // Safely get node attributes with fallbacks const label = graph.getNodeAttribute(id, 'label') || id const color = graph.getNodeAttribute(id, 'color') || '#666' const size = graph.getNodeAttribute(id, 'size') || 4 - + // Custom node display component that doesn't rely on @react-sigma/graph-search return (