fix(codex): reconcile extra credit usage and balances - #3296
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ea2fe845f
ℹ️ 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".
|
Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 4:13 AM ET / 08:13 UTC. ClawSweeper reviewWhat this changesThe PR shows Codex extra-credit usage and purchased balances across cards, menu-bar metrics, and CLI output while reconciling their freshness independently. Merge readiness✅ Ready for maintainer review This remains useful beyond current main and v0.56.4. The current head addresses the earlier findings, and this review found no new blocking defect. Priority: P2 Review scores
Verification
How this fits togetherCodexBar combines account-matched credit readings from OAuth, CLI, PAT, and dashboard sources. Its presentation layer turns those readings into usage cards, menu-bar values, and CLI output. flowchart LR
A[Codex credit sources] --> B[Account-matched snapshots]
B --> C[Select freshest monthly cap]
B --> D[Select freshest successful balance]
C --> E[Shared credit presentation]
D --> E
E --> F[Cards and menu bar]
E --> G[CLI output]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep credit reconciliation centralized and account-scoped, with independent observation timestamps shared by all display consumers. Do we have a high-confidence way to reproduce the issue? Yes for the addressed reconciliation cases: the supplied native scenarios and focused regressions identify concrete stale-balance and omitted-field triggers; this reviewer did not execute them. Is this the best way to solve the issue? Yes. Reusing shared cost presentation and reconciling account-paired observations avoids competing display rules while preserving existing preferences and legacy decoding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 392310c66548. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (21 earlier review cycles; latest 8 shown)
|
|
The Web-source finding is fixed in @codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2096aeaf6e
ℹ️ 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".
Real-account behavior proof (menu bar text regression fixed)While validating this PR against a live Codex account with per-member extra credits, the status item rendered the raw credit amount instead of a percentage: Root cause. Fix ( guard let cost = snapshot?.providerCost,
cost.limit > 0,
cost.used >= 0,
// Codex extra usage is denominated in credits, not money: currency formatting would emit the
// bare amount ("2000.6633599996567") instead of a spend value, so it keeps the percent text.
cost.currencyCode != CodexExtraUsageCost.currencyCode
else {
return nil
}The menu card itself was already correct on the live account — used vs. limit plus the distinct purchased balance: Verification
Screenshots were captured from a freshly packaged bundle on a real account, then the original live configuration was restored. @codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Full local suite result for
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eee9dc4190
ℹ️ 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".
|
Addressed the P2 finding on Short version: Full local suite on
@codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a41bfdcb61
ℹ️ 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".
|
Second P2 addressed in Full local suite on
@codex review |
|
Rebased onto current origin/main (5996f7f) at 3028b08. CHANGELOG keeps the 0.56.4 section intact and puts the Codex Extra-usage line under Unreleased after the existing Tailscale/Claude/Antigravity notes. The four Codex review threads are addressed on the rebased SHAs:
The previous macOS shard failure on f72d4ee was StatusItemExtraUsageMetricTests expecting 100% but getting 2000.66; that path now rejects the Credits currency code and keeps the percent text. No new live screenshots for the zero-reconciliation case. @codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Surface per-member Codex extra credits as Extra usage, including used/limit and any distinct purchased remaining balance. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
The balance was decided once by freshness only on the attached-wins path; the live-wins path returned the snapshot whole and dropped a dashboard balance that live had no reading for. A nil balance is not a reading that the credits are gone: CodexMonthlyCreditPreservation.merging stands a preserved cap up beside a `remaining: 0` placeholder when the credits fetch fails, so the other side still gets to supply it. Decide the balance once, then apply it to whichever cap wins. On the live-wins branch the selector always takes its first arm — the cap won, so `cap.updatedAt >= attached.updatedAt`, and `providerCost` never stamps a cap newer than the credits fetch carrying it, so `liveCredits.updatedAt >= cap.updatedAt`. Not a dead branch, just a consistent simplification.
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
08ad99c to
22a6235
Compare
Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Addressed the remaining P2 (omitted balance treated as a confirmed zero) in What was wrong. Fix. The flag is now set from raw balance presence at each mapper, and preserved through every merge instead of falling back to the default:
Coverage. Also in this push: the earlier CI break is fixed — Not verified locally: this environment has no Swift toolchain, so @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Render account-paired extra usage and purchased balances consistently across cards and menu-bar projections. Preserve confirmed-zero balance observations separately from monthly cap age, including persisted snapshots and purchased-only credits. Co-authored-by: sf-jin-ku <jin.ku@sendbird.com>


Codex extra credits now show monthly spend/limit and a distinct purchased balance on account-scoped cards and menu-bar Extra usage. Monthly bars, reset dates, and their numeric details use the same selected cap; genuine 30-day quota bars keep their own meaning.
The maintainer revision preserves successful balance-read timestamps independently of cap timestamps. A newer confirmed zero clears stale purchased credits, while an unread balance retains the last successful value. This survives attachment and persistence, handles purchased-only depletion, and reconciles the legacy Credits display through a display copy without mutating stored transport snapshots or crossing account boundaries. Changelog and provider docs are updated; original contribution by @sf-jin-ku.
Validation: 121 focused tests passed, including dashboard conversion→attachment→projection→card, independent cap/balance ages, old/new Codable payloads, optional visibility, and CLI zero suppression. The signed native card test reproduces both stale-balance cases before the fix and passes after it. Formatting/lint and structured P0 review are clean. The full suite passed all 1,006 selections in 84 groups, with zero failures, retries, or timeouts.
Before (same synthetic account-paired inputs):
After (zero clears; unread retains; purchased-only zero disappears):