Skip to content

fix(tui): gate rate-limit tier switch on the Anthropic provider#136

Merged
BunsDev merged 1 commit into
mainfrom
fix/rate-limit-tier-switch-provider-gate
Jul 7, 2026
Merged

fix(tui): gate rate-limit tier switch on the Anthropic provider#136
BunsDev merged 1 commit into
mainfrom
fix/rate-limit-tier-switch-provider-gate

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Gates the rate-limit recovery modal's one-key Sonnet/Haiku tier switch on the active provider being Anthropic.

Context

  • Related issue/user request: code-review finding on the rate-limit recovery flow landed in f2046ee — the modal opens for any provider's structured 429 (From<ProviderError> for ClaudeError maps every provider's RateLimited into it), but the s/h actions unconditionally call set_model(SONNET/HAIKU) and persist_provider_and_model(), flipping a Codex-only session to Anthropic persistently, with no credentials to back it.
  • Scope: crates/tui (rate_limit_recovery.rs, app.rs) plus the matching sentence in docs/advanced.md.
  • Non-goals: any other recovery-flow behavior; non-TUI 429 handling.

Changes

  • Add tier_switch_available to RateLimitRecoveryState, set from the active provider when the modal opens (same probe the duplicate-profile scan already uses).
  • Gate the [s]/[h] action hints and key-handler arms on it.
  • New test tier_actions_hidden_for_non_anthropic_provider; existing tests updated for the new open() parameter.
  • Document the gating in docs/advanced.md.

Validation

Record exact commands and outcomes. Mark items N/A with a reason when they do not apply.

  • git diff --check — clean.
  • cargo fmt --all — clean.
  • cargo check --package claurst-tui — passed (change is TUI-scoped; workspace check ran on the same tree state earlier tonight).
  • cargo clippy --package claurst-tui --all-targets -- -D warnings — passed.
  • Targeted/manual checks: cargo test --package claurst-tui rate_limit — 15 passed, 0 failed.
  • Not run: full cargo test --workspace — change is confined to claurst-tui; the touched module's suite plus package clippy/check cover it.

PR Readiness

  • Diff is limited to the intended files.
  • Generated files were not edited by hand.
  • User-facing docs/help were updated or are not needed.
  • No secrets, credentials, local paths, or unrelated logs are included.
  • Remaining risks or follow-up work are listed above.

The recovery modal opens for any provider's structured 429, but the
s/h tier-switch actions unconditionally set an Anthropic Sonnet/Haiku
model and persist the provider flip. A Codex-only user pressing h got
a persistently broken Anthropic config with no credentials.

Add tier_switch_available to RateLimitRecoveryState, set from the
active provider when the modal opens, and gate both the action hints
and the key handlers on it, mirroring the existing provider gate on
the duplicate-profile scan.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 07:00
@BunsDev BunsDev added the crate:tui Terminal UI crate (src-rust/crates/tui) label Jul 7, 2026
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 7, 2026 7:00am

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.

Pull request overview

This PR prevents the TUI rate-limit recovery modal from offering (or handling) the one-key Sonnet/Haiku tier-switch actions when the active provider is not Anthropic, avoiding persisting an invalid provider/model configuration (e.g., flipping a Codex session into Anthropic without credentials).

Changes:

  • Add tier_switch_available to RateLimitRecoveryState, set when opening the modal based on whether the active provider is Anthropic.
  • Gate the [s] / [h] action hints and the corresponding key-handler branches on tier_switch_available.
  • Update/add tests and document the provider gating in docs/advanced.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src-rust/crates/tui/src/rate_limit_recovery.rs Adds tier_switch_available, gates action hint rendering, updates tests and adds a non-Anthropic coverage test.
src-rust/crates/tui/src/app.rs Computes is_anthropic when opening the modal and gates s/h key handling accordingly.
docs/advanced.md Documents that s/h tier switching is only offered for the Anthropic provider.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@BunsDev
BunsDev merged commit d5a7116 into main Jul 7, 2026
4 checks passed
@BunsDev
BunsDev deleted the fix/rate-limit-tier-switch-provider-gate branch July 7, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crate:tui Terminal UI crate (src-rust/crates/tui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants