From d7b0997d3234edafab8b233cecca7179a924c2f4 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Mon, 5 Jan 2026 10:10:32 -0800 Subject: [PATCH] models --- codex-rs/tui/src/app.rs | 11 +++++++---- codex-rs/tui/src/chatwidget.rs | 13 ++++++------- codex-rs/tui2/src/app.rs | 11 +++++++---- codex-rs/tui2/src/chatwidget.rs | 13 ++++++------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index 6f99145774..c4c1a73f6c 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -181,6 +181,10 @@ impl App { let (app_event_tx, mut app_event_rx) = unbounded_channel(); let app_event_tx = AppEventSender::new(app_event_tx); + let mut config = config; + let pending_model_migration_notice = + crate::model_migration::take_pending_model_migration_notice(&mut config); + let conversation_manager = Arc::new(ConversationManager::new( auth_manager.clone(), SessionSource::Cli, @@ -238,10 +242,9 @@ impl App { } }; - // Startup-only: show any previously scheduled model migration notice, then refresh the - // schedule to reflect the current config + model presets (at most one scheduled notice). - chat_widget.maybe_show_pending_model_migration_notice(); - chat_widget.refresh_pending_model_migration_notice(); + if let Some(notice) = pending_model_migration_notice { + chat_widget.show_model_migration_notice(notice); + } chat_widget.maybe_prompt_windows_sandbox_enable(); diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 87c834b491..cea98604cf 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -469,6 +469,7 @@ impl ChatWidget { // turn now that we know the session is configured. self.maybe_send_next_queued_input(); } + self.refresh_pending_model_migration_notice(); if !self.suppress_session_configured_redraw { self.request_redraw(); } @@ -806,12 +807,10 @@ impl ChatWidget { self.request_redraw(); } - pub(crate) fn maybe_show_pending_model_migration_notice(&mut self) { - let Some(notice) = model_migration::take_pending_model_migration_notice(&mut self.config) - else { - return; - }; - + pub(crate) fn show_model_migration_notice( + &mut self, + notice: model_migration::PendingModelMigrationNotice, + ) { self.add_to_history(history_cell::new_info_event( format!( "Model upgrade available: {} -> {}. Use /model to switch.", @@ -826,7 +825,7 @@ impl ChatWidget { }); } - pub(crate) fn refresh_pending_model_migration_notice(&self) { + fn refresh_pending_model_migration_notice(&self) { let available_models = match self.models_manager.try_list_models(&self.config) { Ok(models) => models, Err(_) => return, diff --git a/codex-rs/tui2/src/app.rs b/codex-rs/tui2/src/app.rs index 76e8bc46a4..7103af6671 100644 --- a/codex-rs/tui2/src/app.rs +++ b/codex-rs/tui2/src/app.rs @@ -222,6 +222,10 @@ impl App { let (app_event_tx, mut app_event_rx) = unbounded_channel(); let app_event_tx = AppEventSender::new(app_event_tx); + let mut config = config; + let pending_model_migration_notice = + crate::model_migration::take_pending_model_migration_notice(&mut config); + let conversation_manager = Arc::new(ConversationManager::new( auth_manager.clone(), SessionSource::Cli, @@ -279,10 +283,9 @@ impl App { } }; - // Startup-only: show any previously scheduled model migration notice, then refresh the - // schedule to reflect the current config + model presets (at most one scheduled notice). - chat_widget.maybe_show_pending_model_migration_notice(); - chat_widget.refresh_pending_model_migration_notice(); + if let Some(notice) = pending_model_migration_notice { + chat_widget.show_model_migration_notice(notice); + } chat_widget.maybe_prompt_windows_sandbox_enable(); diff --git a/codex-rs/tui2/src/chatwidget.rs b/codex-rs/tui2/src/chatwidget.rs index dce2c5b2f8..fd3e68a17c 100644 --- a/codex-rs/tui2/src/chatwidget.rs +++ b/codex-rs/tui2/src/chatwidget.rs @@ -434,6 +434,7 @@ impl ChatWidget { // turn now that we know the session is configured. self.maybe_send_next_queued_input(); } + self.refresh_pending_model_migration_notice(); if !self.suppress_session_configured_redraw { self.request_redraw(); } @@ -748,12 +749,10 @@ impl ChatWidget { self.request_redraw(); } - pub(crate) fn maybe_show_pending_model_migration_notice(&mut self) { - let Some(notice) = model_migration::take_pending_model_migration_notice(&mut self.config) - else { - return; - }; - + pub(crate) fn show_model_migration_notice( + &mut self, + notice: model_migration::PendingModelMigrationNotice, + ) { self.add_to_history(history_cell::new_info_event( format!( "Model upgrade available: {} -> {}. Use /model to switch.", @@ -768,7 +767,7 @@ impl ChatWidget { }); } - pub(crate) fn refresh_pending_model_migration_notice(&self) { + fn refresh_pending_model_migration_notice(&self) { let available_models = match self.models_manager.try_list_models(&self.config) { Ok(models) => models, Err(_) => return,