Show actionable rate-limit banners in the TUI (#41742)

## What changed

- Carry optional backend-owned banner and account identity data through
  `account/rateLimits/read`, filtering banners that do not match the authenticated
  account and user.
- Render supported rate-limit notices above the composer with actions for usage,
  credits, resets, owner notifications, and plan management while preserving the
  existing fallback UI for absent or unsupported banners.
- Refresh usage after limit errors, reject stale responses, and keep queued input
  paused until recovery completes. When instructed by the banner, switch to the
  first available fallback model without changing unrelated thread settings.

## Testing

- Add protocol, banner parsing and rendering, CTA, identity filtering, refresh
  ordering, fallback-model, account-change, and queued-input recovery coverage.

GitOrigin-RevId: e03d75a82e425deb87f4b120a71cf2286c0ef6cc
This commit is contained in:
stefanstokic-oai
2026-08-31 00:20:06 +00:00
committed by copyberry
parent 94cbbddafc
commit 79b04f1ab5
69 changed files with 3454 additions and 69 deletions
@@ -317,6 +317,11 @@ pub struct GetAccountRateLimitsResponse {
/// Multi-bucket view keyed by metered `limit_id` (for example, `codex`).
pub rate_limits_by_limit_id: Option<HashMap<String, RateLimitSnapshot>>,
pub rate_limit_reset_credits: Option<RateLimitResetCreditsSummary>,
/// Account associated with this usage snapshot, when supplied by the backend.
pub account_id: Option<String>,
/// Optional backend-owned banner from the same usage read. Its nested keys retain the
/// backend's snake_case contract; an absent banner leaves the client's existing UI unchanged.
pub rate_limit_upsell: Option<serde_json::Value>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]