menubar: drop the early-reset dock band and history caption (#1452)
Some checks are pending
CI / semgrep (push) Waiting to run
macOS Menubar CI / test (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run

* fix(menubar): drop the early-reset dock band and history caption

* menubar: drop stale band references left by the caption removal
This commit is contained in:
Resham Joshi 2026-09-16 11:29:38 +02:00 • committed by GitHub
parent 47b7441dd6
commit 31bd0ff2cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 17 additions and 478 deletions

View file

@ -12,7 +12,7 @@
- **Launching the menubar app replaces the copy already running instead of stacking a second Capacity Dock on the screen edge.** At launch it terminates only *strictly older* instances of its own bundle identifier, so two simultaneous launches cannot quit each other and leave none, and an older copy that ignores the polite quit is forced out a few seconds later.
- **The menubar tells you when a quota window crosses 80% and again when it hits its limit.** Every connected provider's windows — the same list the menu-bar flame and the popover warning row are built from — are checked on the quota refresh that already runs, with no new polling: crossing 80% posts `Claude · Weekly at 80%`, reaching the limit posts `Claude · Weekly limit reached`. Each fires once per window per cycle, a window that hits its limit without ever having been seen at 80% posts only the limit notice, and the cycle's reset instant is part of the identity, so the next cycle re-arms both while an absent or failed fetch keeps what was already announced. The fired set is persisted, so a relaunch does not repeat a crossing. Notification authorization is requested on the first real crossing and never at launch. Settings → Notifications gains a switch, on by default.
- **The macOS menubar app speaks Simplified Chinese, and follows your system language to decide.** Every user-facing string in the popover, the Capacity Dock, the status-item menu, the update alerts and all of Settings now resolves through a `Localizable.strings` catalog shipped for `en` and `zh-Hans` with no third-party library: 628 keys, whose key *is* the English copy, so an untranslated string degrades to correct English rather than a visible identifier. AppKit picks the table from the user's preferred languages; Settings > General > Language overrides it for CodeBurn alone by writing `AppleLanguages` into the app's own preferences domain, which is the same key `CFBundleLocalizations` makes System Settings > Language & Region > Applications write, so the two surfaces are one setting rather than two. Enum raw values that double as persistence or cache keys (`Period`, `MenubarScope`, `InsightMode`, `AccentPreset`, `ProviderFilter`) keep their raw value and gained a separate display label, so nothing a user has saved changes meaning. Three display-only date formatters that were pinned to `en_US_POSIX` with fixed patterns now follow the locale, and the calendar popover's weekday row comes from the locale's own short symbols clipped to two units, so a Chinese UI reads `2026年9月` and `周一 周二` while English keeps `Mo Tu We`. That locale move is the one place English output changes: `EEE MMM d` reads `Sat, Sep 12` in en_US and `Sat 12 Sep` in en_GB, and `MMM d` reads `12 Sep` in en_GB. Provider, model and plan names, units, currency codes, shell commands and anything the `codeburn` CLI itself produces stay verbatim in every locale. Adding a language is now one more `.lproj`; a test fails the build if the two tables disagree on keys, leave a value blank, or disagree on format specifiers, and a second test reads `mac/Sources` itself and fails when a user-facing literal never reaches the catalog at all — the drift a catalog-versus-catalog diff cannot see, because both tables stay in perfect agreement while a bare `Text("…")` ships English to a zh-Hans user. This covers the menubar half of #1219 only, not the CLI output or the web dashboard. (#1219)
- **The menubar tells you when a vendor resets your quota early, and what that provider's early resets have looked like.** Vendors sometimes reset a usage window ahead of schedule as a goodwill gesture; CodeBurn showed the new percentage but never said it had happened, so the free capacity went unused. Two signals now catch it on the refresh lifecycle that already runs, with no new polling: a reset time that jumps to a new cycle while the stored one still had time to run, and usage emptying (a fall of at least 40 points landing at or under 10%) while the advertised reset time stands still. A system notification through the existing notifier names the provider, the window and the lead, worded for the signal that saw it ("Claude's weekly limit reset 18h early. You're back to 100%." when the cycle rolled over, "Claude cleared your weekly usage 18h before its reset. You're back to 100%." when the counter emptied but the reset time held), the Capacity Dock carries a band saying the same for twelve hours, and the quota hover card gains this Mac's own pattern from the 30 days of snapshots already on disk ("Last 3 weekly resets came ~18h early"), derived from the stored reset times with no network and no external feed. One goodwill reset is one notification per provider however many windows it empties, and a reset already announced is never announced again — after a relaunch, or when the vendor briefly serves the old cycle back. It stays silent on a normal scheduled reset, a plan change, clock or timestamp skew, a window appearing or disappearing between fetches, a window's first observation, a reconnect after a terminal failure or a fresh bootstrap, and a window whose length the adapter does not validate; a missing or malformed stored reading is no opinion rather than an event. Settings → General → Notifications turns the notification off, default on, and with it off the dock band still appears. Claude is the provider wired up today, because it is the one whose quota readings are persisted. (#725)
- **The menubar tells you when a vendor resets your quota early.** Vendors sometimes reset a usage window ahead of schedule as a goodwill gesture; CodeBurn showed the new percentage but never said it had happened, so the free capacity went unused. Two signals now catch it on the refresh lifecycle that already runs, with no new polling: a reset time that jumps to a new cycle while the stored one still had time to run, and usage emptying (a fall of at least 40 points landing at or under 10%) while the advertised reset time stands still. A system notification through the existing notifier names the provider, the window and the lead, worded for the signal that saw it ("Claude's weekly limit reset 18h early. You're back to 100%." when the cycle rolled over, "Claude cleared your weekly usage 18h before its reset. You're back to 100%." when the counter emptied but the reset time held). One goodwill reset is one notification per provider however many windows it empties, and a reset already announced is never announced again — after a relaunch, or when the vendor briefly serves the old cycle back. It stays silent on a normal scheduled reset, a plan change, clock or timestamp skew, a window appearing or disappearing between fetches, a window's first observation, a reconnect after a terminal failure or a fresh bootstrap, and a window whose length the adapter does not validate; a missing or malformed stored reading is no opinion rather than an event. Settings → General → Notifications turns the notification off, default on. Claude is the provider wired up today, because it is the one whose quota readings are persisted. (#725)
- **The Capacity Dock shows today's cache-read tokens and tells you whether each quota window will last to its reset.** The Today section gains a provider-scoped cache-read figure beside input, output and calls; a known zero prints as `0` while missing or incomplete historical accounting stays unknown rather than becoming a fabricated zero, and because cache reads were already priced into the burned figure this adds visibility without changing any total. Each quota window then gets one line under it: `Lasts until reset`, `Runs out in 2d 8h`, or — on windows of six hours or less, where one burst would make a linear ETA cry wolf — the pace stage the Plan tab uses (`On pace`, `40% in deficit`, `30% in reserve`). The same line appears under each bar in the agent-tab quota hover card. The projection runs against the window length the provider adapter reports, never a length guessed from the display label, so a monthly cycle whose label happens to read `Weekly` is still paced against its month; it stays silent early in a window, on an exhausted window, without a reset time or a validated duration, and on stale, disconnected or older-than-ten-minute data. Four quota windows move to a two-column grid so scope labels, reset times and captions stay readable, and the dock reserves the caption's height whether or not a column has one so the bubble cannot resize under the pointer. Status snapshot revision 7 invalidates older cached payloads without purging daily history, and no extra polling is introduced. (#1267)
- **The macOS menubar item can show a second line.** Settings → General → Display gains a "Second row" switch, off by default, and a picker for what that line shows: quota remaining with its reset countdown for whichever connected provider is nearest its limit, today's all-provider cost, today's total tokens, or the number of running sessions. Both lines render as one attributed title at 9pt with their line height clamped to 10pt, so the pair fits the standard 22pt menu bar, and the second line hides itself whenever its metric has no data yet, leaving the existing single-row figure exactly as it was. This is a deliberately small first slice of the multi-row layout request: no layout editor, no presets, no live preview, no per-item provider or period scoping. The setting persists as `CodeBurnMenubarSecondRowEnabled` and `CodeBurnMenubarSecondRowMetric` in the app's own defaults domain alongside the existing menubar period, scope and metric keys. (#1252)
- **The Capacity Dock gauge can report the short usage window instead of the weekly one, without expanding the dock.** The resting rail shows one number per provider, and that number was always the weekly (else monthly) billing window. Clicking the provider already resting in the rail now switches its gauge to the provider's short rolling window — Claude's 5-hour limit, Codex's 5-hour or daily window, any `Hourly`, `Daily` or session row an adapter reports — and clicking again switches back. The choice is stored per provider under `CodeBurnCapacityDockGlanceWindows`, so Claude can sit on its 5-hour window while Codex stays weekly, and it survives relaunch. A per-model row such as `Weekly · Opus` is never read as a short window, a provider that reports only one window keeps the plain click-to-pin behaviour, and a stored horizon the provider stops reporting falls back to the window it does report rather than blanking the gauge to `--`. The rail's geometry is untouched, VoiceOver and keyboard users get the switch as a named action on the provider cell with the window named in the cell's value, and Escape or a click outside still unpins the dock. (#1243)

View file

@ -220,8 +220,8 @@ Add a `Capacity Dock` section to General Settings:
- `Appearance` menu with `Graphite` and `Liquid Glass`.
- Early-reset notifications are a switch in the General Settings
`Notifications` section, default on, stored under
`codeburn.quota.earlyResetNotificationsEnabled`. With it off the dock band
still appears; only the system notification is withheld.
`codeburn.quota.earlyResetNotificationsEnabled`. With it off the system
notification is withheld.
- A compact switch list containing only connected or usable stale providers.
Provider connection and credential entry remains in the Providers section;
General Settings never presents the entire 69-provider catalog as dock

View file

@ -67,20 +67,15 @@ Anthropic sometimes resets a usage window before its scheduled time. The menubar
notices on the existing refresh lifecycle — no extra request — by comparing each
fetch's windows against the previous fetch's readings, which are kept per window
in `UserDefaults` alongside the record of what has already been announced.
`SubscriptionSnapshotStore`'s 30 days of snapshots then give the local history
caption ("Last 3 weekly resets came ~18h early"), derived from the stored reset
times alone: a fixed window that starts at `t` ends at `t + length`, so a cycle
that ends sooner than a full window after the previous cycle's scheduled end
began early by the difference. Everything is local; nothing is fetched to
produce it.
Everything is local; nothing is fetched to produce it. A detected reset posts one
system notification and nothing else: there is no persistent UI for it.
The detection is deliberately quiet. It needs a validated window length (the
fixed 5-hour and 7-day limits), a stored reset that has not yet passed, and
either a reset time anchored to a genuinely new cycle or a fall of at least 40
points that lands at or under 10%. A scheduled reset, a plan change, clock or
timestamp skew, a window appearing or disappearing, a first observation and a
reconnect after a terminal failure all produce nothing. Short windows get no
history summary, the same discipline `QuotaPace` applies to its ETA.
reconnect after a terminal failure all produce nothing.
## When fixing a bug here

View file

@ -175,12 +175,6 @@ final class AppStore {
var subscriptionError: String?
var subscriptionLoadState: SubscriptionLoadState = ClaudeCredentialStore.isBootstrapCompleted ? .dormant : .notBootstrapped
var capacityEstimates: [String: CapacityEstimate] = [:]
/// Early quota resets seen for each provider, keyed by dock provider id, and
/// this Mac's own record of how early past resets landed. Both are derived
/// from data already on disk on the existing refresh lifecycle — no polling
/// of its own, no network (#725).
var earlyResetEvents: [String: EarlyQuotaResetEvent] = [:]
var earlyResetHistory: [EarlyQuotaResetHistory.Summary] = []
@ObservationIgnored var earlyQuotaResetMonitor = EarlyQuotaResetMonitor()
@ObservationIgnored var quotaCrossingMonitor = QuotaCrossingMonitor()
@ -1624,8 +1618,6 @@ final class AppStore {
subscriptionError = nil
subscriptionLoadState = .notBootstrapped
capacityEstimates = [:]
earlyResetEvents[CapacityDockProvider.claude.rawValue] = nil
earlyResetHistory = []
earlyQuotaResetMonitor.forget(providerID: CapacityDockProvider.claude.rawValue)
Task.detached { await SubscriptionSnapshotStore.clearAll() }
// Notify the AppDelegate to clear its cadence-loop anchor so the next
@ -2142,22 +2134,6 @@ final class AppStore {
return cleaned
}
/// The early-reset band for one dock provider, while it is still recent.
func capacityDockEarlyResetNotice(
for provider: CapacityDockProvider,
now: Date = Date()
) -> EarlyQuotaResetEvent? {
guard let event = earlyResetEvents[provider.rawValue] else { return nil }
return EarlyQuotaResetNotice.isVisible(event, now: now) ? event : nil
}
/// This Mac's own early-reset pattern for the provider's windows, for the
/// quota hover card. Only Claude persists the snapshots this is derived from.
func earlyResetHistoryCaptions(for filter: ProviderFilter) -> [String] {
guard filter == .claude else { return [] }
return earlyResetHistory.map(\.caption)
}
/// Snapshot of live quota state for a given provider. Returns nil when the user
/// has not connected yet — the bar slot stays empty so we never trigger a
/// source-owned Keychain prompt at startup. Once bootstrapped, the bar persists across all
@ -2911,7 +2887,6 @@ final class AppStore {
}
await refreshCapacityEstimates()
await refreshEarlyResetHistory()
}
/// Hand this fetch's windows to the early-reset monitor, which compares them
@ -2944,10 +2919,6 @@ final class AppStore {
observations: observations,
now: now
)
earlyResetEvents[provider.rawValue] = earlyQuotaResetMonitor.visibleEvent(
providerID: provider.rawValue,
now: now
)
}
/// Claude's rate-limit windows are fixed lengths, the same durations the
@ -2960,24 +2931,6 @@ final class AppStore {
}
}
/// Re-derive the "past resets came this early" captions from the snapshots
/// already on disk. Local only: no network, no external feed.
private func refreshEarlyResetHistory() async {
var summaries: [EarlyQuotaResetHistory.Summary] = []
for key in ["seven_day", "seven_day_opus", "seven_day_sonnet"] {
let snapshots = await SubscriptionSnapshotStore.snapshots(for: key)
if let summary = EarlyQuotaResetHistory.summarize(
snapshots: snapshots,
windowKey: key,
windowName: EarlyQuotaResetFormat.claudeWindowName(forKey: key),
windowSeconds: Self.claudeWindowSeconds(forKey: key)
) {
summaries.append(summary)
}
}
earlyResetHistory = summaries
}
/// Sum effective tokens (input + 5*output + cache_creation + 0.1*cache_read) across the
/// last 7 days of dailyHistory. Used as the "tokens consumed in 7-day window" reading paired
/// with the API-reported percent for capacity estimation.

View file

@ -144,8 +144,7 @@ final class CapacityDockController {
sessionCount: store.capacityDockLiveSessions(for: provider)?.count,
hasToday: store.capacityDockToday(for: provider) != nil,
tailEdge: model.detailTailEdge,
scale: model.detailScale,
hasEarlyResetNotice: store.capacityDockEarlyResetNotice(for: provider) != nil
scale: model.detailScale
)
}

View file

@ -85,42 +85,6 @@ struct EarlyQuotaResetEvent: Codable, Equatable, Sendable {
)
}
}
/// The Capacity Dock band, e.g. "Weekly limit reset 18h early".
var noticeText: String {
let lead = EarlyQuotaResetFormat.lead(seconds: earlyBySeconds)
switch signal {
case .resetMovedForward:
return L(
"%1$@ reset %2$@ early",
EarlyQuotaResetFormat.capitalizedFirst(EarlyQuotaResetFormat.limitName(windowName)),
lead
)
case .usageDropped:
let usage = EarlyQuotaResetFormat.usageName(windowName)
return L("%1$@ cleared, %2$@ before reset", EarlyQuotaResetFormat.capitalizedFirst(usage), lead)
}
}
var noticeHelpText: String {
let lead = EarlyQuotaResetFormat.lead(seconds: earlyBySeconds)
let available = L(
"%lld%% of it was available when CodeBurn noticed.",
Int((100 - percentAfter).rounded())
)
switch signal {
case .resetMovedForward:
return L(
"%1$@ reset this %2$@ %3$@ before its scheduled time. %4$@",
providerName, EarlyQuotaResetFormat.limitName(windowName), lead, available
)
case .usageDropped:
return L(
"%1$@ cleared this %2$@ %3$@ before the window's scheduled reset, which has not moved. %4$@",
providerName, EarlyQuotaResetFormat.usageName(windowName), lead, available
)
}
}
}
/// Decides whether two consecutive readings of the same window are an early
@ -238,118 +202,7 @@ enum EarlyQuotaResetDetector {
}
}
/// How long the Capacity Dock keeps an early-reset band on screen.
enum EarlyQuotaResetNotice {
static let visibleSeconds: TimeInterval = 12 * 3600
static func isVisible(_ event: EarlyQuotaResetEvent, now: Date) -> Bool {
let age = now.timeIntervalSince(event.detectedAt)
// A detection stamped in the future is skew, not a fresh event.
guard age.isFinite, age >= -EarlyQuotaResetDetector.skewTolerance else { return false }
return age <= visibleSeconds
}
}
/// A user's own record of early resets for one window, derived from the
/// 30 days of snapshots already on disk. Local only.
enum EarlyQuotaResetHistory {
/// Leads shorter than this are not claimed as a pattern: window starts are
/// rounded by vendors, so a sub-hour gap is not evidence of anything.
static let minimumLeadSeconds: TimeInterval = 60 * 60
struct Summary: Equatable, Sendable {
let windowKey: String
let windowName: String
/// Consecutive cycle transitions the store can see for this window.
let observedResets: Int
let earlyResets: Int
/// Median lead across the early resets.
let typicalEarlyBySeconds: TimeInterval
/// Hover-card caption, e.g. "Last 3 weekly resets came ~18h early".
var caption: String {
let noun = EarlyQuotaResetFormat.windowNoun(windowName)
let lead = EarlyQuotaResetFormat.approximateLead(seconds: typicalEarlyBySeconds)
if earlyResets == 1 && observedResets == 1 {
return L("Last %1$@ reset came ~%2$@ early", noun, lead)
}
if earlyResets == observedResets {
return L("Last %1$lld %2$@ resets came ~%3$@ early", earlyResets, noun, lead)
}
return L(
"%1$lld of the last %2$lld %3$@ resets came ~%4$@ early",
earlyResets, observedResets, noun, lead
)
}
}
/// The store keeps one entry per window cycle holding the cycle's highest
/// reading, so the moment a new cycle was first seen is not recoverable from
/// `capturedAt`. The reset times are: a fixed window that starts at moment t
/// resets at t + window, so a cycle that followed an early reset ends sooner
/// than a full window after the previous cycle's scheduled end. The lead is
/// `previous.resetsAt + window - next.resetsAt`.
///
/// Short windows (at or under `QuotaPace.etaSuppressionMaxSeconds`) get no
/// summary, for the same reason they get no pace ETA: rounding of their start
/// times is a large share of the window.
static func summarize(
snapshots: [SubscriptionSnapshot],
windowKey: String,
windowName: String,
windowSeconds: Int?
) -> Summary? {
guard let seconds = windowSeconds, seconds > 0 else { return nil }
let window = TimeInterval(seconds)
guard window > QuotaPace.etaSuppressionMaxSeconds else { return nil }
let resets = snapshots
.filter { $0.windowKey == windowKey }
.map(\.resetsAt)
.filter { $0.timeIntervalSince1970.isFinite }
.sorted()
// Jittered timestamps of one cycle collapse to that cycle's latest.
var cycles: [Date] = []
for reset in resets {
if let last = cycles.last,
reset.timeIntervalSince(last) < EarlyQuotaResetDetector.skewTolerance {
cycles[cycles.count - 1] = reset
} else {
cycles.append(reset)
}
}
guard cycles.count >= 2 else { return nil }
var observed = 0
var leads: [TimeInterval] = []
for (earlier, later) in zip(cycles, cycles.dropFirst()) {
let gap = later.timeIntervalSince(earlier)
// A gap longer than a window means cycles went unobserved (app closed,
// idle between short windows); that pair says nothing about timing.
guard gap <= window + EarlyQuotaResetDetector.cycleAnchorTolerance else { continue }
observed += 1
let lead = window - gap
if lead >= minimumLeadSeconds { leads.append(lead) }
}
guard !leads.isEmpty else { return nil }
return Summary(
windowKey: windowKey,
windowName: windowName,
observedResets: observed,
earlyResets: leads.count,
typicalEarlyBySeconds: median(leads)
)
}
private static func median(_ values: [TimeInterval]) -> TimeInterval {
let sorted = values.sorted()
let mid = sorted.count / 2
return sorted.count % 2 == 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid]
}
}
/// Window names and lead formatting shared by the notification, the dock band
/// and the history caption.
/// Window names and lead formatting for the notification.
enum EarlyQuotaResetFormat {
/// Copy names for the Claude windows the snapshot store records.
static func claudeWindowName(forKey key: String) -> String {
@ -373,13 +226,6 @@ enum EarlyQuotaResetFormat {
return rest == 0 ? L("%lldd", hours / 24) : L("%1$lldd %2$lldh", hours / 24, rest)
}
/// "18h", "2d" — rounded, for a pattern that is only ever approximate.
static func approximateLead(seconds: TimeInterval) -> String {
let hours = Int((max(0, seconds) / 3600).rounded())
if hours >= 48 { return L("%lldd", Int((seconds / 86400).rounded())) }
return L("%lldh", max(hours, 1))
}
/// The three grammatical forms the copy needs from a window label.
///
/// `EarlyQuotaResetEvent.windowName` is persisted with the event, so it
@ -421,9 +267,4 @@ enum EarlyQuotaResetFormat {
default: L("%@ usage", windowNoun(name))
}
}
static func capitalizedFirst(_ text: String) -> String {
guard let first = text.first else { return text }
return first.uppercased() + text.dropFirst()
}
}

