Skip to content

Commit 5beb616

Browse files
0xRaduanclaudeetraut-openai
authored
feat(tui): Display keyboard shortcuts inline for approval options (#5889)
Shows single-key shortcuts (y, a, n) next to approval options to make them more discoverable. Previously these shortcuts worked but were hidden, making the feature hard to discover. Changes: - "Yes, proceed" now shows "y" shortcut - "Yes, and don't ask again" now shows "a" shortcut - "No, and tell Codex..." continues to show "esc" shortcut This improves UX by surfacing the quick keyboard shortcuts that were already functional but undiscoverable in the UI. --- Update: added parentheses for better visual clarity <img width="1540" height="486" alt="CleanShot 2025-11-05 at 11 47 07@2x" src="https://github.com/user-attachments/assets/f951c34a-9ec8-4b81-b151-7b2ccba94658" /> --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Eric Traut <[email protected]>
1 parent 917f39e commit 5beb616

7 files changed

+27
-21
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ impl ApprovalOverlay {
117117
.iter()
118118
.map(|opt| SelectionItem {
119119
name: opt.label.clone(),
120-
display_shortcut: opt.display_shortcut,
120+
display_shortcut: opt
121+
.display_shortcut
122+
.or_else(|| opt.additional_shortcuts.first().copied()),
121123
dismiss_on_select: false,
122124
..Default::default()
123125
})

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use ratatui::layout::Rect;
33
// Note: Table-based layout previously used Constraint; the manual renderer
44
// below no longer requires it.
55
use ratatui::style::Color;
6+
use ratatui::style::Style;
67
use ratatui::style::Stylize;
78
use ratatui::text::Line;
89
use ratatui::text::Span;
@@ -96,8 +97,9 @@ fn build_full_line(row: &GenericDisplayRow, desc_col: usize) -> Line<'static> {
9697
let this_name_width = Line::from(name_spans.clone()).width();
9798
let mut full_spans: Vec<Span> = name_spans;
9899
if let Some(display_shortcut) = row.display_shortcut {
99-
full_spans.push(" ".into());
100+
full_spans.push(" (".into());
100101
full_spans.push(display_shortcut.into());
102+
full_spans.push(")".into());
101103
}
102104
if let Some(desc) = row.description.as_ref() {
103105
let gap = desc_col.saturating_sub(this_name_width);
@@ -179,8 +181,9 @@ pub(crate) fn render_rows(
179181
);
180182
if Some(i) == state.selected_idx {
181183
// Match previous behavior: cyan + bold for the selected row.
184+
// Reset the style first to avoid inheriting dim from keyboard shortcuts.
182185
full_line.spans.iter_mut().for_each(|span| {
183-
span.style = span.style.fg(Color::Cyan).bold();
186+
span.style = Style::default().fg(Color::Cyan).bold();
184187
});
185188
}
186189

codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ expression: terminal.backend().vt100().screen().contents()
99

1010
$ echo hello world
1111

12-
1. Yes, proceed
13-
2. Yes, and don't ask again for this command
14-
3. No, and tell Codex what to do differently esc
12+
1. Yes, proceed (y)
13+
2. Yes, and don't ask again for this command (a)
14+
3. No, and tell Codex what to do differently (esc)
1515

1616
Press enter to confirm or esc to cancel

codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec_no_reason.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ expression: terminal.backend().vt100().screen().contents()
66

77
$ echo hello world
88

9-
1. Yes, proceed
10-
2. Yes, and don't ask again for this command
11-
3. No, and tell Codex what to do differently esc
9+
1. Yes, proceed (y)
10+
2. Yes, and don't ask again for this command (a)
11+
3. No, and tell Codex what to do differently (esc)
1212

1313
Press enter to confirm or esc to cancel

codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_patch.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ expression: terminal.backend().vt100().screen().contents()
1111
1 +hello
1212
2 +world
1313

14-
1. Yes, proceed
15-
2. No, and tell Codex what to do differently esc
14+
1. Yes, proceed (y)
15+
2. No, and tell Codex what to do differently (esc)
1616

1717
Press enter to confirm or esc to cancel

codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__exec_approval_modal_exec.snap

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: tui/src/chatwidget/tests.rs
3-
assertion_line: 409
43
expression: "format!(\"{buf:?}\")"
54
---
65
Buffer {
@@ -15,9 +14,9 @@ Buffer {
1514
" ",
1615
" $ echo hello world ",
1716
" ",
18-
"› 1. Yes, proceed ",
19-
" 2. Yes, and don't ask again for this command ",
20-
" 3. No, and tell Codex what to do differently esc ",
17+
"› 1. Yes, proceed (y) ",
18+
" 2. Yes, and don't ask again for this command (a) ",
19+
" 3. No, and tell Codex what to do differently (esc) ",
2120
" ",
2221
" Press enter to confirm or esc to cancel ",
2322
],
@@ -30,9 +29,11 @@ Buffer {
3029
x: 2, y: 5, fg: Reset, bg: Reset, underline: Reset, modifier: ITALIC,
3130
x: 7, y: 5, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
3231
x: 0, y: 9, fg: Cyan, bg: Reset, underline: Reset, modifier: BOLD,
33-
x: 17, y: 9, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
34-
x: 47, y: 11, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
35-
x: 50, y: 11, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
32+
x: 21, y: 9, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
33+
x: 48, y: 10, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
34+
x: 49, y: 10, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
35+
x: 48, y: 11, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
36+
x: 51, y: 11, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
3637
x: 2, y: 13, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
3738
]
3839
}

codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__status_widget_and_approval_modal.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ expression: terminal.backend()
1212
" "
1313
" $ echo 'hello world' "
1414
" "
15-
"› 1. Yes, proceed "
16-
" 2. Yes, and don't ask again for this command "
17-
" 3. No, and tell Codex what to do differently esc "
15+
"› 1. Yes, proceed (y) "
16+
" 2. Yes, and don't ask again for this command (a) "
17+
" 3. No, and tell Codex what to do differently (esc) "
1818
" "
1919
" Press enter to confirm or esc to cancel "

0 commit comments

Comments
 (0)