From 7a5bdac38537aecdced981f55ec8b6f347e3311f Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 18 Jan 2026 16:52:44 +0800 Subject: [PATCH] feat: add uptime display to status header (#329) Show system uptime in the header row with a concise format (e.g., "up 1d 5h"). Simplify title from "Mole Status" to "Status" for better fit. --- cmd/status/metrics_health.go | 3 ++- cmd/status/metrics_health_test.go | 4 ++-- cmd/status/view.go | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/status/metrics_health.go b/cmd/status/metrics_health.go index 0e34828..8a8836a 100644 --- a/cmd/status/metrics_health.go +++ b/cmd/status/metrics_health.go @@ -159,7 +159,8 @@ func formatUptime(secs uint64) string { hours := (secs % 86400) / 3600 mins := (secs % 3600) / 60 if days > 0 { - return fmt.Sprintf("%dd %dh %dm", days, hours, mins) + // Only show days and hours when uptime is over 1 day (skip minutes for brevity) + return fmt.Sprintf("%dd %dh", days, hours) } if hours > 0 { return fmt.Sprintf("%dh %dm", hours, mins) diff --git a/cmd/status/metrics_health_test.go b/cmd/status/metrics_health_test.go index 3bd2497..e9c9205 100644 --- a/cmd/status/metrics_health_test.go +++ b/cmd/status/metrics_health_test.go @@ -52,8 +52,8 @@ func TestFormatUptime(t *testing.T) { if got := formatUptime(3600 + 120); got != "1h 2m" { t.Fatalf("expected \"1h 2m\", got %s", got) } - if got := formatUptime(86400*2 + 3600*3 + 60*5); got != "2d 3h 5m" { - t.Fatalf("expected \"2d 3h 5m\", got %s", got) + if got := formatUptime(86400*2 + 3600*3 + 60*5); got != "2d 3h" { + t.Fatalf("expected \"2d 3h\", got %s", got) } } diff --git a/cmd/status/view.go b/cmd/status/view.go index 2bb4f12..010e11a 100644 --- a/cmd/status/view.go +++ b/cmd/status/view.go @@ -131,7 +131,7 @@ type cardData struct { } func renderHeader(m MetricsSnapshot, errMsg string, animFrame int, termWidth int, catHidden bool) string { - title := titleStyle.Render("Mole Status") + title := titleStyle.Render("Status") scoreStyle := getScoreStyle(m.HealthScore) scoreText := subtleStyle.Render("Health ") + scoreStyle.Render(fmt.Sprintf("● %d", m.HealthScore)) @@ -165,6 +165,9 @@ func renderHeader(m MetricsSnapshot, errMsg string, animFrame int, termWidth int if m.Hardware.OSVersion != "" { infoParts = append(infoParts, m.Hardware.OSVersion) } + if m.Uptime != "" { + infoParts = append(infoParts, subtleStyle.Render("up "+m.Uptime)) + } headerLine := title + " " + scoreText + " " + strings.Join(infoParts, " · ")