Repository navigation
feat(codex): notify when OpenAI banks a limit reset, and show it everywhere quota is shown - #1328
Merged
Merged
Conversation
…eady carries The reset-credits decoder kept only `available_count` and the soonest expiry, and the inline block on the usage payload kept only `available_count`. The response has always carried more: `id`, `reset_type` and `granted_at` per credit, and `applicable_available_count` alongside the total. Those are exactly the fields needed to tell a newly granted credit from one the account was already holding, so they are decoded now instead of discarded. Identity comes first: a credit is reduced to a grant only if it carries an `id` or, failing that, a `granted_at` to be named by. One that carries neither still counts toward the server's authoritative total but never becomes a grant, because it could not be told apart from the next one and would re-announce itself on every refresh. Only `status == "available"` credits become grants, so a redeemed one is spent history rather than news. `applicable_available_count` is unknown when absent, never zero. The companion endpoint does not always send it and the usage payload sometimes does, so the usage response we are already holding fills it in when — and only when — the authoritative source said nothing. No extra request either way.
A banked reset is the one capacity signal a user can act on before it is spent, and it arrives silently. CodeBurn already sees it: the reset-credit inventory rides every successful Codex quota refresh. Comparing that inventory against the previous reading is all it takes to notice a grant, so there is no new endpoint, no new cadence and no new data source here. The detection is a pure function over an observation and the state it is judged against, which is what makes the awkward cases testable rather than hopeful: - The first-ever observation is a baseline. Everything the account already holds is history, not a burst of notifications. - A credit that disappears was spent or expired, and is never an event. Its id is kept for the retention window so a payload that lists it again — a flicker, not a grant — cannot re-announce it. - An absent or malformed credits payload is *no opinion*: no event, and no state change at all. Treating it as an empty account would re-baseline on every failed fetch and re-announce the whole inventory on reconnect. Seen ids persist to `codex-banked-resets.json` in the CodeBurn cache directory, written through SafeFile behind an actor exactly the way SubscriptionSnapshotStore writes its snapshots — the same mechanism, not a second one — so a relaunch does not repeat a notice. State is written before the post, not after: a notice we drop is a smaller failure than one that repeats forever. Disconnecting clears the file, so a reconnect under another account baselines again. The notification goes out on the existing UpdateNotifier path, one per new credit, naming what was granted, when, and how many are usable. Never the credit id, never a token. Settings gains a toggle, default on; with it off the state is still recorded, so turning it back on does not release a backlog. Nothing here ever spends a credit. It is a notice.
The Plan tab row #724 added showed a count and an expiry. It now also shows how many of those credits can be applied right now and when the most recent one landed, which is what a user deciding whether to push through or throttle back actually needs. The same sentence appears in the agent-tab quota hover card and in `codeburn quota`. One formatter produces it, mirrored line for line in Swift and TypeScript, down to the compact-age rules — deliberately not RelativeDateTimeFormatter or Intl.RelativeTimeFormat, because the two surfaces have to print the same characters, and a locale-aware formatter would not. `codeburn quota` grows a `notes` channel for provider facts that are not a window; only Codex sets it, so every other provider's output is byte-identical to before. The CLI reads the credits off the `rate_limit_reset_credits` block of the usage response it already fetches and never calls the companion endpoint, so it prints the count without the grant and expiry captions that only the per-credit list carries. Refs #725. No new polling loop and no new data source: this reads fields from a response already fetched on the existing cadence.
The notification delegate ran performFullUpdate() for any notification tapped. With a second notification kind, tapping "Codex banked a limit reset" would start a CLI and app update. Gate the handler on the UpdateChecker identifier prefix, shared as a constant so the poster and the handler cannot drift.
This was referenced Sep 12, 2026
Closed
iamtoruk
added a commit
that referenced
this pull request
Sep 12, 2026
Rebase resolution for #1289 onto main (#1306, #1313, #1314, #1315, #1328, #1329). Conflicts kept both intents: main's second-row title composition, glance-window accessibility actions, cache-read line, host field and merged Notifications section keep their behaviour and now resolve through L(…). Adds 14 keys to both tables, drops 4 that no longer have a call site, and retranslates the two Copilot explanations main rewrote.
ozymandiashh
added a commit
to ozymandiashh/codeburn
that referenced
this pull request
Sep 12, 2026
A day's worth of menubar work landed: getagentseal#1328 (Codex banked limit resets), getagentseal#1329 (early quota reset detection), 138ef34 folding the three notification switches into one Settings section, cbcd984 rewording the usage-drop early reset, the Copilot per-rung host work, and the dock's cache-read row and pace captions. Four files conflicted, ten hunks. Every one resolved as a union: main's behaviour lands verbatim and the catalog routing is re-applied on top. - MenubarSecondRow.swift: main rebuilt `secondRow` around a `row` binding it clamps through `clampToRowBudget`, and rebuilt `quotaRow` so the provider label is abbreviated against the budget left over by the figures. The routing is reshaped to fit rather than reverting either: the figures go through `L("%lld%% left")` and the label joins with a plain space, which is the word order in both locales. The old `"%@ %lld%% left"` key cannot survive that restructure, and a `"%@ %@"` key to replace it would be nothing but specifiers, which LocalizationCatalogTests rejects on purpose. - CapacityDockView.swift: main's cache-read line kept, and its new stale-but-idle distinction kept as two routed strings rather than one. - HeatmapSection.swift: main moved the reset-credits label into the new `CodexBankedResetPresentation`, so the local helper it replaced is deleted rather than kept alongside it. - SettingsView.swift: the Updates section becomes main's consolidated Notifications section; the Copilot help paragraph and token footer take main's longer wording under new keys; the pasted-token section gains main's host field; `.dormant` and the stale connection title route through main's new presentation helpers. Verified mechanically: outside `mac/` the tree is byte-identical to main, and every one of the seven `L(...)` keys that disappeared is accounted for — three reworded by main, one dropped by the `quotaRow` restructure above, and three whose code main moved into `CodexBankedResetPresentation` and `CopilotQuotaPresentation.dormantSettingsDetail`. Those three, and the much larger set of new strings the features shipped unrouted, are the next commit.
ozymandiashh
added a commit
to ozymandiashh/codeburn
that referenced
this pull request
Sep 12, 2026
getagentseal#1328's banked limit resets, getagentseal#1329's early quota reset detection, the consolidated notifications section, the Copilot per-rung host work and the dock's cache-read row all shipped user-facing copy with no `L(` calls. 67 new keys, 5 retired by main's rewrites and restructures: 551 keys become 613. Most of it was invisible to the guard test, which is the next commit's problem. Both features put their wording in a new pure presentation type — exactly the shape the views render as `Text(presentation.caption)` — so the call-site pass had nothing to look at. Routed here: - Notifications: the section itself plus the banked-reset and early-reset toggles and their help text. - Codex banked resets: the Plan-tab row label, the detail parts the hover card and Plan tab share, the notification title and body, and the compact-age vocabulary. - Early quota resets: both notification shapes, the dock band, the hover help text and the three history-summary sentences, plus the Claude window names and the lead formatter. - Quota pace: the captions, the projection sentences and the window-length and countdown labels. The countdown reuses the popover's own `%lldd %lldh` / `%lldh %lldm` / `%lldm` keys so the two can never disagree. - Copilot: the host-aware dormant and rejection messages, the new host field. - Capacity Dock: the cache-read row and the window/reset accessibility labels. Two notes on judgement calls: `CodexBankedResetPresentation.detail` and `compactAge` carry a documented character-identical mirror in `src/quota/codex.ts`. Routing them keeps that mirror exact — `en` is an identity table, so they emit byte-for-byte what they did before — while letting a zh-Hans menubar say it in Chinese. The CLI stays English-only, so the two diverge in a translated build exactly as every other menubar string already does. The doc comments now say so. `EarlyQuotaResetFormat.windowNoun` trims " limit" and `capitalizedFirst` upper-cases: English morphology that degrades to the identity in Chinese. Left that way deliberately — the trim exists to avoid "weekly limit resets" in English, a repetition Chinese does not produce — rather than keying a second catalog entry per window purely to shorten a noun. Both are commented. Argument order is preserved in every multi-argument key, including the history summary, where the natural Chinese phrasing wanted to reorder two counts: `String(format:)` binds positionally, so the parity test would have caught it, but the reordered sentence would have been wrong in a way no test can see. Verified with the standalone swiftc harness (`swift test` cannot run here) and `swift build`.
ozymandiashh
added a commit
to ozymandiashh/codeburn
that referenced
this pull request
Sep 12, 2026
The previous commit had to add 67 keys, and the guard test caught almost none of them. getagentseal#1328 and getagentseal#1329 each arrived as a new pure presentation type holding a feature's whole vocabulary — `CodexBankedResetPresentation`, `EarlyQuotaResetFormat`, `QuotaPacePresentation` — and the views only ever render `Text(presentation.caption)`. There is no literal at a call site to see, and these are not enum display labels either, so two of the three passes were blind. Only the catalog round-trip noticed anything, and only for the four keys whose code main happened to move. So the display-label pass becomes a copy-bearing-declaration pass, anchored on the convention this codebase already follows: every `String` returned by a type whose name ends in `Presentation` or `Format` is copy, as is every `displayName` / `settingsLabel` / `notificationTitle` / `notificationBody` / `noticeText` / `noticeHelpText` / `caption` / `helpText` / `rowLabel` anywhere. A return-type rule was tried first — any declaration returning String — and rejected: it reports 378 findings on this tree, almost all enum raw values and CLI argument strings. Anchoring on the naming convention gives 29, every one of which is either already denylisted or a bug fixed below. Three bugs the probe exposed: - `->` drove the header parser's bracket depth negative, because `>` was treated as closing a generic. Every `func … -> String` was invisible while the `var` form was caught — so `QuotaPacePresentation.caption`, the single biggest source of new copy, would have sailed through. - A `case "five_hour":` pattern read as produced copy rather than as a value being matched, so any string-keyed switch reported its own match keys. - `enclosingTypeName` rescanned the file per member, which is quadratic; on AppStore.swift the pass took minutes. It now indexes each file once. Denylist grows by two entries, both documented: `ExportFormat.cliName` and `.suffix`, caught only because that enum's name ends in "Format" — it is an export-format enum, and those return a CLI argument value and a file extension. Mutation-checked: un-routing `EarlyQuotaResetEvent.notificationTitle` and `QuotaPacePresentation.caption` both fail the new pass, and each of the three bugs above has a test that fails without its fix. Known imprecision, documented in the source: the owning type is the nearest preceding declaration rather than a brace-scoped one, so a member after a nested type's closing brace is attributed to the nested type. A finding prints the qualified name it used and that is the string to paste into the denylist, so the two cannot disagree — and it errs toward guarding more, never less.
ozymandiashh
added a commit
to ozymandiashh/codeburn
that referenced
this pull request
Sep 12, 2026
getagentseal#1329 (early quota resets) and getagentseal#1328 (banked Codex resets) both landed, so the two features this forecast reads from are now on main. Conflicts, all resolved as unions: - CHANGELOG.md, the usual: both sides' entries kept in their sections. - SettingsView.swift, the seam this branch flagged. Main folded the notification switches into one `Section("Notifications")` (138ef34), so the forecast's opt-in notice and its threshold picker move into that section rather than adding a fourth one. The standalone "Codex Reset Forecast" section is gone. - AppStore.swift, five hunks: both announcers, both post-fetch observe calls, both stores cleared on disconnect, and the Codex summary now carrying main's banked-reset footer line alongside this branch's `forecastLines`. Nothing from either side dropped. - HeatmapSection.swift: main replaced `resetCreditsLabel` with `CodexBankedResetPresentation`; that deletion is kept and this branch's forecast rows stay. - src/quota/index.ts: main's `notes` and this branch's `resetForecast` are both on `QuotaCommandProvider`. They stay separate on purpose - `notes` is for facts the provider reported, `resetForecast` is an estimate over a public record, and folding one into the other is what the footer-lines fix earlier on this branch was about. With both features on main, the local-event loader now decodes through their real `Codable` types - `EarlyQuotaResetMonitor.ProviderState`, `EarlyQuotaResetEvent` and `CodexBankedResetState` - instead of the private mirror structs it carried while they were unmerged. Drift is now a compile error rather than a silent misread. It still reads the two stores by address rather than calling them, because neither exposes a read this can use: `CodexBankedResetStore.load()` is async and hard-wired to the real cache path with nothing to inject, and the forecast is evaluated synchronously from view bodies; and `EarlyQuotaResetMonitor.visibleEvent` applies the twelve-hour dock-visibility window, which is the wrong filter here - a reset twenty hours ago is no longer worth a band in the dock and is still exactly what "since last reset" should count from. The `UserDefaults` key prefix is still a literal, because `EarlyQuotaResetMonitor` is @mainactor and its static cannot initialise a nonisolated one; a test asserts the two strings are equal, so drift fails there instead of silently reading nothing.
3 of 4 tasks
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.
Supersedes #1322. Same work by @ozymandiashh, rebased on current
main(clean, no conflicts), plus one fix found in review.What changed vs #1322
One commit added on top:
fix(macos): only install an update when the update notice is tapped—AppDelegate.userNotificationCenter(_:didReceive:)(added in #1283) calledupdateChecker.performFullUpdate()for any notification the user tapped. #1322 introduces a second notification kind, so tapping "Codex banked a limit reset" would have kicked off a CLI package-manager update and an app update. The handler now checks theUpdateChecker.identifier prefix, shared as a constant so the poster and the handler cannot drift. #1320 posts through the same delegate and needs the same guard.The three original commits are unmodified.
Verified on a real machine
swift build,swift build -c release,swift test— 569 tests in 64 suites pass. (feat(codex): notify when OpenAI banks a limit reset, and show it everywhere quota is shown #1322 reportedswift testcould not run on the author's box.)npx tsc --noEmitclean;npm test— 4090 passed, 5 skipped, 0 failed (main: 4076 — the 14 new tests).decodeResetCredits/resetCreditsLine. All 34 well-formed cases produce byte-identical strings, including compact-age boundaries (59s/60s, 2h50m, 3d22h), tie-breaking on equalgranted_at, and the future-grant wording./wham/usageresponse on a Free account carriesrate_limit_reset_credits: {available_count, applicable_available_count}and no inlinecreditsarray.codeburn quota --format jsonis byte-identical tomainfor every provider;notesis purely additive.Known, not fixed here
Codableparser is stricter than main's: a non-stringid,reset_typeorgranted_at, or a non-integerapplicable_available_count, now fails the wholeparseResetCreditsand hides the Limit resets row thatmainwould still render. The TS side is lenient in all those cases. No observed payload produces them, and the quota read stays connected either way, so this is schema-drift brittleness rather than a live bug.SettingsView.swift, at exactly these two hunks.