From 6bd9a64fce25421f20a2d5e51304b7c138428af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20MANSUY?= Date: Thu, 4 Dec 2025 19:18:13 +0800 Subject: [PATCH] cherry-pick b1a4e7d7 --- lightrag_webui/src/components/graph/GraphControl.tsx | 8 ++++---- lightrag_webui/src/hooks/useRandomGraph.tsx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lightrag_webui/src/components/graph/GraphControl.tsx b/lightrag_webui/src/components/graph/GraphControl.tsx index 6d040c47..55864789 100644 --- a/lightrag_webui/src/components/graph/GraphControl.tsx +++ b/lightrag_webui/src/components/graph/GraphControl.tsx @@ -43,12 +43,12 @@ const GraphControl = ({ disableHoverEffect }: { disableHoverEffect?: boolean }) const selectedEdge = useGraphStore.use.selectedEdge() const focusedEdge = useGraphStore.use.focusedEdge() const sigmaGraph = useGraphStore.use.sigmaGraph() - + // Track system theme changes when theme is set to 'system' - const [systemThemeIsDark, setSystemThemeIsDark] = useState(() => + const [systemThemeIsDark, setSystemThemeIsDark] = useState(() => window.matchMedia('(prefers-color-scheme: dark)').matches ) - + useEffect(() => { if (theme === 'system') { const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)') @@ -219,7 +219,7 @@ const GraphControl = ({ disableHoverEffect }: { disableHoverEffect?: boolean }) */ useEffect(() => { // Check if dark mode is actually applied (handles both 'dark' theme and 'system' theme when OS is dark) - const isDarkTheme = theme === 'dark' || + const isDarkTheme = theme === 'dark' || (theme === 'system' && window.document.documentElement.classList.contains('dark')) const labelColor = isDarkTheme ? Constants.labelColorDarkTheme : undefined const edgeColor = isDarkTheme ? Constants.edgeColorDarkTheme : undefined diff --git a/lightrag_webui/src/hooks/useRandomGraph.tsx b/lightrag_webui/src/hooks/useRandomGraph.tsx index 6bc0a1a2..2337ccd7 100644 --- a/lightrag_webui/src/hooks/useRandomGraph.tsx +++ b/lightrag_webui/src/hooks/useRandomGraph.tsx @@ -56,7 +56,7 @@ const useRandomGraph = () => { image: faker.image.urlLoremFlickr() }) }) - + // Add edge attributes graph.edges().forEach((edge: string) => { graph.mergeEdgeAttributes(edge, { @@ -65,7 +65,7 @@ const useRandomGraph = () => { color: randomColor() }) }) - + return graph as Graph }, [faker])