Skip to content

Add time-until-reset countdown to menu bar#435

Open
guglielmofonda wants to merge 1 commit intosteipete:mainfrom
guglielmofonda:feature/countdown-to-reset
Open

Add time-until-reset countdown to menu bar#435
guglielmofonda wants to merge 1 commit intosteipete:mainfrom
guglielmofonda:feature/countdown-to-reset

Conversation

@guglielmofonda
Copy link

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% · 28m

Settings

New toggle in Settings → Display → Menu bar:

Show time until reset — Display a countdown (e.g. "28m") next to the percentage in the menu bar.

The toggle is disabled/faded when "Menu bar shows percent" is off, since the countdown only appears in text mode.

Countdown format

Time remaining Display
Hours + minutes 2h 5m
Under an hour 28m
Under a minute <1m
Past or unknown (hidden)

Picks the nearest upcoming reset across both the primary and secondary quota windows.

Implementation

  • MenuBarDisplayText.timeUntilResetText() — pure formatter, testable in isolation
  • StatusItemController starts a 60-second Timer when the feature is on, so the label ticks down every minute without waiting for a data refresh; timer is torn down when disabled
  • Persisted via UserDefaults key menuBarShowsTimeUntilReset, default false

Test plan

  • Enable "Menu bar shows percent" + "Show time until reset" → see e.g. 72% · 28m
  • Wait ~1 minute → countdown decrements automatically
  • Disable toggle → only 72% shown
  • Disable "Menu bar shows percent" → countdown toggle is greyed out

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)
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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