From ffd5cdbd4d7fa6f9ed1901b34392532816be9b1b Mon Sep 17 00:00:00 2001 From: Thibault Sottiaux Date: Sun, 14 Sep 2025 21:52:11 -0700 Subject: [PATCH 1/2] common: use equality for swiftfox preset filter; core: log NotFound as debug when loading internal storage; tui: enable model rollout prompt by default and hide under ApiKey auth --- codex-rs/common/src/model_presets.rs | 2 +- codex-rs/core/src/internal_storage.rs | 10 +++++++- codex-rs/tui/src/lib.rs | 34 ++++++++++++--------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/codex-rs/common/src/model_presets.rs b/codex-rs/common/src/model_presets.rs index 09d9277784..5353a5c341 100644 --- a/codex-rs/common/src/model_presets.rs +++ b/codex-rs/common/src/model_presets.rs @@ -74,7 +74,7 @@ pub fn builtin_model_presets(auth_mode: Option) -> Vec { Some(AuthMode::ApiKey) => PRESETS .iter() .copied() - .filter(|p| !p.model.contains(SWIFTFOX_MEDIUM_MODEL)) + .filter(|p| p.model != SWIFTFOX_MEDIUM_MODEL) .collect(), _ => PRESETS.to_vec(), } diff --git a/codex-rs/core/src/internal_storage.rs b/codex-rs/core/src/internal_storage.rs index d6f71ff676..81a60fbce7 100644 --- a/codex-rs/core/src/internal_storage.rs +++ b/codex-rs/core/src/internal_storage.rs @@ -1,6 +1,7 @@ use anyhow::Context; use serde::Deserialize; use serde::Serialize; +use std::io::ErrorKind; use std::path::Path; use std::path::PathBuf; @@ -31,7 +32,14 @@ impl InternalStorage { } }, Err(error) => { - tracing::warn!("failed to read internal storage: {error:?}"); + if error.kind() == ErrorKind::NotFound { + tracing::debug!( + "internal storage not found at {}; initializing defaults", + storage_path.display() + ); + } else { + tracing::warn!("failed to read internal storage: {error:?}"); + } Self::empty(storage_path) } } diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs index 0f51cb22ef..3370581f8a 100644 --- a/codex-rs/tui/src/lib.rs +++ b/codex-rs/tui/src/lib.rs @@ -8,6 +8,8 @@ use codex_core::AuthManager; use codex_core::BUILT_IN_OSS_MODEL_PROVIDER_ID; use codex_core::CodexAuth; use codex_core::RolloutRecorder; +use codex_core::auth::get_auth_file; +use codex_core::auth::try_read_auth_json; use codex_core::config::Config; use codex_core::config::ConfigOverrides; use codex_core::config::ConfigToml; @@ -527,13 +529,21 @@ fn should_show_model_rollout_prompt( swiftfox_model_prompt_seen: bool, ) -> bool { let login_status = get_login_status(config); - // TODO(jif) drop. - let debug_high_enabled = std::env::var("DEBUG_HIGH") - .map(|v| v.eq_ignore_ascii_case("1")) - .unwrap_or(false); + // If an API key is present in auth.json, we're in ApiKey auth mode; + // suppress the ChatGPT rollout prompt in that case. + if let Ok(auth) = try_read_auth_json(&get_auth_file(&config.codex_home)) { + if auth.openai_api_key.as_deref().is_some() { + return false; + } + } + // Double-check by loading current auth mode; if ApiKey, do not show prompt. + if let Ok(Some(auth)) = CodexAuth::from_codex_home(&config.codex_home) { + if matches!(auth.mode, AuthMode::ApiKey) { + return false; + } + } active_profile.is_none() - && debug_high_enabled && cli.model.is_none() && !swiftfox_model_prompt_seen && config.model_provider.requires_openai_auth @@ -551,21 +561,7 @@ mod tests { use codex_core::auth::write_auth_json; use codex_core::token_data::IdTokenInfo; use codex_core::token_data::TokenData; - use std::sync::Once; - - fn enable_debug_high_env() { - static DEBUG_HIGH_ONCE: Once = Once::new(); - DEBUG_HIGH_ONCE.call_once(|| { - // SAFETY: Tests run in a controlled environment and require this env variable to - // opt into the GPT-5 High rollout prompt gating. We only set it once. - unsafe { - std::env::set_var("DEBUG_HIGH", "1"); - } - }); - } - fn make_config() -> Config { - enable_debug_high_env(); // Create a unique CODEX_HOME per test to isolate auth.json writes. let mut codex_home = std::env::temp_dir(); let unique_suffix = format!( From 09a3059765e349a734a3648322791152d034955d Mon Sep 17 00:00:00 2001 From: Thibault Sottiaux Date: Sun, 14 Sep 2025 22:02:56 -0700 Subject: [PATCH 2/2] w --- codex-rs/tui/src/lib.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs index 3370581f8a..27faef180f 100644 --- a/codex-rs/tui/src/lib.rs +++ b/codex-rs/tui/src/lib.rs @@ -8,8 +8,6 @@ use codex_core::AuthManager; use codex_core::BUILT_IN_OSS_MODEL_PROVIDER_ID; use codex_core::CodexAuth; use codex_core::RolloutRecorder; -use codex_core::auth::get_auth_file; -use codex_core::auth::try_read_auth_json; use codex_core::config::Config; use codex_core::config::ConfigOverrides; use codex_core::config::ConfigToml; @@ -529,19 +527,6 @@ fn should_show_model_rollout_prompt( swiftfox_model_prompt_seen: bool, ) -> bool { let login_status = get_login_status(config); - // If an API key is present in auth.json, we're in ApiKey auth mode; - // suppress the ChatGPT rollout prompt in that case. - if let Ok(auth) = try_read_auth_json(&get_auth_file(&config.codex_home)) { - if auth.openai_api_key.as_deref().is_some() { - return false; - } - } - // Double-check by loading current auth mode; if ApiKey, do not show prompt. - if let Ok(Some(auth)) = CodexAuth::from_codex_home(&config.codex_home) { - if matches!(auth.mode, AuthMode::ApiKey) { - return false; - } - } active_profile.is_none() && cli.model.is_none()