Do not poll for usage when using API Key auth (#10973)

Fixes #10869

- Gate TUI rate-limit polling on ChatGPT-auth providers only.
- `prefetch_rate_limits()` now checks `should_prefetch_rate_limits()`.
- New gate requires:
  - `config.model_provider.requires_openai_auth`
  - cached auth is ChatGPT (`CodexAuth::is_chatgpt_auth`)
- Prevents `/wham/usage` polling in API/custom-endpoint profiles.
This commit is contained in:
Eric Traut
2026-02-06 23:26:44 -08:00
committed by GitHub
parent 18bb25557c
commit 3779b52e2d
2 changed files with 28 additions and 6 deletions

View File

@@ -1138,6 +1138,22 @@ fn set_chatgpt_auth(chat: &mut ChatWidget) {
));
}
#[tokio::test]
async fn prefetch_rate_limits_is_gated_on_chatgpt_auth_provider() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
assert!(!chat.should_prefetch_rate_limits());
set_chatgpt_auth(&mut chat);
assert!(chat.should_prefetch_rate_limits());
chat.config.model_provider.requires_openai_auth = false;
assert!(!chat.should_prefetch_rate_limits());
chat.prefetch_rate_limits();
assert!(chat.rate_limit_poller.is_none());
}
#[tokio::test]
async fn worked_elapsed_from_resets_when_timer_restarts() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;