Skip to content

FEAT: redeem banked quota resets from Quota view - #38

Merged
merefield merged 4 commits into
mainfrom
feat/quota-reset
Sep 5, 2026
Merged

merefield merged 4 commits into
mainfrom
feat/quota-reset

Conversation

@merefield

@merefield merefield commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

Users with a banked Codex reset can now redeem it from the Quota tab. A top-right RESET // N button changes to CONFIRM RESET on 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 PERCENT accepts 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/consume API 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

  • Full go test -race ./... and go vet ./... pass.
  • Fake app-server tests cover all four outcomes, invalid keys, unverified/changed accounts, and unknown responses.
  • UI tests cover confirmation, cancellation, retry idempotency, stale reads, visibility, rendered click coordinates, and surrounding controls across terminal widths.
  • Local binary rebuilt for review. No live reset redeemed during testing.

Source: https://learn.chatgpt.com/docs/app-server#8-earned-rate-limit-resets-chatgpt

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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/consume call 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.

Comment thread internal/ui/quota_reset.go Resolved
Comment thread internal/codex/client.go Resolved
Comment thread internal/ui/quota_reset.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 resetNotice to "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

@merefield
merefield merged commit 242cad2 into main Sep 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants