Update health monitor

This commit is contained in:
MacRimi
2026-02-16 22:53:16 +01:00
parent a1d48a28e9
commit 8004ee48c9
4 changed files with 62 additions and 6 deletions

View File

@@ -105,6 +105,8 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
setError(null)
try {
let newOverallStatus = "OK"
// Use the new combined endpoint for fewer round-trips
const response = await fetch(getApiUrl("/api/health/full"))
if (!response.ok) {
@@ -114,14 +116,17 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
const data = await legacyResponse.json()
setHealthData(data)
setDismissedItems([])
newOverallStatus = data?.overall || "OK"
} else {
const fullData: FullHealthData = await response.json()
setHealthData(fullData.health)
setDismissedItems(fullData.dismissed || [])
newOverallStatus = fullData.health?.overall || "OK"
}
// Emit event with the FRESH data from the response, not the stale state
const event = new CustomEvent("healthStatusUpdated", {
detail: { status: healthData?.overall || "OK" },
detail: { status: newOverallStatus },
})
window.dispatchEvent(event)
} catch (err) {
@@ -129,7 +134,7 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
} finally {
setLoading(false)
}
}, [getApiUrl, healthData?.overall])
}, [getApiUrl])
useEffect(() => {
if (open) {