Add time-until-reset countdown to menu bar#435
Add time-until-reset countdown to menu bar#435guglielmofonda wants to merge 1 commit intosteipete:mainfrom
Conversation
When "Show time until reset" is enabled in Settings → Display, a compact countdown (e.g. "72% · 28m" or "72% · 2h 5m") appears next to the percentage in the menu bar. It picks the nearest upcoming reset across the primary and secondary quota windows. - MenuBarDisplayText: add timeUntilResetText() formatter - StatusItemController+Animation: append countdown to menuBarDisplayText - StatusItemController: start/stop a 60-second Timer so the label ticks down every minute without waiting for a data refresh - SettingsStoreState / SettingsStore / SettingsStore+Defaults: persist the new `menuBarShowsTimeUntilReset` boolean via UserDefaults - PreferencesDisplayPane: add toggle under "Menu bar shows percent" (disabled + faded when text mode is off, since the countdown is invisible in icon-only mode)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b30fc6fe00
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
| self.updateVisibility() | ||
| self.updateIcons() | ||
| self.updateCountdownTimer() |
There was a problem hiding this comment.
Track countdown toggle in settings observation
This call only runs when observeSettingsChanges() is triggered, but the new menuBarShowsTimeUntilReset flag is not read in SettingsStore.menuObservationToken (Sources/CodexBar/SettingsStore+MenuObservation.swift), so toggling “Show time until reset” at runtime does not immediately execute this path. In that scenario the menu bar text and countdown timer won’t start/stop until some unrelated observed setting changes (or the app restarts), which makes the new toggle appear broken.
Useful? React with 👍 / 👎.
Summary
Adds a time-until-reset countdown directly in the menu bar, so you can see how long until your quota resets without having to click the icon.
Before: click the icon → scroll down to find "Resets in 28m"
After: menu bar already shows
72% · 28mSettings
New toggle in Settings → Display → Menu bar:
The toggle is disabled/faded when "Menu bar shows percent" is off, since the countdown only appears in text mode.
Countdown format
2h 5m28m<1mPicks the nearest upcoming reset across both the primary and secondary quota windows.
Implementation
MenuBarDisplayText.timeUntilResetText()— pure formatter, testable in isolationStatusItemControllerstarts a 60-secondTimerwhen the feature is on, so the label ticks down every minute without waiting for a data refresh; timer is torn down when disabledUserDefaultskeymenuBarShowsTimeUntilReset, defaultfalseTest plan
72% · 28m72%shown