From 52c85b11b8e5e7de8529542199fa506c1d2b2729 Mon Sep 17 00:00:00 2001 From: Tyler Koenig Date: Sat, 16 May 2026 14:58:34 -0400 Subject: [PATCH] fix(tui): compute uptime from windowed statuses, not running counters --- internal/tui/tab_sites.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/tui/tab_sites.go b/internal/tui/tab_sites.go index 26816cb..6f7df4c 100644 --- a/internal/tui/tab_sites.go +++ b/internal/tui/tab_sites.go @@ -152,11 +152,17 @@ func fmtLatency(d time.Duration) string { return dangerStyle.Render(s) } -func fmtUptime(total, up int) string { - if total == 0 { +func fmtUptime(statuses []bool) string { + if len(statuses) == 0 { return subtleStyle.Render("—") } - pct := float64(up) / float64(total) * 100 + up := 0 + for _, s := range statuses { + if s { + up++ + } + } + pct := float64(up) / float64(len(statuses)) * 100 s := fmt.Sprintf("%.1f%%", pct) if pct >= 99 { return specialStyle.Render(s) @@ -309,7 +315,7 @@ func (m Model) viewSitesTab() string { typeIcon(site.Type, false) + " " + site.Type, fmtStatus(site.Status, site.Paused), fmtLatency(site.Latency), - fmtUptime(hist.TotalChecks, hist.UpChecks), + fmtUptime(hist.Statuses), spark, fmtSSL(site), fmtRetries(site), @@ -631,7 +637,7 @@ func (m Model) viewDetailPanel() string { row("Interval", fmt.Sprintf("%ds", site.Interval)) row("Timeout", fmt.Sprintf("%ds", site.Timeout)) row("Latency", fmtLatency(site.Latency)) - row("Uptime", fmtUptime(hist.TotalChecks, hist.UpChecks)) + row("Uptime", fmtUptime(hist.Statuses)) if site.Type == "http" { row("Method", site.Method)