mirror of
https://github.com/openai/codex.git
synced 2026-12-01 00:20:48 +00:00
fmt
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -72,13 +72,5 @@ pub(crate) fn get_model_info(name: &str) -> Option<ModelInfo> {
|
||||
|
||||
/// 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"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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<usize>, 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,7 +505,9 @@ impl ChatWidget<'_> {
|
||||
if let Ok(contents) = std::fs::read_to_string(&config_path) {
|
||||
if let Ok(cfg) = toml::from_str::<ConfigToml>(&contents) {
|
||||
let mut config_models: Vec<String> = 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<'_> {
|
||||
|
||||
Reference in New Issue
Block a user