Repository navigation
FEAT: redeem banked quota resets from Quota view - #38
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There are a couple of correctness/robustness issues in the new reset submission path (unchecked type assertion panic risk and uncontextualized errors) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an in-TUI workflow to redeem “banked quota resets” from the Quota view, including confirmation UX, retry/idempotency handling, and a CLI flag to control when the reset affordance becomes visible.
Changes:
- Introduces a Quota tab reset button with two-click confirmation, timeout/cancel behavior, and a notice panel for outcomes.
- Adds
--reset-threshold(0–100) to control the consumption threshold for showing the reset button, with validation and tests. - Implements the app-server
account/rateLimitResetCredit/consumecall and related fake-server tests for recognized outcomes.
File summaries
| File | Description |
|---|---|
| README.md | Documents the reset redemption UX and the new threshold flag. |
| main.go | Adds --reset-threshold parsing/validation and passes it into the UI model. |
| main_test.go | Tests CLI parsing/validation and propagation of the threshold into the UI. |
| internal/ui/view.go | Renders a quota reset notice panel when applicable. |
| internal/ui/tabs.go | Integrates reset button layout/hit testing with the main tab row and narrow-width behavior. |
| internal/ui/quota_reset.go | Implements reset button state machine, eligibility logic, idempotency key creation, and submission. |
| internal/ui/quota_reset_test.go | Adds UI-level tests for confirmation, retry idempotency, visibility rules, and hit surfaces. |
| internal/ui/model.go | Adds reset-related model state, message handling, and stale-fetch protection via reset revisioning. |
| internal/codex/client.go | Adds ConsumeReset and wires the reset-consume RPC into the app-server session flow. |
| internal/codex/client_test.go | Extends the fake app-server and adds tests for reset outcomes and account binding. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces a sensitive, stateful quota-reset redemption flow across UI + client RPC paths, and should receive final human validation despite strong test coverage.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
internal/ui/model.go:743
- After a successful reset submission, the UI sets
resetNoticeto "Quota reset. Refreshing limits…" and then triggers a fresh fetch. If that follow-up fetch fails (message.err != nil), the notice stays stuck on "Refreshing" even though the refresh did not complete, which is misleading (the error frame will show an error but the notice still implies progress/success). Consider updating the notice on the error path so the reset status message stays accurate.
- Files reviewed: 10/10 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
Users with a banked Codex reset can now redeem it from the Quota tab. A top-right
RESET // Nbutton changes toCONFIRM RESETon the first click; only a second click within ten seconds submits the reset. The confirmation explains that eligible quota windows refresh and the weekly reset schedule changes. Esc and tab changes cancel confirmation.The button moves onto a separate row on narrow terminals and uses the same geometry for rendering and mouse hit testing. It appears for fresh, verified quota data with available credits only when at least one quota window reaches the configured consumption threshold (80% by default).
--reset-threshold PERCENTaccepts whole percentages from 0 to 100; 0 bypasses consumption checks for testing, while still requiring an available credit. Older servers without availability data leave it hidden. Uncertain submissions expose a retry action even if availability cannot be refreshed.Redemption uses the official
account/rateLimitResetCredit/consumeAPI and the prevailing Codex account, with an account identity check before submission. Duplicate clicks are blocked while submitting. Uncertain retries retain the original UUID, and stale reads started before submission cannot overwrite subsequent quota data. All recognized outcomes trigger a fresh quota read. The retry identifier is process-local; the README explains checking Usage before retrying after restarting.Validation
go test -race ./...andgo vet ./...pass.Source: https://learn.chatgpt.com/docs/app-server#8-earned-rate-limit-resets-chatgpt