bring back shortcuts

This commit is contained in:
Roy Han
2026-03-02 18:23:38 -08:00
parent 5295338f0f
commit cefe70e10e
6 changed files with 30 additions and 14 deletions
@@ -367,6 +367,9 @@ impl ApprovalOverlay {
let prefix_label = format!("{prefix} {}. ", idx + 1);
GenericDisplayRow {
name: format!("{prefix_label}{}", option.label),
display_shortcut: option
.display_shortcut
.or_else(|| option.additional_shortcuts.first().copied()),
wrap_indent: Some(UnicodeWidthStr::width(prefix_label.as_str())),
..Default::default()
}
@@ -1275,7 +1278,7 @@ fn patch_options() -> Vec<ApprovalOption> {
ApprovalOption {
label: "No, and tell Codex what to do differently".to_string(),
decision: ApprovalDecision::PatchRejectWithNotes,
display_shortcut: None,
display_shortcut: Some(key_hint::plain(KeyCode::Tab)),
additional_shortcuts: vec![key_hint::plain(KeyCode::Char('n'))],
},
]
@@ -1850,12 +1853,24 @@ mod tests {
}
#[test]
fn patch_option_three_no_longer_shows_esc_shortcut() {
fn patch_options_show_expected_shortcuts() {
let (tx, _rx) = unbounded_channel::<AppEvent>();
let tx = AppEventSender::new(tx);
let view = ApprovalOverlay::new(make_patch_request(), tx, Features::with_defaults());
let rendered = render_overlay_lines(&view, 80);
assert!(
rendered.contains("(y)"),
"patch option should show y shortcut: {rendered}"
);
assert!(
rendered.contains("(a)"),
"patch option should show a shortcut: {rendered}"
);
assert!(
rendered.contains("(tab)"),
"patch option should show tab shortcut: {rendered}"
);
assert!(
!rendered.contains("(esc)"),
"patch option should not show esc shortcut: {rendered}"
@@ -13,9 +13,9 @@ expression: "render_overlay_lines(&view, 80)"
1 +hello
2 +world
1. Yes, proceed
2. Yes, and don't ask again for these files
› 3. No, and tell Codex what to do differently
1. Yes, proceed (y)
2. Yes, and don't ask again for these files (a)
› 3. No, and tell Codex what to do differently (tab)
enter to send | tab to go back | esc to interrupt
› split the changes by file
@@ -13,7 +13,7 @@ expression: "render_overlay_lines(&view, 80)"
1 +hello
2 +world
1. Yes, proceed
2. Yes, and don't ask again for these files
› 3. No, and tell Codex what to do differently
1. Yes, proceed (y)
2. Yes, and don't ask again for these files (a)
› 3. No, and tell Codex what to do differently (tab)
tab to follow up | esc to interrupt
@@ -14,7 +14,7 @@ expression: terminal.backend().vt100().screen().contents()
1 +hello
2 +world
› 1. Yes, proceed
2. Yes, and don't ask again for these files
3. No, and tell Codex what to do differently
› 1. Yes, proceed (y)
2. Yes, and don't ask again for these files (a)
3. No, and tell Codex what to do differently (tab)
esc to interrupt
@@ -14,9 +14,9 @@ expression: terminal.backend().vt100().screen().contents()
1 +hello
2 +world
1. Yes, proceed
2. Yes, and don't ask again for these files
› 3. No, and tell Codex what to do differently
1. Yes, proceed (y)
2. Yes, and don't ask again for these files (a)
› 3. No, and tell Codex what to do differently (tab)
enter to send | tab to go back | esc to interrupt
› split the edits into smaller commits
+1
View File
@@ -2162,6 +2162,7 @@ pub(crate) fn new_patch_event(
pub(crate) fn new_patch_apply_failure(stderr: String) -> PlainHistoryCell {
let mut lines: Vec<Line<'static>> = Vec::new();
// Failure title
lines.push(Line::from("✘ Failed to apply patch".magenta().bold()));
if !stderr.trim().is_empty() {