mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
[codex] Fix usage-limit reset copy and state (#28793)
## Why The reset flow introduced in #28154 still describes earned reset credits as "rate-limit resets" and uses generic reset-scope copy. It can also retain a stale available-credit count after redemption or an account change, leaving the reset action enabled after the last credit is used. This follow-up updates terminology only within that reset feature. Existing rate-limit wording elsewhere in the CLI and TUI is unchanged. ## What changed - Rename reset-specific `/usage` menu items, startup hints, and reset dialogs to "usage limit reset." - Describe monthly resets for Free, Go, and accounts that report a monthly usage window; otherwise describe the current 5-hour and weekly limits. - Recheck a cached zero balance when `/usage` is reopened, and refresh the balance after redemption so the final reset immediately disables the action. - Correlate async refresh results before updating snapshots and clear account-derived reset state, warnings, prompts, and status surfaces when the account changes. ## Validation - `just test -p codex-tui chatwidget::tests::usage` — 29 passed. - `just test -p codex-tui chatwidget::tests::status_command_tests` — 7 passed. - Account-boundary prompt and plan-mode prompt regression tests passed. - `cargo insta pending-snapshots` from `codex-rs/tui` — no pending snapshots.\ <img width="814" height="318" alt="image" src="https://github.com/user-attachments/assets/2a460e96-458b-4805-8d9f-c759382d21a4" /> view for monthly <img width="905" height="243" alt="image" src="https://github.com/user-attachments/assets/179f88e3-08fb-4af5-8dc6-ce6a944ed681" />
This commit is contained in:
20 files changed
+496
-112
No files matched your search
@@ -19,7 +19,6 @@ use codex_app_server_protocol::MarketplaceRemoveResponse;
|
||||
use codex_app_server_protocol::MarketplaceUpgradeParams;
|
||||
use codex_app_server_protocol::MarketplaceUpgradeResponse;
|
||||
|
||||
use codex_app_server_protocol::RateLimitResetCreditsSummary;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
|
||||
use crate::hooks_rpc::fetch_hooks_list;
|
||||
@@ -90,7 +89,8 @@ impl App {
|
||||
.and_then(|result| result.map_err(|err| err.to_string()))
|
||||
}
|
||||
RateLimitRefreshOrigin::StartupPrefetch { .. }
|
||||
| RateLimitRefreshOrigin::StatusCommand { .. } => {
|
||||
| RateLimitRefreshOrigin::StatusCommand { .. }
|
||||
| RateLimitRefreshOrigin::UsageMenu { .. } => {
|
||||
request.await.map_err(|err| err.to_string())
|
||||
}
|
||||
};
|
||||
@@ -127,7 +127,7 @@ impl App {
|
||||
tokio::spawn(async move {
|
||||
let result = tokio::time::timeout(
|
||||
RATE_LIMIT_RESET_REQUEST_TIMEOUT,
|
||||
fetch_rate_limit_reset_credits(request_handle),
|
||||
fetch_account_rate_limits(request_handle),
|
||||
)
|
||||
.await
|
||||
.map_err(|_| "account/rateLimits/read timed out in TUI".to_string())
|
||||
@@ -789,24 +789,6 @@ pub(super) async fn fetch_account_token_activity(
|
||||
.wrap_err("account/usage/read failed in TUI")
|
||||
}
|
||||
|
||||
pub(super) async fn fetch_rate_limit_reset_credits(
|
||||
request_handle: AppServerRequestHandle,
|
||||
) -> Result<RateLimitResetCreditsSummary> {
|
||||
let request_id = RequestId::String(format!("account-rate-limit-resets-{}", Uuid::new_v4()));
|
||||
let response: GetAccountRateLimitsResponse = request_handle
|
||||
.request_typed(ClientRequest::GetAccountRateLimits {
|
||||
request_id,
|
||||
params: None,
|
||||
})
|
||||
.await
|
||||
.wrap_err("account/rateLimits/read failed in TUI")?;
|
||||
response.rate_limit_reset_credits.ok_or_else(|| {
|
||||
color_eyre::eyre::eyre!(
|
||||
"account/rateLimits/read response did not include rateLimitResetCredits"
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) async fn consume_rate_limit_reset_credit_request(
|
||||
request_handle: AppServerRequestHandle,
|
||||
idempotency_key: String,
|
||||
|
||||
Reference in new issue
Block a user