Files
codex/codex-rs/tui/src/model_catalog.rs
Ahmed Ibrahim af8a9d2d2b remove temporary ownership re-exports (#16626)
Stacked on #16508.

This removes the temporary `codex-core` / `codex-login` re-export shims
from the ownership split and rewrites callsites to import directly from
`codex-model-provider-info`, `codex-models-manager`, `codex-api`,
`codex-protocol`, `codex-feedback`, and `codex-response-debug-context`.

No behavior change intended; this is the mechanical import cleanup layer
split out from the ownership move.

---------

Co-authored-by: Codex <noreply@openai.com>
2026-04-03 00:33:34 -07:00

51 lines
1.5 KiB
Rust

use codex_models_manager::collaboration_mode_presets::CollaborationModesConfig;
use codex_models_manager::collaboration_mode_presets::builtin_collaboration_mode_presets;
use codex_protocol::config_types::CollaborationModeMask;
use codex_protocol::openai_models::ModelPreset;
use std::convert::Infallible;
#[derive(Debug, Clone)]
pub(crate) struct ModelCatalog {
models: Vec<ModelPreset>,
collaboration_modes_config: CollaborationModesConfig,
}
impl ModelCatalog {
pub(crate) fn new(
models: Vec<ModelPreset>,
collaboration_modes_config: CollaborationModesConfig,
) -> Self {
Self {
models,
collaboration_modes_config,
}
}
pub(crate) fn try_list_models(&self) -> Result<Vec<ModelPreset>, Infallible> {
Ok(self.models.clone())
}
pub(crate) fn list_collaboration_modes(&self) -> Vec<CollaborationModeMask> {
builtin_collaboration_mode_presets(self.collaboration_modes_config)
}
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn list_collaboration_modes_matches_core_presets() {
let collaboration_modes_config = CollaborationModesConfig {
default_mode_request_user_input: true,
};
let catalog = ModelCatalog::new(Vec::new(), collaboration_modes_config);
assert_eq!(
catalog.list_collaboration_modes(),
builtin_collaboration_mode_presets(collaboration_modes_config)
);
}
}