Skip to content

feat(status): battery health scoring and uptime warning#663

Merged
tw93 merged 1 commit intotw93:mainfrom
sebastianbreguel:feat/status-health-indicators
Apr 1, 2026
Merged

feat(status): battery health scoring and uptime warning#663
tw93 merged 1 commit intotw93:mainfrom
sebastianbreguel:feat/status-health-indicators

Conversation

@sebastianbreguel
Copy link
Copy Markdown
Contributor

Summary

Adds two health indicators to mo status that surface actionable information already collected but not highlighted:

  • Battery health scoring: The Power card now shows a color-coded health label (Healthy / Fair / Service Soon) based on cycle count (500/900 thresholds) and capacity (90%/80% thresholds). Cycle count text is also color-coded.
  • Uptime warning: Uptime in the header is now color-coded — green for ≤7 days, yellow for 7–14 days, red with ↻ indicator for >14 days suggesting a restart.
  • Both metrics contribute small penalties to the overall health score.

These were discussed in #659 as features that fit naturally inside mo status without creating overlap.

What changed

File Change
metrics.go Added UptimeSeconds field to MetricsSnapshot
metrics_health.go Added battery/uptime thresholds, penalties in health score, batteryHealthLabel() and uptimeSeverity() helpers
metrics_health_test.go 3 new test functions covering label logic, severity, and score penalties
view.go Color-coded uptime in header, health label + colored cycles in Power card

Test plan

  • go build ./cmd/status/ — compiles cleanly
  • go vet ./cmd/status/ — no issues
  • go test ./cmd/status/ — all 55 tests pass
  • JSON output includes uptime_seconds and battery data
  • Visual verification: battery label renders correctly, uptime colors work

- Battery card now shows health label (Healthy/Fair/Service Soon) based
  on cycle count and capacity thresholds, with color-coded cycles
- Uptime in header is color-coded: green ≤7d, yellow 7-14d, red >14d
  with restart indicator
- Both metrics now factor into the overall health score
- Added tests for batteryHealthLabel, uptimeSeverity, and health score
  battery/uptime penalties
@sebastianbreguel sebastianbreguel requested a review from tw93 as a code owner April 1, 2026 03:44
@sebastianbreguel
Copy link
Copy Markdown
Contributor Author

Visual Preview

Power Card — Before vs After

Before (raw data only):

◪ Power  ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
Level  ████████████░░░░  70.0%
Health ████████████████  100%
Discharging · 3h 20m · 8W
Normal · 19 cycles · 42.5°C

After (health label + colored cycles):

◪ Power  ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
Level  ████████████░░░░  70.0%
Health ████████████████  100%
Discharging · 3h 20m · 8W
🟢 Healthy · 19 cycles · 42.5°C

With aging battery (600 cycles, 87% capacity):

◪ Power  ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
Level  ████████████░░░░  72.0%
Health ██████████████░░   87%
Discharging · 2h 45m · 9W
🟡 Fair · 600 cycles · 45.2°C

With worn battery (950 cycles, 74% capacity):

◪ Power  ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
Level  ██████████░░░░░░  65.0%
Health ████████████░░░░   74%
Discharging · 1h 50m · 11W
🔴 Service Soon · 950 cycles · 48.1°C

Header — Uptime Warning

Normal (≤7 days):

Status  Health ● 94  MacBook Pro · Apple M4 Pro · 24GB/460GB · macOS 26.3 · up 1d 4h

Warning (7–14 days, yellow):

Status  Health ● 92  MacBook Pro · Apple M4 Pro · 24GB/460GB · macOS 26.3 · ⚠ up 10d 5h

Danger (>14 days, red + restart indicator):

Status  Health ● 89  MacBook Pro · Apple M4 Pro · 24GB/460GB · macOS 26.3 · 🔴 up 18d 2h ↻

Health Score Impact

Condition Penalty Example
Cycles 500–900 -2 Score 98 → 96
Cycles >900 -5 Score 98 → 93
Capacity 80–90% -2 Score 98 → 96
Capacity <80% -5 Score 98 → 93
Uptime 7–14 days -1 Score 98 → 97
Uptime >14 days -3 Score 98 → 95

@tw93 tw93 merged commit 02eed20 into tw93:main Apr 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants