Skip to content

Commit d7286e9

Browse files
authored
chore: remove model upgrade popup (#4332)
1 parent bcf2bc0 commit d7286e9

File tree

5 files changed

+4
-454
lines changed

5 files changed

+4
-454
lines changed

codex-rs/core/src/internal_storage.rs

Lines changed: 0 additions & 89 deletions
This file was deleted.

codex-rs/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ mod exec_command;
2929
pub mod exec_env;
3030
mod flags;
3131
pub mod git_info;
32-
pub mod internal_storage;
3332
pub mod landlock;
3433
mod mcp_connection_manager;
3534
mod mcp_tool_call;

codex-rs/tui/src/ascii_animation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ impl AsciiAnimation {
9090
true
9191
}
9292

93+
#[allow(dead_code)]
9394
pub(crate) fn request_frame(&self) {
9495
self.request_frame.schedule_frame();
9596
}

codex-rs/tui/src/lib.rs

Lines changed: 3 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ use codex_core::RolloutRecorder;
1212
use codex_core::config::Config;
1313
use codex_core::config::ConfigOverrides;
1414
use codex_core::config::ConfigToml;
15-
use codex_core::config::GPT_5_CODEX_MEDIUM_MODEL;
1615
use codex_core::config::find_codex_home;
1716
use codex_core::config::load_config_as_toml_with_cli_overrides;
18-
use codex_core::config::persist_model_selection;
1917
use codex_core::find_conversation_path_by_id_str;
2018
use codex_core::protocol::AskForApproval;
2119
use codex_core::protocol::SandboxPolicy;
@@ -54,7 +52,6 @@ pub mod live_wrap;
5452
mod markdown;
5553
mod markdown_render;
5654
mod markdown_stream;
57-
mod new_model_popup;
5855
pub mod onboarding;
5956
mod pager_overlay;
6057
mod render;
@@ -79,14 +76,11 @@ pub mod test_backend;
7976
#[cfg(not(debug_assertions))]
8077
mod updates;
8178

82-
use crate::new_model_popup::ModelUpgradeDecision;
83-
use crate::new_model_popup::run_model_upgrade_popup;
8479
use crate::onboarding::TrustDirectorySelection;
8580
use crate::onboarding::onboarding_screen::OnboardingScreenArgs;
8681
use crate::onboarding::onboarding_screen::run_onboarding_app;
8782
use crate::tui::Tui;
8883
pub use cli::Cli;
89-
use codex_core::internal_storage::InternalStorage;
9084

9185
// (tests access modules directly within the crate)
9286

@@ -204,8 +198,6 @@ pub async fn run_main(
204198
cli_profile_override,
205199
)?;
206200

207-
let internal_storage = InternalStorage::load(&config.codex_home);
208-
209201
let log_dir = codex_core::config::log_dir(&config)?;
210202
std::fs::create_dir_all(&log_dir)?;
211203
// Open (or create) your log file, appending to it.
@@ -249,21 +241,14 @@ pub async fn run_main(
249241

250242
let _ = tracing_subscriber::registry().with(file_layer).try_init();
251243

252-
run_ratatui_app(
253-
cli,
254-
config,
255-
internal_storage,
256-
active_profile,
257-
should_show_trust_screen,
258-
)
259-
.await
260-
.map_err(|err| std::io::Error::other(err.to_string()))
244+
run_ratatui_app(cli, config, active_profile, should_show_trust_screen)
245+
.await
246+
.map_err(|err| std::io::Error::other(err.to_string()))
261247
}
262248

263249
async fn run_ratatui_app(
264250
cli: Cli,
265251
config: Config,
266-
mut internal_storage: InternalStorage,
267252
active_profile: Option<String>,
268253
should_show_trust_screen: bool,
269254
) -> color_eyre::Result<AppExitInfo> {
@@ -389,36 +374,6 @@ async fn run_ratatui_app(
389374
resume_picker::ResumeSelection::StartFresh
390375
};
391376

392-
if should_show_model_rollout_prompt(
393-
&cli,
394-
&config,
395-
active_profile.as_deref(),
396-
internal_storage.gpt_5_codex_model_prompt_seen,
397-
) {
398-
internal_storage.gpt_5_codex_model_prompt_seen = true;
399-
if let Err(e) = internal_storage.persist().await {
400-
error!("Failed to persist internal storage: {e:?}");
401-
}
402-
403-
let upgrade_decision = run_model_upgrade_popup(&mut tui).await?;
404-
let switch_to_new_model = upgrade_decision == ModelUpgradeDecision::Switch;
405-
406-
if switch_to_new_model {
407-
config.model = GPT_5_CODEX_MEDIUM_MODEL.to_owned();
408-
config.model_reasoning_effort = None;
409-
if let Err(e) = persist_model_selection(
410-
&config.codex_home,
411-
active_profile.as_deref(),
412-
&config.model,
413-
config.model_reasoning_effort,
414-
)
415-
.await
416-
{
417-
error!("Failed to persist model selection: {e:?}");
418-
}
419-
}
420-
}
421-
422377
let Cli { prompt, images, .. } = cli;
423378

424379
let app_result = App::run(
@@ -532,140 +487,3 @@ fn should_show_login_screen(login_status: LoginStatus, config: &Config) -> bool
532487

533488
login_status == LoginStatus::NotAuthenticated
534489
}
535-
536-
fn should_show_model_rollout_prompt(
537-
cli: &Cli,
538-
config: &Config,
539-
active_profile: Option<&str>,
540-
gpt_5_codex_model_prompt_seen: bool,
541-
) -> bool {
542-
let login_status = get_login_status(config);
543-
544-
active_profile.is_none()
545-
&& cli.model.is_none()
546-
&& !gpt_5_codex_model_prompt_seen
547-
&& config.model_provider.requires_openai_auth
548-
&& matches!(login_status, LoginStatus::AuthMode(AuthMode::ChatGPT))
549-
&& !cli.oss
550-
}
551-
552-
#[cfg(test)]
553-
mod tests {
554-
use super::*;
555-
use clap::Parser;
556-
use codex_core::auth::AuthDotJson;
557-
use codex_core::auth::get_auth_file;
558-
use codex_core::auth::login_with_api_key;
559-
use codex_core::auth::write_auth_json;
560-
use codex_core::token_data::IdTokenInfo;
561-
use codex_core::token_data::TokenData;
562-
use std::sync::atomic::AtomicUsize;
563-
use std::sync::atomic::Ordering;
564-
565-
fn get_next_codex_home() -> PathBuf {
566-
static NEXT_CODEX_HOME_ID: AtomicUsize = AtomicUsize::new(0);
567-
let mut codex_home = std::env::temp_dir();
568-
let unique_suffix = format!(
569-
"codex_tui_test_{}_{}",
570-
std::process::id(),
571-
NEXT_CODEX_HOME_ID.fetch_add(1, Ordering::Relaxed)
572-
);
573-
codex_home.push(unique_suffix);
574-
codex_home
575-
}
576-
577-
fn make_config() -> Config {
578-
// Create a unique CODEX_HOME per test to isolate auth.json writes.
579-
let codex_home = get_next_codex_home();
580-
std::fs::create_dir_all(&codex_home).expect("create unique CODEX_HOME");
581-
Config::load_from_base_config_with_overrides(
582-
ConfigToml::default(),
583-
ConfigOverrides::default(),
584-
codex_home,
585-
)
586-
.expect("load default config")
587-
}
588-
589-
/// Test helper to write an `auth.json` with the requested auth mode into the
590-
/// provided CODEX_HOME directory. This ensures `get_login_status()` reads the
591-
/// intended mode deterministically.
592-
fn set_auth_method(codex_home: &std::path::Path, mode: AuthMode) {
593-
match mode {
594-
AuthMode::ApiKey => {
595-
login_with_api_key(codex_home, "sk-test-key").expect("write api key auth.json");
596-
}
597-
AuthMode::ChatGPT => {
598-
// Minimal valid JWT payload: header.payload.signature (all base64url, no padding)
599-
const FAKE_JWT: &str = "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.e30.c2ln"; // {"alg":"none","typ":"JWT"}.{}."sig"
600-
let mut id_info = IdTokenInfo::default();
601-
id_info.raw_jwt = FAKE_JWT.to_string();
602-
let auth = AuthDotJson {
603-
openai_api_key: None,
604-
tokens: Some(TokenData {
605-
id_token: id_info,
606-
access_token: "access-token".to_string(),
607-
refresh_token: "refresh-token".to_string(),
608-
account_id: None,
609-
}),
610-
last_refresh: None,
611-
};
612-
let file = get_auth_file(codex_home);
613-
write_auth_json(&file, &auth).expect("write chatgpt auth.json");
614-
}
615-
}
616-
}
617-
618-
#[test]
619-
fn shows_login_when_not_authenticated() {
620-
let cfg = make_config();
621-
assert!(should_show_login_screen(
622-
LoginStatus::NotAuthenticated,
623-
&cfg
624-
));
625-
}
626-
627-
#[test]
628-
fn shows_model_rollout_prompt_for_default_model() {
629-
let cli = Cli::parse_from(["codex"]);
630-
let cfg = make_config();
631-
set_auth_method(&cfg.codex_home, AuthMode::ChatGPT);
632-
assert!(should_show_model_rollout_prompt(&cli, &cfg, None, false,));
633-
}
634-
635-
#[test]
636-
fn hides_model_rollout_prompt_when_api_auth_mode() {
637-
let cli = Cli::parse_from(["codex"]);
638-
let cfg = make_config();
639-
set_auth_method(&cfg.codex_home, AuthMode::ApiKey);
640-
assert!(!should_show_model_rollout_prompt(&cli, &cfg, None, false,));
641-
}
642-
643-
#[test]
644-
fn hides_model_rollout_prompt_when_marked_seen() {
645-
let cli = Cli::parse_from(["codex"]);
646-
let cfg = make_config();
647-
set_auth_method(&cfg.codex_home, AuthMode::ChatGPT);
648-
assert!(!should_show_model_rollout_prompt(&cli, &cfg, None, true,));
649-
}
650-
651-
#[test]
652-
fn hides_model_rollout_prompt_when_cli_overrides_model() {
653-
let cli = Cli::parse_from(["codex", "--model", "gpt-4.1"]);
654-
let cfg = make_config();
655-
set_auth_method(&cfg.codex_home, AuthMode::ChatGPT);
656-
assert!(!should_show_model_rollout_prompt(&cli, &cfg, None, false,));
657-
}
658-
659-
#[test]
660-
fn hides_model_rollout_prompt_when_profile_active() {
661-
let cli = Cli::parse_from(["codex"]);
662-
let cfg = make_config();
663-
set_auth_method(&cfg.codex_home, AuthMode::ChatGPT);
664-
assert!(!should_show_model_rollout_prompt(
665-
&cli,
666-
&cfg,
667-
Some("gpt5"),
668-
false,
669-
));
670-
}
671-
}

0 commit comments

Comments
 (0)