Skip to content

Commit a32d305

Browse files
authored
fix: update UI treatment of slash command menu to match that of the TS CLI (#1161)
Uses the same colors as in the TypeScript CLI: ![image](https://github.com/user-attachments/assets/919cd472-ffb4-4654-a46a-d84f0cd9c097) Now it is also readable on a light theme, e.g., in Ghostty: ![image](https://github.com/user-attachments/assets/468c37b0-ea63-4455-9b48-73dc2c95f0f6)
1 parent a768a6a commit a32d305

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

codex-rs/tui/src/bottom_pane/command_popup.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use ratatui::buffer::Buffer;
44
use ratatui::layout::Rect;
55
use ratatui::style::Color;
66
use ratatui::style::Style;
7+
use ratatui::style::Stylize;
78
use ratatui::widgets::Block;
89
use ratatui::widgets::BorderType;
910
use ratatui::widgets::Borders;
@@ -147,8 +148,6 @@ impl CommandPopup {
147148

148149
impl WidgetRef for CommandPopup {
149150
fn render_ref(&self, area: Rect, buf: &mut Buffer) {
150-
let style = Style::default().bg(Color::Blue).fg(Color::White);
151-
152151
let matches = self.filtered_commands();
153152

154153
let mut rows: Vec<Row> = Vec::new();
@@ -157,21 +156,25 @@ impl WidgetRef for CommandPopup {
157156

158157
if visible_matches.is_empty() {
159158
rows.push(Row::new(vec![
160-
Cell::from("").style(style),
161-
Cell::from("No matching commands").style(style.add_modifier(Modifier::ITALIC)),
159+
Cell::from(""),
160+
Cell::from("No matching commands").add_modifier(Modifier::ITALIC),
162161
]));
163162
} else {
163+
let default_style = Style::default();
164+
let command_style = Style::default().fg(Color::LightBlue);
164165
for (idx, cmd) in visible_matches.iter().enumerate() {
165-
let highlight = Style::default().bg(Color::White).fg(Color::Blue);
166-
let cmd_style = if Some(idx) == self.selected_idx {
167-
highlight
166+
let (cmd_style, desc_style) = if Some(idx) == self.selected_idx {
167+
(
168+
command_style.bg(Color::DarkGray),
169+
default_style.bg(Color::DarkGray),
170+
)
168171
} else {
169-
style
172+
(command_style, default_style)
170173
};
171174

172175
rows.push(Row::new(vec![
173-
Cell::from(cmd.command().to_string()).style(cmd_style),
174-
Cell::from(cmd.description().to_string()).style(style),
176+
Cell::from(format!("/{}", cmd.command())).style(cmd_style),
177+
Cell::from(cmd.description().to_string()).style(desc_style),
175178
]));
176179
}
177180
}
@@ -182,13 +185,11 @@ impl WidgetRef for CommandPopup {
182185
rows,
183186
[Constraint::Length(FIRST_COLUMN_WIDTH), Constraint::Min(10)],
184187
)
185-
.style(style)
186-
.column_spacing(1)
188+
.column_spacing(0)
187189
.block(
188190
Block::default()
189191
.borders(Borders::ALL)
190-
.border_type(BorderType::Rounded)
191-
.style(style),
192+
.border_type(BorderType::Rounded),
192193
);
193194

194195
table.render(area, buf);

0 commit comments

Comments
 (0)