fix(tui/history): make Shift+Up/Down navigate history in all popups; persist UI-only slash commands to history

This commit is contained in:
James Peter
2025-09-08 10:38:57 +10:00
parent 5970a97798
commit 16c38b6bf4
2 changed files with 26 additions and 4 deletions
+8
View File
@@ -644,6 +644,14 @@ impl App<'_> {
AppState::Onboarding { .. } => {}
},
AppEvent::DispatchCommand(command, command_text) => {
// Persist UI-only slash commands to cross-session history.
// For prompt-expanding commands (/plan, /solve, /code) we let the
// expanded prompt be recorded by the normal submission path.
if !command.is_prompt_expanding() {
let _ = self
.app_event_tx
.send(AppEvent::CodexOp(Op::AddToHistory { text: command_text.clone() }));
}
// Extract command arguments by removing the slash command from the beginning
// e.g., "/browser status" -> "status", "/chrome 9222" -> "9222"
let command_args = {
+18 -4
View File
@@ -597,7 +597,11 @@ impl ChatComposer {
};
match key_event {
KeyEvent { code: KeyCode::Up, .. } => {
// Allow Shift+Up to navigate history even when slash popup is active.
KeyEvent { code: KeyCode::Up, modifiers, .. } => {
if modifiers.contains(KeyModifiers::SHIFT) {
return self.handle_key_event_without_popup(key_event);
}
// If there are 0 or 1 items, let Up behave normally (cursor/history/scroll)
if popup.match_count() <= 1 {
return self.handle_key_event_without_popup(key_event);
@@ -605,7 +609,11 @@ impl ChatComposer {
popup.move_up();
(InputResult::None, true)
}
KeyEvent { code: KeyCode::Down, .. } => {
// Allow Shift+Down to navigate history even when slash popup is active.
KeyEvent { code: KeyCode::Down, modifiers, .. } => {
if modifiers.contains(KeyModifiers::SHIFT) {
return self.handle_key_event_without_popup(key_event);
}
// If there are 0 or 1 items, let Down behave normally (cursor/history/scroll)
if popup.match_count() <= 1 {
return self.handle_key_event_without_popup(key_event);
@@ -731,7 +739,10 @@ impl ChatComposer {
};
match key_event {
KeyEvent { code: KeyCode::Up, .. } => {
KeyEvent { code: KeyCode::Up, modifiers, .. } => {
if modifiers.contains(KeyModifiers::SHIFT) {
return self.handle_key_event_without_popup(key_event);
}
// If there are 0 or 1 items, let Up behave normally (cursor/history/scroll)
if popup.match_count() <= 1 {
return self.handle_key_event_without_popup(key_event);
@@ -739,7 +750,10 @@ impl ChatComposer {
popup.move_up();
(InputResult::None, true)
}
KeyEvent { code: KeyCode::Down, .. } => {
KeyEvent { code: KeyCode::Down, modifiers, .. } => {
if modifiers.contains(KeyModifiers::SHIFT) {
return self.handle_key_event_without_popup(key_event);
}
// If there are 0 or 1 items, let Down behave normally (cursor/history/scroll)
if popup.match_count() <= 1 {
return self.handle_key_event_without_popup(key_event);