Add reset warnings for unused credits approaching window reset#619
Add reset warnings for unused credits approaching window reset#6190-CYBERDYNE-SYSTEMS-0 wants to merge 1 commit intosteipete:mainfrom
Conversation
Notifies users via macOS notification when a usage window (session or weekly) is about to reset and they still have significant capacity remaining (>=20%). This helps users plan long-running tasks to use credits before they expire. - Configurable warning advance time (1-48 hours, default 8h) - Menu card banner with amber styling when warning is active - 1-hour notification cooldown to avoid spam - Applies to all enabled providers with reset time data - Settings toggle in Preferences > General > Automation New files: - ResetWarningState.swift: evaluation logic + dedup - ResetWarningTests.swift: 11 Swift Testing cases
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c312f4b6f7
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let warning = ResetWarningEvaluator.evaluate( | ||
| provider: provider, | ||
| window: primary, | ||
| windowKind: .session, |
There was a problem hiding this comment.
Use provider-specific window kinds for reset warnings
This hard-codes the primary window as .session (and secondary as .weekly a few lines below), but several providers do not map their windows that way. For example, Kimi’s primary is weekly quota and secondary is a 5-hour rate-limit window, so warnings/notifications end up mislabeled and can notify on the wrong semantic lane. That makes the new warning text inaccurate for those providers and can confuse users about what is actually resetting.
Useful? React with 👍 / 👎.
| await self.refreshCreditsIfNeeded(minimumSnapshotUpdatedAt: refreshStartedAt) | ||
| } | ||
|
|
||
| self.checkResetWarnings() |
There was a problem hiding this comment.
Recompute reset warnings when warning settings change
Reset warnings are only recalculated inside the refresh path here, but the new settings (resetWarningEnabled / resetWarningHours) are not observed in UsageStore.observeSettingsChanges. As a result, changing those preferences does not immediately clear/re-evaluate activeResetWarnings; in Manual refresh mode, stale warning banners can remain indefinitely until the user triggers a refresh.
Useful? React with 👍 / 👎.
Summary
Notifies users when a usage window (session or weekly) is about to reset and they still have significant capacity remaining. This helps plan long-running tasks to use credits before they expire.
How it works
RateWindowentries. A warning triggers whenremainingPercent >= 20%ANDresetsAtis within the configured advance time (default 8 hours).Settings
Files changed
CodexBarCore/ResetWarningState.swiftResetWarningmodel +ResetWarningEvaluatorlogicUsageStore.swiftSessionQuotaNotifications.swiftpostResetWarningMenuCardView.swiftPreferencesGeneralPane.swiftSettingsStore*(3 files)StatusItemController+Menu.swiftPreferencesProvidersPane.swiftResetWarningTests.swiftOpen questions for maintainer
Testing
Built and verified on macOS arm64. SwiftFormat passes clean. Unit tests cover boundary conditions, cooldown logic, and edge cases (nil reset time, past reset, low remaining).