Lightweight coding agent that runs in your terminal
Rust
Do not poll for usage when using API Key auth (#10973)
Eric Traut3779b52e2d29
diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rsindex 94fece3620..f103f5bfc8 100644--- a/codex-rs/tui/src/chatwidget.rs+++ b/codex-rs/tui/src/chatwidget.rs@@ -4492,12 +4492,7 @@ impl ChatWidget {fn prefetch_rate_limits(&mut self) {self.stop_rate_limit_poller();- if !self- .auth_manager- .auth_cached()- .as_ref()- .is_some_and(CodexAuth::is_chatgpt_auth)- {+ if !self.should_prefetch_rate_limits() {return;}@@ -4522,6 +4517,17 @@ impl ChatWidget {self.rate_limit_poller = Some(handle);}+ fn should_prefetch_rate_limits(&self) -> bool {+ if !self.config.model_provider.requires_openai_auth {+ return false;+ }++ self.auth_manager+ .auth_cached()+ .as_ref()+ .is_some_and(CodexAuth::is_chatgpt_auth)+ }+fn lower_cost_preset(&self) -> Option<ModelPreset> {let models = self.models_manager.try_list_models(&self.config).ok()?;modelsdiff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rsindex fcd2b84616..bf173ceca3 100644--- a/codex-rs/tui/src/chatwidget/tests.rs+++ b/codex-rs/tui/src/chatwidget/tests.rs@@ -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;