Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

feat(tui): default reasoning selection to medium (#7040)

Dylan Hurd1822ffe870e6
diff --git a/codex-rs/tui/src/bottom_pane/list_selection_view.rs b/codex-rs/tui/src/bottom_pane/list_selection_view.rs
index 88fbaf5b53..d294a47265 100644
--- a/codex-rs/tui/src/bottom_pane/list_selection_view.rs
+++ b/codex-rs/tui/src/bottom_pane/list_selection_view.rs
@@ -52,6 +52,7 @@ pub(crate) struct SelectionViewParams {
pub is_searchable: bool,
pub search_placeholder: Option<String>,
pub header: Box<dyn Renderable>,
+ pub initial_selected_idx: Option<usize>,
}
impl Default for SelectionViewParams {
@@ -64,6 +65,7 @@ impl Default for SelectionViewParams {
is_searchable: false,
search_placeholder: None,
header: Box::new(()),
+ initial_selected_idx: None,
}
}
}
@@ -80,6 +82,7 @@ pub(crate) struct ListSelectionView {
filtered_indices: Vec<usize>,
last_selected_actual_idx: Option<usize>,
header: Box<dyn Renderable>,
+ initial_selected_idx: Option<usize>,
}
impl ListSelectionView {
@@ -110,6 +113,7 @@ impl ListSelectionView {
filtered_indices: Vec::new(),
last_selected_actual_idx: None,
header,
+ initial_selected_idx: params.initial_selected_idx,
};
s.apply_filter();
s
@@ -132,7 +136,8 @@ impl ListSelectionView {
(!self.is_searchable)
.then(|| self.items.iter().position(|item| item.is_current))
.flatten()
- });
+ })
+ .or_else(|| self.initial_selected_idx.take());
if self.is_searchable && !self.search_query.is_empty() {
let query_lower = self.search_query.to_lowercase();
diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs
index eb9389b46c..a371fa8cb8 100644
--- a/codex-rs/tui/src/chatwidget.rs
+++ b/codex-rs/tui/src/chatwidget.rs
@@ -2120,6 +2120,14 @@ impl ChatWidget {
} else {
default_choice
};
+ let selection_choice = highlight_choice.or(default_choice);
+ let initial_selected_idx = choices
+ .iter()
+ .position(|choice| choice.stored == selection_choice)
+ .or_else(|| {
+ selection_choice
+ .and_then(|effort| choices.iter().position(|choice| choice.display == effort))
+ });
let mut items: Vec<SelectionItem> = Vec::new();
for choice in choices.iter() {
let effort = choice.display;
@@ -2196,6 +2204,7 @@ impl ChatWidget {
header: Box::new(header),
footer_hint: Some(standard_popup_hint_line()),
items,
+ initial_selected_idx,
..Default::default()
});
}