diff --git a/lightrag_webui/src/components/graph/GraphLabels.tsx b/lightrag_webui/src/components/graph/GraphLabels.tsx index fdd06c56..7fe26cf5 100644 --- a/lightrag_webui/src/components/graph/GraphLabels.tsx +++ b/lightrag_webui/src/components/graph/GraphLabels.tsx @@ -93,9 +93,25 @@ const GraphLabels = () => { ) const handleRefresh = useCallback(() => { - // Re-set the same label to trigger a refresh through useEffect - const currentLabel = useSettingsStore.getState().queryLabel - useSettingsStore.getState().setQueryLabel(currentLabel) + // Reset labels fetch status to allow fetching labels again + useGraphStore.getState().setLabelsFetchAttempted(false) + + // Reset graph data fetch status directly, not depending on allDatabaseLabels changes + useGraphStore.getState().setGraphDataFetchAttempted(false) + + // Fetch all labels again + useGraphStore.getState().fetchAllDatabaseLabels() + .then(() => { + // Trigger a graph data reload by changing the query label back and forth + const currentLabel = useSettingsStore.getState().queryLabel + useSettingsStore.getState().setQueryLabel('') + setTimeout(() => { + useSettingsStore.getState().setQueryLabel(currentLabel) + }, 0) + }) + .catch((error) => { + console.error('Failed to refresh labels:', error) + }) }, []) return ( diff --git a/lightrag_webui/src/hooks/useLightragGraph.tsx b/lightrag_webui/src/hooks/useLightragGraph.tsx index da61ab2c..f83d396d 100644 --- a/lightrag_webui/src/hooks/useLightragGraph.tsx +++ b/lightrag_webui/src/hooks/useLightragGraph.tsx @@ -229,7 +229,7 @@ const useLightrangeGraph = () => { return } - // Only fetch data when graphDataFetchAttempted is false + // Only fetch data when graphDataFetchAttempted is false (avoids re-fetching on vite dev mode) if (!isFetching && !useGraphStore.getState().graphDataFetchAttempted) { // Set flags fetchInProgressRef.current = true