View file

@ -16,8 +16,7 @@ import Foundation
/// - the scheduled reset time of every announcement already made, matched with
/// the detector's own skew tolerance, so a vendor that briefly serves the old
/// cycle again — possibly from a replica whose timestamp differs by a minute
/// or two — cannot announce the same reset twice, across relaunches included;
/// - the latest event, for the Capacity Dock band.
/// or two — cannot announce the same reset twice, across relaunches included.
@MainActor
final class EarlyQuotaResetMonitor {
struct Observation: Equatable {
@ -33,7 +32,6 @@ final class EarlyQuotaResetMonitor {
var windows: [String: EarlyQuotaResetReading]
/// Scheduled reset times already announced, per window key.
var announced: [String: [Date]]
var latestEvent: EarlyQuotaResetEvent?
}
/// Announcements older than the snapshot store's horizon are dropped.
@ -110,25 +108,18 @@ final class EarlyQuotaResetMonitor {
windows: windows,
announced: announced
.mapValues { $0.filter { $0 >= cutoff } }
.filter { !$0.value.isEmpty },
latestEvent: headline ?? stored?.latestEvent
.filter { !$0.value.isEmpty }
),
providerID: providerID
)
guard let headline else { return nil }
// Persisted before delivery: an event is one-shot even when the user has
// notifications off or denied, and the dock band still shows it.
// notifications off or denied.
await post(headline)
return headline
}
/// The latest announced event for the dock band, while it is still recent.
func visibleEvent(providerID: String, now: Date = Date()) -> EarlyQuotaResetEvent? {
guard let event = loadState(providerID: providerID)?.latestEvent else { return nil }
return EarlyQuotaResetNotice.isVisible(event, now: now) ? event : nil
}
/// Called on user disconnect so a reconnect, possibly to another account,
/// starts without a baseline.
func forget(providerID: String) {

View file

@ -646,8 +646,7 @@
"Notify me when Codex banks a limit reset" = "Notify me when Codex banks a limit reset";
"OpenAI sometimes grants Codex accounts a credit that resets a rate-limit window early. CodeBurn reads these from the quota response it already fetches and tells you once per grant. It never spends one." = "OpenAI sometimes grants Codex accounts a credit that resets a rate-limit window early. CodeBurn reads these from the quota response it already fetches and tells you once per grant. It never spends one.";
"Notify me when a quota resets early" = "Notify me when a quota resets early";
"Posts a notification when a provider resets a usage limit before its scheduled time, so you know the capacity is back. The Capacity Dock shows the same notice for 12 hours either way." = "Posts a notification when a provider resets a usage limit before its scheduled time, so you know the capacity is back. The Capacity Dock shows the same notice for 12 hours either way.";
"Derived from this Mac's own record of past quota windows for this provider. Local only — nothing is fetched to produce it." = "Derived from this Mac's own record of past quota windows for this provider. Local only — nothing is fetched to produce it.";
"Posts a notification when a provider resets a usage limit before its scheduled time, so you know the capacity is back." = "Posts a notification when a provider resets a usage limit before its scheduled time, so you know the capacity is back.";
"cache read" = "cache read";
"Cache read: %@ tokens" = "Cache read: %@ tokens";
"Quota window %@" = "Quota window %@";
@ -670,14 +669,6 @@
"You're back to %lld%%." = "You're back to %lld%%.";
"%1$@'s %2$@ reset %3$@ early. %4$@" = "%1$@'s %2$@ reset %3$@ early. %4$@";
"%1$@ cleared your %2$@ %3$@ before its reset. %4$@" = "%1$@ cleared your %2$@ %3$@ before its reset. %4$@";
"%1$@ reset %2$@ early" = "%1$@ reset %2$@ early";
"%1$@ cleared, %2$@ before reset" = "%1$@ cleared, %2$@ before reset";
"%lld%% of it was available when CodeBurn noticed." = "%lld%% of it was available when CodeBurn noticed.";
"%1$@ reset this %2$@ %3$@ before its scheduled time. %4$@" = "%1$@ reset this %2$@ %3$@ before its scheduled time. %4$@";
"%1$@ cleared this %2$@ %3$@ before the window's scheduled reset, which has not moved. %4$@" = "%1$@ cleared this %2$@ %3$@ before the window's scheduled reset, which has not moved. %4$@";
"Last %1$@ reset came ~%2$@ early" = "Last %1$@ reset came ~%2$@ early";
"Last %1$lld %2$@ resets came ~%3$@ early" = "Last %1$lld %2$@ resets came ~%3$@ early";
"%1$lld of the last %2$lld %3$@ resets came ~%4$@ early" = "%1$lld of the last %2$lld %3$@ resets came ~%4$@ early";
"%lldh" = "%lldh";
"5-hour limit" = "5-hour limit";
"weekly limit" = "weekly limit";

View file

@ -637,8 +637,7 @@
"Notify me when Codex banks a limit reset" = "Codex 获得限额重置额度时通知我";
"OpenAI sometimes grants Codex accounts a credit that resets a rate-limit window early. CodeBurn reads these from the quota response it already fetches and tells you once per grant. It never spends one." = "OpenAI 有时会向 Codex 账户发放一份额度,用于提前重置某个限流窗口。CodeBurn 会从它已经获取的配额响应中读取这些额度,并为每次发放提醒你一次。CodeBurn 绝不会使用这些额度。";
"Notify me when a quota resets early" = "配额提前重置时通知我";
"Posts a notification when a provider resets a usage limit before its scheduled time, so you know the capacity is back. The Capacity Dock shows the same notice for 12 hours either way." = "当某个服务商在预定时间之前重置用量限额时发送通知,让你知道额度已经恢复。无论是否开启,容量 Dock 都会将同样的提示显示 12 小时。";
"Derived from this Mac's own record of past quota windows for this provider. Local only — nothing is fetched to produce it." = "根据这台 Mac 自己记录的该服务商过往配额窗口得出。仅限本地——不会为此获取任何数据。";
"Posts a notification when a provider resets a usage limit before its scheduled time, so you know the capacity is back." = "当某个服务商在预定时间之前重置用量限额时发送通知,让你知道额度已经恢复。";
"cache read" = "缓存读取";
"Cache read: %@ tokens" = "缓存读取:%@ Token";
"Quota window %@" = "配额窗口 %@";
@ -661,14 +660,6 @@
"You're back to %lld%%." = "你已恢复到 %lld%%。";
"%1$@'s %2$@ reset %3$@ early. %4$@" = "%1$@ 的%2$@提前 %3$@重置。%4$@";
"%1$@ cleared your %2$@ %3$@ before its reset. %4$@" = "%1$@ 清空了你的%2$@,比其重置提前 %3$@。%4$@";
"%1$@ reset %2$@ early" = "%1$@提前 %2$@重置";
"%1$@ cleared, %2$@ before reset" = "%1$@已清空,比重置提前 %2$@";
"%lld%% of it was available when CodeBurn noticed." = "CodeBurn 发现时其中有 %lld%% 可用。";
"%1$@ reset this %2$@ %3$@ before its scheduled time. %4$@" = "%1$@ 将这个%2$@提前 %3$@ 重置,早于其预定时间。%4$@";
"%1$@ cleared this %2$@ %3$@ before the window's scheduled reset, which has not moved. %4$@" = "%1$@ 清空了这个%2$@,比该窗口的预定重置时间早 %3$@,而重置时间并未改变。%4$@";
"Last %1$@ reset came ~%2$@ early" = "上次%1$@重置提前了约 %2$@";
"Last %1$lld %2$@ resets came ~%3$@ early" = "最近 %1$lld 次%2$@重置提前了约 %3$@";
"%1$lld of the last %2$lld %3$@ resets came ~%4$@ early" = "最近 %1$lld/%2$lld 次%3$@重置提前了约 %4$@";
"%lldh" = "%lld 小时";
"5-hour limit" = "5 小时限额";
"weekly limit" = "每周限额";

View file

@ -345,7 +345,6 @@ private struct AgentTabQuotaBar: View {
}
private struct QuotaDetailPopover: View {
@Environment(AppStore.self) private var store
let quota: QuotaSummary
var body: some View {
@ -413,17 +412,6 @@ private struct QuotaDetailPopover: View {
ForEach(Array(quota.details.enumerated()), id: \.offset) { index, w in
QuotaDetailRow(window: w)
}
// What this Mac has seen of the provider's own reset timing, next to
// the pace captions. Derived from the snapshots already on disk.
let earlyResetLines = store.earlyResetHistoryCaptions(for: quota.providerFilter)
if !earlyResetLines.isEmpty {
ForEach(Array(earlyResetLines.enumerated()), id: \.offset) { _, line in
Text(line)
.font(.system(size: 10))
.foregroundStyle(.secondary)
.help(L("Derived from this Mac's own record of past quota windows for this provider. Local only — nothing is fetched to produce it."))
}
}
if !quota.footerLines.isEmpty {
Divider()
.padding(.top, 2)

View file

@ -87,15 +87,11 @@ enum CapacityDockMetrics {
sessionCount: Int?,
hasToday: Bool,
tailEdge: CapacityDockEdge,
scale: CGFloat,
hasEarlyResetNotice: Bool = false
scale: CGFloat
) -> CGFloat {
guard let quota else { return 186 * scale }
// Each section carries its own padding, so the panel adds none.
var height = CapacityDockGlance.headerHeight
// The early-reset band is a notice like the staleness line, with the
// same padded height, and can sit alongside it.
if hasEarlyResetNotice { height += CapacityDockGlance.noticeHeight }
// The tail only eats vertical room when it points up or down.
if !tailEdge.isVertical { height += CapacityDockGlance.tailAllowance }
if let sessionCount { height += CapacityDockGlance.sessionsHeight(count: sessionCount) }
@ -813,9 +809,6 @@ struct CapacityDockDetailView: View {
if !CapacityDockGlance.drawsNotice(quota.connection) {
connectionLabel(quota.connection, provider: provider)
}
if let earlyReset = store.capacityDockEarlyResetNotice(for: provider) {
earlyResetNoticeSection(earlyReset)
}
if let sessions = store.capacityDockLiveSessions(for: provider) {
sessionsSection(sessions).dividerBelow()
}
@ -856,29 +849,6 @@ struct CapacityDockDetailView: View {
}
}
/// A vendor reset one of this provider's windows ahead of schedule. Drawn as
/// a notice band with the staleness line's inset, padding and divider, and
/// reserved in `CapacityDockMetrics.detailHeight` the same way, for
/// `EarlyQuotaResetNotice.visibleSeconds` after the reset was seen.
@ViewBuilder
private func earlyResetNoticeSection(_ event: EarlyQuotaResetEvent) -> some View {
let s = model.detailScale
Text(event.noticeText)
.font(.system(size: 10))
.foregroundStyle(.green.opacity(0.86))
.lineLimit(1)
.minimumScaleFactor(0.8)
.help(event.noticeHelpText)
.accessibilityElement(children: .ignore)
.accessibilityLabel(event.noticeText)
.accessibilityHint(event.noticeHelpText)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 6 * s)
.padding(.bottom, 8 * s)
.padding(.horizontal, CapacityDockGlance.contentInset * s)
.dividerBelow()
}
@ViewBuilder
private func header(_ provider: CapacityDockProvider, plan: String?) -> some View {
let s = model.detailScale

View file

@ -555,7 +555,7 @@ private struct GeneralSettingsTab: View {
.font(.system(size: 11))
.foregroundStyle(.secondary)
Toggle(L("Notify me when a quota resets early"), isOn: $notifyAboutEarlyResets)
Text(L("Posts a notification when a provider resets a usage limit before its scheduled time, so you know the capacity is back. The Capacity Dock shows the same notice for 12 hours either way."))
Text(L("Posts a notification when a provider resets a usage limit before its scheduled time, so you know the capacity is back."))
.font(.system(size: 11))
.foregroundStyle(.secondary)
Toggle(L("Quota crossings (%1$lld%% and %2$lld%%)", 80, 100), isOn: $notifyAboutQuotaCrossings)

View file

@ -55,7 +55,6 @@ struct EarlyQuotaResetDetectorTests {
#expect(event.percentBefore == 80.0)
#expect(event.percentAfter == 0.0)
#expect(event.notificationBody == "Claude's weekly limit reset 18h early. You're back to 100%.")
#expect(event.noticeText == "Weekly limit reset 18h early")
}
@Test("Usage emptying while the reset time stands still is an early reset")
@ -71,8 +70,7 @@ struct EarlyQuotaResetDetectorTests {
#expect(event.notificationTitle == "Claude quota cleared early")
#expect(event.notificationBody
== "Claude cleared your weekly usage 18h before its reset. You're back to 99%.")
#expect(event.noticeText == "Weekly usage cleared, 18h before reset")
for text in [event.notificationTitle, event.notificationBody, event.noticeText, event.noticeHelpText] {
for text in [event.notificationTitle, event.notificationBody] {
#expect(!text.contains("reset early"))
}
}
@ -294,136 +292,6 @@ struct EarlyQuotaResetDetectorTests {
}
}
@Suite("Early quota reset history")
struct EarlyQuotaResetHistoryTests {
private func snapshots(resetOffsets: [TimeInterval], windowKey: String = "seven_day") -> [SubscriptionSnapshot] {
resetOffsets.map { offset in
SubscriptionSnapshot(
windowKey: windowKey,
percent: 50,
resetsAt: now.addingTimeInterval(offset),
capturedAt: now.addingTimeInterval(offset - 3600),
effectiveTokens: nil
)
}
}
@Test("Three consecutive weekly cycles that each landed 18h early read as a pattern")
func consistentEarlyResets() {
let early: TimeInterval = 18 * 3600
// Each cycle ends a window after the previous reset, minus the lead.
var offsets: [TimeInterval] = [-3 * week]
for _ in 0..<3 { offsets.append(offsets.last! + week - early) }
let summary = EarlyQuotaResetHistory.summarize(
snapshots: snapshots(resetOffsets: offsets),
windowKey: "seven_day",
windowName: "weekly limit",
windowSeconds: weekSeconds
)
#expect(summary?.earlyResets == 3)
#expect(summary?.observedResets == 3)
#expect(summary?.typicalEarlyBySeconds == early)
#expect(summary?.caption == "Last 3 weekly resets came ~18h early")
}
@Test("Cycles that ran to schedule produce no summary")
func onScheduleResetsHaveNoPattern() {
let offsets: [TimeInterval] = [-3 * week, -2 * week, -week, 0]
#expect(EarlyQuotaResetHistory.summarize(
snapshots: snapshots(resetOffsets: offsets),
windowKey: "seven_day",
windowName: "weekly limit",
windowSeconds: weekSeconds
) == nil)
}
@Test("A mixed record says how many of the observed resets were early")
func mixedRecord() {
let early: TimeInterval = 12 * 3600
let offsets: [TimeInterval] = [
-3 * week,
-3 * week + week - early,
-3 * week + 2 * week - early,
-3 * week + 3 * week - early * 2,
]
let summary = EarlyQuotaResetHistory.summarize(
snapshots: snapshots(resetOffsets: offsets),
windowKey: "seven_day",
windowName: "weekly limit",
windowSeconds: weekSeconds
)
#expect(summary?.observedResets == 3)
#expect(summary?.earlyResets == 2)
#expect(summary?.caption == "2 of the last 3 weekly resets came ~12h early")
}
@Test("Short windows get no pattern, the same discipline the pace ETA uses")
func shortWindowsHaveNoPattern() {
let offsets: [TimeInterval] = [0, fiveHours - 2 * 3600, 2 * (fiveHours - 2 * 3600)]
#expect(EarlyQuotaResetHistory.summarize(
snapshots: snapshots(resetOffsets: offsets, windowKey: "five_hour"),
windowKey: "five_hour",
windowName: "5-hour limit",
windowSeconds: 5 * 3600
) == nil)
}
@Test("A single observed cycle is not a pattern")
func oneCycleHasNoPattern() {
#expect(EarlyQuotaResetHistory.summarize(
snapshots: snapshots(resetOffsets: [0]),
windowKey: "seven_day",
windowName: "weekly limit",
windowSeconds: weekSeconds
) == nil)
}
@Test("Cycles the store never saw are not read as timing evidence")
func unobservedCyclesAreSkipped() {
// A gap of three windows: the app was closed. That pair says nothing.
#expect(EarlyQuotaResetHistory.summarize(
snapshots: snapshots(resetOffsets: [-4 * week, -week]),
windowKey: "seven_day",
windowName: "weekly limit",
windowSeconds: weekSeconds
) == nil)
}
@Test("A gap in the record is not counted among the resets the summary speaks for")
func unobservedCyclesAreNotCounted() {
let early: TimeInterval = 18 * 3600
let first = -5 * week
// Three windows pass unobserved, then one cycle that landed early.
let resumed = first + 3 * week
let summary = EarlyQuotaResetHistory.summarize(
snapshots: snapshots(resetOffsets: [first, resumed, resumed + week - early]),
windowKey: "seven_day",
windowName: "weekly limit",
windowSeconds: weekSeconds
)
#expect(summary?.observedResets == 1)
#expect(summary?.earlyResets == 1)
#expect(summary?.caption == "Last weekly reset came ~18h early")
}
@Test("Jittered reset timestamps inside one cycle collapse to that cycle")
func jitterIsCollapsed() {
let early: TimeInterval = 18 * 3600
let first = -2 * week
let second = first + week - early
let offsets: [TimeInterval] = [first, first + 90, second, second + 120]
let summary = EarlyQuotaResetHistory.summarize(
snapshots: snapshots(resetOffsets: offsets),
windowKey: "seven_day",
windowName: "weekly limit",
windowSeconds: weekSeconds
)
#expect(summary?.observedResets == 1)
#expect(summary?.earlyResets == 1)
#expect(summary?.caption == "Last weekly reset came ~18h early")
}
}
@Suite("Early quota reset notifications")
@MainActor
struct EarlyQuotaResetMonitorTests {
@ -503,7 +371,7 @@ struct EarlyQuotaResetMonitorTests {
}
}
@Test("Toggle off posts nothing and never asks for authorization, but the dock still shows it")
@Test("Toggle off posts nothing and never asks for authorization")
func toggleOffStaysSilent() async throws {
try await withIsolatedMonitor { monitor, notifier, defaults in
defaults.set(false, forKey: EarlyQuotaResetPreference.defaultsKey)
@ -517,7 +385,6 @@ struct EarlyQuotaResetMonitorTests {
#expect(event != nil)
#expect(notifier.posts.isEmpty)
#expect(notifier.authorizationRequests == 0)
#expect(monitor.visibleEvent(providerID: "claude", now: now) != nil)
}
}
@ -582,56 +449,9 @@ struct EarlyQuotaResetMonitorTests {
now: now
)
#expect(notifier.posts.isEmpty)
#expect(monitor.visibleEvent(providerID: "claude", now: now) == nil)
}
}
@Test("The dock band is bounded in time")
func noticeExpires() async throws {
try await withIsolatedMonitor { monitor, _, _ in
await seedBaseline(monitor)
await monitor.record(
providerID: "claude", providerName: "Claude", planLabel: "Max 20x",
baselineIsTrusted: true,
observations: [weeklyObservation(afterEarlyReset)],
now: now
)
// Literal twelve hours: reading the constant back would pin nothing.
let twelveHours: TimeInterval = 12 * 3600
#expect(monitor.visibleEvent(
providerID: "claude", now: now.addingTimeInterval(twelveHours - 60)
) != nil)
#expect(monitor.visibleEvent(
providerID: "claude", now: now.addingTimeInterval(twelveHours + 60)
) == nil)
}
}
}
@Suite("Capacity Dock early reset band")
struct EarlyQuotaResetDockTests {
@Test("The band is a notice the computed panel height reserves")
func bandIsReserved() {
let quota = QuotaSummary(
providerFilter: .claude,
connection: .connected,
primary: nil,
details: [QuotaSummary.Window(label: "Weekly", percent: 0.2, resetsAt: now)],
planLabel: "Max 20x",
footerLines: []
)
func height(_ hasBand: Bool) -> CGFloat {
CapacityDockMetrics.detailHeight(
quota: quota,
sessionCount: 1,
hasToday: true,
tailEdge: .right,
scale: 1,
hasEarlyResetNotice: hasBand
)
}
#expect(height(true) == height(false) + CapacityDockGlance.noticeHeight)
}
}
// MARK: - Helpers