Skip to content

Add rate projection coloring, live countdown, and reset notification - #14

Open
ramonsmits wants to merge 3 commits into
Haletran:mainfrom
ramonsmits:feature/rate-projection-and-countdown
Open

Add rate projection coloring, live countdown, and reset notification#14
ramonsmits wants to merge 3 commits into
Haletran:mainfrom
ramonsmits:feature/rate-projection-and-countdown

Conversation

@ramonsmits

Copy link
Copy Markdown

Summary

Three features that improve usage monitoring:

  • Rate projection coloring — bars now turn yellow/red based on projected utilization at current consumption rate, not just current percentage. If you're at 30% but only 1h into a 5h window, that projects to 150% — red. Previously this would show green.
  • Live countdown timer — "Resets in" labels now update continuously (every minute, switching to every second in the final minute) instead of only on API poll
  • Reset notification with sound — when a window was at 100% and resets, plays a racing-start beep sequence (beep-beep-beep-beeeep) and shows a GNOME notification

Details

Rate projection

  • projected = (utilization / elapsed) * total_window
  • Skips projection when <5% of window has elapsed (not enough data)
  • Applied to both panel bar and dropdown bars
  • Dropdown shows "(proj: 95%)" when warning/critical

Live countdown

  • Stores resets_at from API in instance variables
  • _scheduleCountdownTick() picks the right interval: 60s normally, 1s in final minute
  • Shows seconds in the final minute (e.g. "42s", "2m 15s")

Reset notification

  • Tracks _prevWasLimited state per window
  • Detects when utilization drops from >=100% to <80% (reset occurred)
  • Also triggers on countdown reaching zero if window was limited
  • Sound: 3x 880Hz short beeps + 1x 1320Hz long beep via gst-launch-1.0

Cleanup

  • All new timers properly cleaned up in destroy()
  • Reset-refresh timeout tracked and cancelled on destroy

Test plan

  • Verify bars show projection-based colors (not raw thresholds)
  • Verify countdown labels update in real-time
  • Verify seconds shown in final minute of countdown
  • Verify notification + sound plays on reset (can test by restarting with mock data)
  • Verify clean disable/enable cycle (no timer leaks)

Replace simple threshold-based color logic with rate projection that
calculates whether current usage rate will exhaust the window. Colors
now reflect projected burn rate instead of current utilization:
- Normal (green): projected <= 90%
- Warning (yellow): projected > 90%
- Critical (red): projected > 100%

Panel progress bar is also colored based on projection. Dropdown shows
projected percentage when warning/critical.
Replace static "Resets in Xh Ym" text with a continuously updating
countdown. Updates every 60s when > 1 min remains, switches to
per-second updates for the final minute, shows "Resetting..." when
the timer expires, then triggers a data refresh after 3 seconds.

Also shows seconds in the countdown when under 1 minute remaining.
When a usage window was at 100% and then resets (detected via API
polling or countdown expiry), play an F1-style racing start beep
sequence (3 short 880Hz + 1 long 1320Hz via gst-launch-1.0) and
show a GNOME notification. Tracks previous limited state per window
to detect the transition from limited to available.
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.

1 participant