Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: An error occurs when clicking the virtual root node of the mind map to call the API. (#19731)

balibabub13320e419d3
diff --git a/web/src/components/structure-graph/adapters.tsx b/web/src/components/structure-graph/adapters.tsx
index 5b9bef3d36..816cf2b480 100644
--- a/web/src/components/structure-graph/adapters.tsx
+++ b/web/src/components/structure-graph/adapters.tsx
@@ -370,6 +370,11 @@ export function adaptTimelineToX6Data(template: IStructureGraphTemplate): {
return { nodes, edges };
}
+// G6's mindmap layout requires a single root, so multi-root API data is
+// wrapped under this synthetic node. It is not an entity and carries no
+// chunk payload; clicks on it must not trigger chunk navigation/fetching.
+export const SyntheticMindMapRootId = 'mindmap-root';
+
export function adaptMindMapToIndentedTree(
template: IStructureGraphTemplate,
): TreeData {
@@ -389,7 +394,7 @@ export function adaptMindMapToIndentedTree(
}
return {
- id: 'mindmap-root',
+ id: SyntheticMindMapRootId,
children: g6Roots,
};
}
diff --git a/web/src/components/structure-graph/mindmap-g6-graph/index.tsx b/web/src/components/structure-graph/mindmap-g6-graph/index.tsx
index f3a890c344..a313e003e0 100644
--- a/web/src/components/structure-graph/mindmap-g6-graph/index.tsx
+++ b/web/src/components/structure-graph/mindmap-g6-graph/index.tsx
@@ -19,7 +19,10 @@ import { cn } from '@/lib/utils';
import { Graph, IElementEvent, NodeEvent, treeToGraphData } from '@antv/g6';
import { memo, useEffect, useRef, useState } from 'react';
-import { adaptMindMapToIndentedTree } from '../adapters';
+import {
+ adaptMindMapToIndentedTree,
+ SyntheticMindMapRootId,
+} from '../adapters';
import { type MindMapG6GraphProps, type MindMapNodeValue } from './types';
interface MindMapNodeData {
@@ -109,6 +112,9 @@ function MindMapG6Graph({
const handleNodeClick = (evt: IElementEvent) => {
const nodeId = evt.target.id as string;
+ // The synthetic root only wraps multi-root API data — it is not an
+ // entity, so clicking it must not fire chunk navigation/fetching.
+ if (nodeId === SyntheticMindMapRootId) return;
const nodeData = graph!.getNodeData(nodeId);
const data = nodeData.data as MindMapNodeData | undefined;
if (data?.source_chunk_ids?.length) {