clean models manager (#9168)

Have only the following Methods:
- `list_models`: getting current available models
- `try_list_models`: sync version no refresh for tui use
- `get_default_model`: get the default model (should be tightened to
core and received on session configuration)
- `get_model_info`: get `ModelInfo` for a specific model (should be
tightened to core but used in tests)
- `refresh_if_new_etag`: trigger refresh on different etags

Also move the cache to its own struct
This commit is contained in:
Ahmed Ibrahim authored and GitHub committed 2026-01-13 16:55:33 -08:00
1 parent ebbbee70c6
commit 7e33ac7eb6
12 files changed
+404 -273

No files matched your search

+6 -3
View File
@@ -33,6 +33,7 @@ use codex_core::config::edit::ConfigEditsBuilder;
#[cfg(target_os = "windows")]
use codex_core::features::Feature;
use codex_core::models_manager::manager::ModelsManager;
use codex_core::models_manager::manager::RefreshStrategy;
use codex_core::models_manager::model_presets::HIDE_GPT_5_1_CODEX_MAX_MIGRATION_PROMPT_CONFIG;
use codex_core::models_manager::model_presets::HIDE_GPT5_1_MIGRATION_PROMPT_CONFIG;
use codex_core::protocol::DeprecationNoticeEvent;
@@ -212,7 +213,9 @@ async fn handle_model_migration_prompt_if_needed(
app_event_tx: &AppEventSender,
models_manager: Arc<ModelsManager>,
) -> Option<AppExitInfo> {
let available_models = models_manager.list_models(config).await;
let available_models = models_manager
.list_models(config, RefreshStrategy::OnlineIfUncached)
.await;
let upgrade = available_models
.iter()
.find(|preset| preset.model == model)
@@ -383,7 +386,7 @@ impl App {
));
let mut model = thread_manager
.get_models_manager()
.get_model(&config.model, &config)
.get_default_model(&config.model, &config, RefreshStrategy::OnlineIfUncached)
.await;
let exit_info = handle_model_migration_prompt_if_needed(
tui,
@@ -619,7 +622,7 @@ impl App {
let model_info = self
.server
.get_models_manager()
.construct_model_info(self.current_model.as_str(), &self.config)
.get_model_info(self.current_model.as_str(), &self.config)
.await;
match event {
AppEvent::NewSession => {