mirror of
https://github.com/openai/codex.git
synced 2026-11-22 23:00:42 +00:00
refactor(tui): move keymap details to footer
Keep shortcut rows focused on section, status, action, and binding. Move selected action descriptions into the footer note and add a compact legend for custom and unbound shortcut markers.
This commit is contained in:
@@ -135,6 +135,7 @@ pub(crate) struct SelectionItem {
|
||||
pub display_shortcut: Option<KeyBinding>,
|
||||
pub description: Option<String>,
|
||||
pub selected_description: Option<String>,
|
||||
pub selected_footer_note: Option<String>,
|
||||
pub is_current: bool,
|
||||
pub is_default: bool,
|
||||
pub is_disabled: bool,
|
||||
@@ -393,6 +394,20 @@ impl ListSelectionView {
|
||||
.and_then(|visible_idx| self.filtered_indices.get(visible_idx).copied())
|
||||
}
|
||||
|
||||
fn selected_footer_note_line(&self) -> Option<Line<'static>> {
|
||||
let selected_item = self
|
||||
.selected_actual_idx()
|
||||
.and_then(|actual_idx| self.active_items().get(actual_idx));
|
||||
|
||||
selected_item
|
||||
.and_then(|item| {
|
||||
item.selected_footer_note
|
||||
.as_ref()
|
||||
.map(|note| Line::from(note.clone()).dim())
|
||||
})
|
||||
.or_else(|| self.footer_note.clone())
|
||||
}
|
||||
|
||||
fn apply_filter(&mut self) {
|
||||
let previously_selected = self
|
||||
.selected_actual_idx()
|
||||
@@ -967,9 +982,9 @@ impl Renderable for ListSelectionView {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(note) = &self.footer_note {
|
||||
if let Some(note) = self.selected_footer_note_line() {
|
||||
let note_width = width.saturating_sub(2);
|
||||
let note_lines = wrap_styled_line(note, note_width);
|
||||
let note_lines = wrap_styled_line(¬e, note_width);
|
||||
height = height.saturating_add(note_lines.len() as u16);
|
||||
}
|
||||
if self.footer_hint.is_some() {
|
||||
@@ -984,8 +999,8 @@ impl Renderable for ListSelectionView {
|
||||
}
|
||||
|
||||
let note_width = area.width.saturating_sub(2);
|
||||
let note_lines = self
|
||||
.footer_note
|
||||
let note_line = self.selected_footer_note_line();
|
||||
let note_lines = note_line
|
||||
.as_ref()
|
||||
.map(|note| wrap_styled_line(note, note_width));
|
||||
let note_height = note_lines.as_ref().map_or(0, |lines| lines.len() as u16);
|
||||
|
||||
@@ -957,7 +957,7 @@ mod tests {
|
||||
composer_tab
|
||||
.items
|
||||
.iter()
|
||||
.any(|item| item.description.as_deref() == Some("ctrl-enter · Custom"))
|
||||
.any(|item| item.description.as_deref() == Some("ctrl-enter"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -971,7 +971,7 @@ mod tests {
|
||||
assert_eq!(unbound_tab.items[0].name, "Toggle Vim Mode");
|
||||
assert_eq!(
|
||||
unbound_tab.items[0].description.as_deref(),
|
||||
Some("unbound · Default")
|
||||
Some("unbound")
|
||||
);
|
||||
assert!(!unbound_tab.items[0].is_disabled);
|
||||
}
|
||||
|
||||
@@ -290,7 +290,11 @@ fn keymap_selection_items<'a>(
|
||||
fn keymap_selection_item(row: &KeymapActionRow) -> SelectionItem {
|
||||
let context = row.context.to_string();
|
||||
let action = row.action.to_string();
|
||||
let source = keymap_source_label(row);
|
||||
let source = if row.custom_binding {
|
||||
"Custom"
|
||||
} else {
|
||||
"Default"
|
||||
};
|
||||
let search_value = format!(
|
||||
"{} {} {} {} {} {}",
|
||||
row.context_label, row.action, row.label, row.description, row.binding_summary, source
|
||||
@@ -299,13 +303,8 @@ fn keymap_selection_item(row: &KeymapActionRow) -> SelectionItem {
|
||||
SelectionItem {
|
||||
name: row.label.clone(),
|
||||
name_prefix_spans: keymap_row_prefix(row),
|
||||
description: Some(format!("{} · {source}", row.binding_summary)),
|
||||
selected_description: Some(format!(
|
||||
"{} · {}. {}",
|
||||
current_binding_sentence(row),
|
||||
keymap_source_sentence(row),
|
||||
row.description
|
||||
)),
|
||||
description: Some(row.binding_summary.clone()),
|
||||
selected_footer_note: Some(format!("{}: {}", row.label, row.description)),
|
||||
actions: vec![Box::new(move |tx| {
|
||||
tx.send(AppEvent::OpenKeymapActionMenu {
|
||||
context: context.clone(),
|
||||
@@ -338,30 +337,6 @@ fn keymap_row_prefix(row: &KeymapActionRow) -> Vec<Span<'static>> {
|
||||
]
|
||||
}
|
||||
|
||||
fn keymap_source_label(row: &KeymapActionRow) -> &'static str {
|
||||
if row.custom_binding {
|
||||
"Custom"
|
||||
} else {
|
||||
"Default"
|
||||
}
|
||||
}
|
||||
|
||||
fn keymap_source_sentence(row: &KeymapActionRow) -> &'static str {
|
||||
if row.custom_binding {
|
||||
"Custom root override"
|
||||
} else {
|
||||
"Default keymap"
|
||||
}
|
||||
}
|
||||
|
||||
fn current_binding_sentence(row: &KeymapActionRow) -> String {
|
||||
if row.is_unbound() {
|
||||
"Unbound".to_string()
|
||||
} else {
|
||||
format!("Current {}", row.binding_summary)
|
||||
}
|
||||
}
|
||||
|
||||
fn keymap_header(description: String, summary: String) -> Box<dyn Renderable> {
|
||||
let mut header = ColumnRenderable::new();
|
||||
header.push(Line::from("Keymap".bold()));
|
||||
@@ -383,6 +358,10 @@ fn keymap_picker_hint_line() -> Line<'static> {
|
||||
" group · ".dim(),
|
||||
"enter".cyan(),
|
||||
" edit shortcut · ".dim(),
|
||||
"*".cyan(),
|
||||
" custom · ".dim(),
|
||||
"-".cyan(),
|
||||
" unbound · ".dim(),
|
||||
"esc".cyan(),
|
||||
" close".dim(),
|
||||
])
|
||||
|
||||
+12
-12
@@ -2,15 +2,15 @@
|
||||
source: tui/src/keymap_setup.rs
|
||||
expression: snapshot
|
||||
---
|
||||
Open Transcript | ctrl-t · Default | Global open_transcript Open Transcript Open the transcript overlay. ctrl-t Default
|
||||
Open External Editor | ctrl-g · Default | Global open_external_editor Open External Editor Open the current draft in an external editor. ctrl-g Default
|
||||
Copy | ctrl-o · Default | Global copy Copy Copy the last agent response to the clipboard. ctrl-o Default
|
||||
Toggle Vim Mode | unbound · Default | Global toggle_vim_mode Toggle Vim Mode Turn Vim composer mode on or off. unbound Default
|
||||
Edit Previous Message | esc · Default | Chat edit_previous_message Edit Previous Message Begin or advance edit-previous-message when the composer is empty. esc Default
|
||||
Confirm Edit Previous Message | enter · Default | Chat confirm_edit_previous_message Confirm Edit Previous Message Confirm the selected previous message to edit. enter Default
|
||||
Submit | enter · Default | Composer submit Submit Submit the current composer draft. enter Default
|
||||
Queue | tab · Default | Composer queue Queue Queue the draft while a task is running. tab Default
|
||||
Toggle Shortcuts | ?, shift-? · Default | Composer toggle_shortcuts Toggle Shortcuts Show or hide the composer shortcut overlay. ?, shift-? Default
|
||||
Insert Newline | ctrl-j, ctrl-m, enter, shift-enter · Default | Editor insert_newline Insert Newline Insert a newline in the editor. ctrl-j, ctrl-m, enter, shift-enter Default
|
||||
Move Left | left, ctrl-b · Default | Editor move_left Move Left Move the cursor left. left, ctrl-b Default
|
||||
Move Right | right, ctrl-f · Default | Editor move_right Move Right Move the cursor right. right, ctrl-f Default
|
||||
Open Transcript | ctrl-t | Global open_transcript Open Transcript Open the transcript overlay. ctrl-t Default
|
||||
Open External Editor | ctrl-g | Global open_external_editor Open External Editor Open the current draft in an external editor. ctrl-g Default
|
||||
Copy | ctrl-o | Global copy Copy Copy the last agent response to the clipboard. ctrl-o Default
|
||||
Toggle Vim Mode | unbound | Global toggle_vim_mode Toggle Vim Mode Turn Vim composer mode on or off. unbound Default
|
||||
Edit Previous Message | esc | Chat edit_previous_message Edit Previous Message Begin or advance edit-previous-message when the composer is empty. esc Default
|
||||
Confirm Edit Previous Message | enter | Chat confirm_edit_previous_message Confirm Edit Previous Message Confirm the selected previous message to edit. enter Default
|
||||
Submit | enter | Composer submit Submit Submit the current composer draft. enter Default
|
||||
Queue | tab | Composer queue Queue Queue the draft while a task is running. tab Default
|
||||
Toggle Shortcuts | ?, shift-? | Composer toggle_shortcuts Toggle Shortcuts Show or hide the composer shortcut overlay. ?, shift-? Default
|
||||
Insert Newline | ctrl-j, ctrl-m, enter, shift-enter | Editor insert_newline Insert Newline Insert a newline in the editor. ctrl-j, ctrl-m, enter, shift-enter Default
|
||||
Move Left | left, ctrl-b | Editor move_left Move Left Move the cursor left. left, ctrl-b Default
|
||||
Move Right | right, ctrl-f | Editor move_right Move Right Move the cursor right. right, ctrl-f Default
|
||||
|
||||
+10
-9
@@ -10,13 +10,14 @@ expression: "render_picker(params, 120)"
|
||||
[All] Common Customized (1) Unbound (1) App Composer Editor Vim Navigation Approval
|
||||
|
||||
Type to search shortcuts
|
||||
› Global Open Transcript Current ctrl-t · Default keymap. Open the transcript overlay.
|
||||
Global Open External Editor ctrl-g · Default
|
||||
Global Copy ctrl-o · Default
|
||||
Global - Toggle Vim Mode unbound · Default
|
||||
Chat Edit Previous Message esc · Default
|
||||
Chat Confirm Edit Previous Message enter · Default
|
||||
Composer * Submit ctrl-enter · Custom
|
||||
Composer Queue tab · Default
|
||||
› Global Open Transcript ctrl-t
|
||||
Global Open External Editor ctrl-g
|
||||
Global Copy ctrl-o
|
||||
Global - Toggle Vim Mode unbound
|
||||
Chat Edit Previous Message esc
|
||||
Chat Confirm Edit Previous Message enter
|
||||
Composer * Submit ctrl-enter
|
||||
Composer Queue tab
|
||||
|
||||
left/right group · enter edit shortcut · esc close
|
||||
Open Transcript: Open the transcript overlay.
|
||||
left/right group · enter edit shortcut · * custom · - unbound · esc close
|
||||
|
||||
+12
-12
@@ -12,15 +12,15 @@ tab: Editor (16 selectable)
|
||||
tab: Vim (34 selectable)
|
||||
tab: Navigation (17 selectable)
|
||||
tab: Approval (6 selectable)
|
||||
Open Transcript | ctrl-t · Default | Global open_transcript Open Transcript Open the transcript overlay. ctrl-t Default
|
||||
Open External Editor | ctrl-g · Default | Global open_external_editor Open External Editor Open the current draft in an external editor. ctrl-g Default
|
||||
Copy | ctrl-o · Default | Global copy Copy Copy the last agent response to the clipboard. ctrl-o Default
|
||||
Toggle Vim Mode | unbound · Default | Global toggle_vim_mode Toggle Vim Mode Turn Vim composer mode on or off. unbound Default
|
||||
Edit Previous Message | esc · Default | Chat edit_previous_message Edit Previous Message Begin or advance edit-previous-message when the composer is empty. esc Default
|
||||
Confirm Edit Previous Message | enter · Default | Chat confirm_edit_previous_message Confirm Edit Previous Message Confirm the selected previous message to edit. enter Default
|
||||
Submit | enter · Default | Composer submit Submit Submit the current composer draft. enter Default
|
||||
Queue | tab · Default | Composer queue Queue Queue the draft while a task is running. tab Default
|
||||
Toggle Shortcuts | ?, shift-? · Default | Composer toggle_shortcuts Toggle Shortcuts Show or hide the composer shortcut overlay. ?, shift-? Default
|
||||
Insert Newline | ctrl-j, ctrl-m, enter, shift-enter · Default | Editor insert_newline Insert Newline Insert a newline in the editor. ctrl-j, ctrl-m, enter, shift-enter Default
|
||||
Move Left | left, ctrl-b · Default | Editor move_left Move Left Move the cursor left. left, ctrl-b Default
|
||||
Move Right | right, ctrl-f · Default | Editor move_right Move Right Move the cursor right. right, ctrl-f Default
|
||||
Open Transcript | ctrl-t | Global open_transcript Open Transcript Open the transcript overlay. ctrl-t Default
|
||||
Open External Editor | ctrl-g | Global open_external_editor Open External Editor Open the current draft in an external editor. ctrl-g Default
|
||||
Copy | ctrl-o | Global copy Copy Copy the last agent response to the clipboard. ctrl-o Default
|
||||
Toggle Vim Mode | unbound | Global toggle_vim_mode Toggle Vim Mode Turn Vim composer mode on or off. unbound Default
|
||||
Edit Previous Message | esc | Chat edit_previous_message Edit Previous Message Begin or advance edit-previous-message when the composer is empty. esc Default
|
||||
Confirm Edit Previous Message | enter | Chat confirm_edit_previous_message Confirm Edit Previous Message Confirm the selected previous message to edit. enter Default
|
||||
Submit | enter | Composer submit Submit Submit the current composer draft. enter Default
|
||||
Queue | tab | Composer queue Queue Queue the draft while a task is running. tab Default
|
||||
Toggle Shortcuts | ?, shift-? | Composer toggle_shortcuts Toggle Shortcuts Show or hide the composer shortcut overlay. ?, shift-? Default
|
||||
Insert Newline | ctrl-j, ctrl-m, enter, shift-enter | Editor insert_newline Insert Newline Insert a newline in the editor. ctrl-j, ctrl-m, enter, shift-enter Default
|
||||
Move Left | left, ctrl-b | Editor move_left Move Left Move the cursor left. left, ctrl-b Default
|
||||
Move Right | right, ctrl-f | Editor move_right Move Right Move the cursor right. right, ctrl-f Default
|
||||
|
||||
+10
-9
@@ -11,13 +11,14 @@ expression: "render_picker(params, 78)"
|
||||
Navigation Approval
|
||||
|
||||
Type to search shortcuts
|
||||
› Global Open Transcript Current ctrl-t · Default ke…
|
||||
Global Open External Editor ctrl-g · Default
|
||||
Global Copy ctrl-o · Default
|
||||
Global - Toggle Vim Mode unbound · Default
|
||||
Chat Edit Previous Message esc · Default
|
||||
Chat Confirm Edit Previous Message enter · Default
|
||||
Composer Submit enter · Default
|
||||
Composer Queue tab · Default
|
||||
› Global Open Transcript ctrl-t
|
||||
Global Open External Editor ctrl-g
|
||||
Global Copy ctrl-o
|
||||
Global - Toggle Vim Mode unbound
|
||||
Chat Edit Previous Message esc
|
||||
Chat Confirm Edit Previous Message enter
|
||||
Composer Submit enter
|
||||
Composer Queue tab
|
||||
|
||||
left/right group · enter edit shortcut · esc close
|
||||
Open Transcript: Open the transcript overlay.
|
||||
left/right group · enter edit shortcut · * custom · - unbound · esc close
|
||||
|
||||
@@ -10,13 +10,14 @@ expression: "render_picker(params, 120)"
|
||||
[All] Common Customized (0) Unbound (1) App Composer Editor Vim Navigation Approval
|
||||
|
||||
Type to search shortcuts
|
||||
› Global Open Transcript Current ctrl-t · Default keymap. Open the transcript overlay.
|
||||
Global Open External Editor ctrl-g · Default
|
||||
Global Copy ctrl-o · Default
|
||||
Global - Toggle Vim Mode unbound · Default
|
||||
Chat Edit Previous Message esc · Default
|
||||
Chat Confirm Edit Previous Message enter · Default
|
||||
Composer Submit enter · Default
|
||||
Composer Queue tab · Default
|
||||
› Global Open Transcript ctrl-t
|
||||
Global Open External Editor ctrl-g
|
||||
Global Copy ctrl-o
|
||||
Global - Toggle Vim Mode unbound
|
||||
Chat Edit Previous Message esc
|
||||
Chat Confirm Edit Previous Message enter
|
||||
Composer Submit enter
|
||||
Composer Queue tab
|
||||
|
||||
left/right group · enter edit shortcut · esc close
|
||||
Open Transcript: Open the transcript overlay.
|
||||
left/right group · enter edit shortcut · * custom · - unbound · esc close
|
||||
|
||||
Reference in New Issue
Block a user