RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix: Switching the document-level graph selector should also update the corresponding total node count. (#19732)
balibabue2d3586cd5bb
diff --git a/web/src/pages/chunk/representation/hooks/use-graph-entity-search.test.ts b/web/src/pages/chunk/representation/hooks/use-graph-entity-search.test.tsindex 3d5963d10a..fb4c3c5d61 100644--- a/web/src/pages/chunk/representation/hooks/use-graph-entity-search.test.ts+++ b/web/src/pages/chunk/representation/hooks/use-graph-entity-search.test.ts@@ -34,7 +34,7 @@ describe('useGraphEntitySearch handleNoMatchEnter', () => {jest.clearAllMocks();});- it('treats Enter on an existing entity name like a dropdown selection: highlight + dim, no keyword refetch', () => {+ it('treats Enter on an existing entity name like a dropdown selection: highlight + keyword refetch', () => {const { result } = setupHook([{ id: 'e1', name: 'swallow' },{ id: 'e2', name: 'owl tree' },@@ -46,8 +46,9 @@ describe('useGraphEntitySearch handleNoMatchEnter', () => {expect(result.current.highlightNodeId).toBe('swallow');expect(result.current.graphSelectValue).toBe('swallow');- // The keyword subgraph refetch must NOT be armed for a name hit.- expect(mockFetchDocumentStructureGraph).toHaveBeenLastCalledWith('');+ // The keyword subgraph refetch is armed with the entity name, so the+ // graph and the entity count refresh from the server.+ expect(mockFetchDocumentStructureGraph).toHaveBeenLastCalledWith('swallow');});it('matches entity names case-insensitively and returns the canonical name', () => {@@ -88,3 +89,41 @@ describe('useGraphEntitySearch handleNoMatchEnter', () => {);});});++describe('useGraphEntitySearch handleSelectEntity', () => {+ beforeEach(() => {+ jest.clearAllMocks();+ });++ it('refetches the keyword subgraph for the picked entity and keeps it highlighted', () => {+ const { result } = setupHook([+ { id: 'e1', name: 'swallow' },+ { id: 'e2', name: 'owl tree' },+ ]);++ act(() => {+ result.current.handleSelectEntity('owl tree');+ });++ expect(result.current.highlightNodeId).toBe('owl tree');+ expect(result.current.graphSelectValue).toBe('owl tree');+ expect(mockFetchDocumentStructureGraph).toHaveBeenLastCalledWith(+ 'owl tree',+ );+ });++ it('clearing the selection refetches the full graph', () => {+ const { result } = setupHook([{ id: 'e1', name: 'swallow' }]);++ act(() => {+ result.current.handleSelectEntity('swallow');+ });+ act(() => {+ result.current.handleSelectEntity('');+ });++ expect(result.current.highlightNodeId).toBeNull();+ expect(result.current.graphSelectValue).toBe('');+ expect(mockFetchDocumentStructureGraph).toHaveBeenLastCalledWith('');+ });+});diff --git a/web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts b/web/src/pages/chunk/representation/hooks/use-graph-entity-search.tsindex de2fa645fb..5356cff247 100644--- a/web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts+++ b/web/src/pages/chunk/representation/hooks/use-graph-entity-search.ts@@ -56,6 +56,9 @@ export function useGraphEntitySearch(? selectedNodeId: '';+ // Picking an option behaves like an Enter search: refetch the server-side+ // keyword subgraph for that entity (fresh graph + entity count) and keep the+ // node highlighted, in addition to the chunk navigation.const handleSelectEntity = useCallback((name: string) => {if (!name) {@@ -65,6 +68,7 @@ export function useGraphEntitySearch(return;}setSelectedNodeId(name);+ setGraphKeywords(name);const entity = (selectedTemplate?.entities ?? []).find((item) => getEntityDisplayName(item) === name,);@@ -82,9 +86,8 @@ export function useGraphEntitySearch(const handleNoMatchEnter = useCallback((keywords: string) => {// Enter on a keyword that exactly names an entity must behave like- // picking it from the dropdown: highlight that node and its neighbors- // and dim the rest. Only unmatched text falls back to the server-side- // keyword subgraph, which renders fully bright.+ // picking it from the dropdown. Only unmatched text falls back to the+ // raw keyword subgraph with no highlighted node.const entityName = findEntityDisplayNameByKeyword(selectedTemplate?.entities ?? [],keywords,