diff --git a/lightrag_webui/src/App.tsx b/lightrag_webui/src/App.tsx index 6760375c..55e6268a 100644 --- a/lightrag_webui/src/App.tsx +++ b/lightrag_webui/src/App.tsx @@ -25,6 +25,7 @@ function App() { const [apiKeyAlertOpen, setApiKeyAlertOpen] = useState(false) const [initializing, setInitializing] = useState(true) // Add initializing state const versionCheckRef = useRef(false); // Prevent duplicate calls in Vite dev mode + const healthCheckInitializedRef = useRef(false); // Prevent duplicate health checks in Vite dev mode const handleApiKeyAlertOpenChange = useCallback((open: boolean) => { setApiKeyAlertOpen(open) @@ -70,6 +71,14 @@ function App() { } }; + // On first mount or when enableHealthCheck becomes true and apiKeyAlertOpen is false, + // perform an immediate health check + if (!healthCheckInitializedRef.current) { + healthCheckInitializedRef.current = true; + // Immediate health check on first load + performHealthCheck(); + } + // Set interval for periodic execution const interval = setInterval(performHealthCheck, healthCheckInterval * 1000); return () => clearInterval(interval);