Do health check on page initial load

This commit is contained in:
yangdx
2025-04-15 18:03:21 +08:00
parent ce0aeaf9b4
commit 70019979c1

View File

@@ -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);