feat: add an estimated time to depletion (ETD) indicator#38
Open
carlosresu wants to merge 12 commits into
Open
feat: add an estimated time to depletion (ETD) indicator#38carlosresu wants to merge 12 commits into
carlosresu wants to merge 12 commits into
Conversation
Revert shared window.rs draw/width signatures to base; read show_etd via a state-lock accessor and share a lock-free text-width slot mechanism with the detailed-remaining feature (identical block, distinct per-feature wiring). Place ETD's struct fields, menu ID, and Settings menu item at anchors that are non-adjacent to the other display features so any merge subset is conflict-free. Keeps poller's format_countdown_from_secs at its base 2-arg signature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in Estimated Time to Depletion (ETD) indicator that tells you how long until a quota runs out at your current pace, so you can see at a glance whether you are about to hit the limit before the window resets. Inspired by issue #21.
When a usage bar is on pace to deplete before its window resets, the cell appends the estimate after the remaining time:
remlabel and the estimate follows as… ETD, e.g.90% · 1d rem · 13h ETD— about a day until the weekly window resets, but at the current burn rate you would run out in ~13h.resets_attimestamp and the fixed window length (5h / 7d):etd = (100 - used%) / (used% / elapsed). It is shown only when the projected depletion lands before the reset — i.e. exactly when you are over pace. Cells pacing safely show nothing extra.The indicator is off by default. State persists to
settings.jsonvia a#[serde(default)] show_etdfield, so existing settings files migrate cleanly.Screenshots
Same usage data with Show ETD enabled — the 5h session is pacing safely (no suffix), while the 7d weekly is over pace and shows the estimate.
Settings control
A single right-click Settings → Show ETD checkbox toggles it. The checkmark reflects the current state; toggling repaints live and persists immediately.
Layout
When ETD is on, the text column widens (
TEXT_WIDTH 62→ETD_TEXT_WIDTH 160) so the worst-case100% · 59m rem · 59m ETDis never clipped. The width is threaded through both the layout calc and the draw clip rect so they stay in agreement; when ETD is off the widget renders exactly as before.Localization
Show ETD, theETDlabel, and theremlabel are present in all 10 supported locales (a missing field is a compile error).Tests
This change adds the repository's first unit tests (
#[cfg(test)]inpoller.rsandwindow.rs), 9 in total:Someiffused% > 100·elapsed/window).etd_suffixformatting: present when at-risk, absent when safe, absent without a reset timestamp.Commits
feat: add ETD projection math with unit testsfeat: add ETD localization stringsfeat: add ETD suffix formatterfeat: persist show_etd settingfeat: add Show ETD toggle and wire ETD into usage cellsfix: widen usage cells when ETD is shown so the suffix is not clippedfeat: label remaining time with 'rem' in ETD mode and widen column to fitdocs: document the ETD indicatorTest plan
cargo test— 9/9 passing, output pristinecargo buildclean, no warnings· <rem> rem · <etd> ETDand a safe cell stays baresettings.json