feat(tui): add rate-limit reset redemption to /usage#28154
Conversation
df9d29d to
9e246b3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df9d29d6db
ℹ️ 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".
049080f to
744aff0
Compare
1fd75fb to
77c2b29
Compare
a8c5a51 to
03c9c7e
Compare
## Why Codex users can earn personal rate-limit reset credits, but app-server clients do not currently have an API for reading or redeeming them. This adds the backend and protocol foundation used by the `/usage` TUI flow in #28154. ## What changed - Extend `account/rateLimits/read` with a nullable `rateLimitResetCredits` summary sourced from the existing usage response. - Add backend-client and app-server support for consuming a reset with a caller-generated idempotency key. A UUID is recommended, and clients reuse the same key when retrying the same logical reset. - Return only the consume `outcome`; clients refetch `account/rateLimits/read` for updated window state. - Document the response field and each consume outcome, and regenerate the JSON and TypeScript schema fixtures. - Clarify in `AGENTS.md` that new app-server string enum values use camelCase on the wire. - Update the existing TUI response fixture for the expanded protocol shape. - Add coverage for authentication, response mapping, backend failures, consume outcomes, and request timeout behavior. ## Validation - `just test -p codex-app-server-protocol` — 231 passed. - `just test -p codex-backend-client` — 14 passed. - Focused `codex-app-server` reset-credit tests — 5 passed. - Focused `codex-tui` protocol response fixture test — passed. - `just fix -p codex-backend-client -p codex-app-server-protocol -p codex-app-server` — passed. - `just fmt` — passed.
b5b2bf7 to
b3e7cd4
Compare
fcoury-oai
left a comment
There was a problem hiding this comment.
Codex identified what looks like a real problem refreshing credits when user has none, check below.
| SelectionItem { | ||
| name: "Redeem rate limit reset".to_string(), | ||
| description: Some(reset_description), | ||
| is_disabled: !reset_available, |
There was a problem hiding this comment.
[P2] Re-check a cached zero reset balance
Could we avoid treating a cached zero balance as terminal? Reset credits are snapshot-only, so a user who earns one after startup remains locked out because /usage disables the only action that refetches the balance. Please refresh when /usage opens or keep the action enabled as "Check reset availability."
Found by Codex.
fcoury-oai
left a comment
There was a problem hiding this comment.
Tested the happy path with no reset credits. Code looks good.
Approved 👍

Why
Codex users can earn personal rate-limit reset credits, but the CLI does not currently provide a way to view or redeem them. The
/usagecommand restored in #27925 is intended to be the entry point for usage-related actions, so reset redemption belongs there rather than in a separate dashed slash command.This uses the app-server and backend-client reset-credit APIs landed in #28143.
What changed
/usageinto a menu with entries for token activity and earned rate-limit resets while preserving/usage daily,/usage weekly, and/usage cumulative.Validation
just test -p codex-tui chatwidget::tests::usage— 25 passed.cargo insta pending-snapshotsfromcodex-rs/tui— no pending snapshots.Examples
The current confirmation defaults to Cancel and does not label either action as the default.
Reset flow