From f78f8d8c7c370721286ca7b90e80b2bf1d7664c0 Mon Sep 17 00:00:00 2001 From: pap Date: Tue, 29 Jul 2025 23:20:24 +0100 Subject: [PATCH] fmt --- codex-rs/core/src/codex.rs | 3 +- codex-rs/core/src/config.rs | 2 +- codex-rs/core/src/openai_model_info.rs | 10 +---- codex-rs/tui/src/app.rs | 5 +-- codex-rs/tui/src/bottom_pane/mod.rs | 4 +- .../src/bottom_pane/model_selection_view.rs | 38 +++++++++++-------- codex-rs/tui/src/chatwidget.rs | 5 ++- 7 files changed, 34 insertions(+), 33 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index f61d45f5ec..48572e31df 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -111,7 +111,8 @@ impl Codex { let user_instructions = get_user_instructions(&config).await; - let configure_session = config.to_configure_session_op(Some(config.model.clone()), user_instructions); + let configure_session = + config.to_configure_session_op(Some(config.model.clone()), user_instructions); let config = Arc::new(config); diff --git a/codex-rs/core/src/config.rs b/codex-rs/core/src/config.rs index 9fd253c79c..0fcad44fc3 100644 --- a/codex-rs/core/src/config.rs +++ b/codex-rs/core/src/config.rs @@ -14,8 +14,8 @@ use crate::model_provider_info::ModelProviderInfo; use crate::model_provider_info::built_in_model_providers; use crate::openai_model_info::get_model_info; use crate::protocol::AskForApproval; -use crate::protocol::SandboxPolicy; use crate::protocol::Op; +use crate::protocol::SandboxPolicy; use dirs::home_dir; use serde::Deserialize; use std::collections::HashMap; diff --git a/codex-rs/core/src/openai_model_info.rs b/codex-rs/core/src/openai_model_info.rs index f0e4355305..0f97c1334d 100644 --- a/codex-rs/core/src/openai_model_info.rs +++ b/codex-rs/core/src/openai_model_info.rs @@ -72,13 +72,5 @@ pub(crate) fn get_model_info(name: &str) -> Option { /// Return a curated list of commonly-used OpenAI model names for selection UIs. pub fn get_all_model_names() -> Vec<&'static str> { - vec![ - "codex-mini-latest", - "o3", - "o4-mini", - "gpt-4.1", - "gpt-4o", - ] + vec!["codex-mini-latest", "o3", "o4-mini", "gpt-4.1", "gpt-4o"] } - - diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index 9c7d3d9d9c..56f185486e 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -366,7 +366,7 @@ impl App<'_> { widget.show_model_selector(); } // Models are populated from a curated list; no network fetch. - }, + } }, AppEvent::DispatchCommandWithArgs(command, args) => match command { SlashCommand::Model => { @@ -489,7 +489,6 @@ impl App<'_> { } } - #[cfg(test)] mod tests { use super::strip_surrounding_quotes; @@ -529,4 +528,4 @@ mod tests { assert_eq!(normalized, norm_expected, "normalized args for '{}'", line); } } -} \ No newline at end of file +} diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs index b9e950d888..4ca7cb692c 100644 --- a/codex-rs/tui/src/bottom_pane/mod.rs +++ b/codex-rs/tui/src/bottom_pane/mod.rs @@ -18,15 +18,15 @@ mod chat_composer; mod chat_composer_history; mod command_popup; mod file_search_popup; -mod status_indicator_view; mod model_selection_view; +mod status_indicator_view; pub(crate) use chat_composer::ChatComposer; pub(crate) use chat_composer::InputResult; use approval_modal_view::ApprovalModalView; -use status_indicator_view::StatusIndicatorView; use model_selection_view::ModelSelectionView; +use status_indicator_view::StatusIndicatorView; /// Pane displayed in the lower half of the chat UI. pub(crate) struct BottomPane<'a> { diff --git a/codex-rs/tui/src/bottom_pane/model_selection_view.rs b/codex-rs/tui/src/bottom_pane/model_selection_view.rs index afde21e5c6..cf40dba68e 100644 --- a/codex-rs/tui/src/bottom_pane/model_selection_view.rs +++ b/codex-rs/tui/src/bottom_pane/model_selection_view.rs @@ -11,10 +11,10 @@ use ratatui::widgets::Block; use ratatui::widgets::BorderType; use ratatui::widgets::Borders; use ratatui::widgets::Cell; +use ratatui::widgets::Clear; use ratatui::widgets::Row; use ratatui::widgets::Table; use ratatui::widgets::Widget; -use ratatui::widgets::Clear; use crate::app_event::AppEvent; use crate::app_event_sender::AppEventSender; @@ -136,7 +136,11 @@ impl ModelSelectionView { } else { // searching: pinned current + matches let mut matches = 1; // current always present - for name in self.options.iter().filter(|m| m.as_str() != self.current_model) { + for name in self + .options + .iter() + .filter(|m| m.as_str() != self.current_model) + { if fuzzy_match(name, &self.query).is_some() { matches += 1; } @@ -174,7 +178,6 @@ impl ModelSelectionView { } None } - } /// Row that can be rendered in the selector. @@ -186,7 +189,6 @@ enum DisplayRow { }, } - /// Return indices for a simple case-insensitive subsequence match and a score. /// Smaller score is better. fn fuzzy_match(haystack: &str, needle: &str) -> Option<(Vec, i32)> { @@ -360,8 +362,11 @@ impl<'a> BottomPaneView<'a> for ModelSelectionView { let mut cell = Cell::from(Line::from(spans)); // Selected row style takes precedence. if abs_idx == self.selected_idx { - cell = cell - .style(Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD)); + cell = cell.style( + Style::default() + .fg(Color::Yellow) + .add_modifier(Modifier::BOLD), + ); } else if *is_current { // Special color for the current model when not selected. cell = cell.style(Style::default().fg(Color::Cyan)); @@ -394,14 +399,17 @@ impl<'a> BottomPaneView<'a> for ModelSelectionView { title.push(')'); } - let table = Table::new(visible_rows, vec![ratatui::prelude::Constraint::Percentage(100)]) - .block( - Block::default() - .title(title) - .borders(Borders::ALL) - .border_type(BorderType::Rounded), - ) - .widths([ratatui::prelude::Constraint::Percentage(100)]); + let table = Table::new( + visible_rows, + vec![ratatui::prelude::Constraint::Percentage(100)], + ) + .block( + Block::default() + .title(title) + .borders(Borders::ALL) + .border_type(BorderType::Rounded), + ) + .widths([ratatui::prelude::Constraint::Percentage(100)]); table.render(area, buf); } @@ -423,4 +431,4 @@ impl<'a> BottomPaneView<'a> for ModelSelectionView { self.selected_idx = self.selected_idx.min(self.row_count().saturating_sub(1)); true } -} +} diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 4dc9459f07..65609c7863 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -505,7 +505,9 @@ impl ChatWidget<'_> { if let Ok(contents) = std::fs::read_to_string(&config_path) { if let Ok(cfg) = toml::from_str::(&contents) { let mut config_models: Vec = Vec::new(); - if let Some(m) = cfg.model { config_models.push(m); } + if let Some(m) = cfg.model { + config_models.push(m); + } for (_name, profile) in cfg.profiles.into_iter() { if let Some(m) = profile.model { config_models.push(m); @@ -541,7 +543,6 @@ impl ChatWidget<'_> { self.submit_op(op); self.request_redraw(); } - } impl WidgetRef for &ChatWidget<'_> {