This commit is contained in:
pap
2025-07-29 23:20:24 +01:00
parent 1836614c06
commit f78f8d8c7c
7 changed files with 34 additions and 33 deletions
+2 -1
View File
@@ -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);
+1 -1
View File
@@ -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;
+1 -9
View File
@@ -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"]
}
+2 -3
View File
@@ -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);
}
}
}
}
+2 -2
View File
@@ -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
}
}
}
+3 -2
View File
@@ -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<'_> {