mirror of
https://github.com/openai/codex.git
synced 2026-05-02 18:37:01 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user