the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix(input): preserve shift-tab in pane automation (#2259)
Can Celikadb50cba9b15
diff --git a/docs/next/CHANGELOG.md b/docs/next/CHANGELOG.mdindex 7d1b9620c..09f220dc4 100644--- a/docs/next/CHANGELOG.md+++ b/docs/next/CHANGELOG.md@@ -5,6 +5,9 @@### Added- The plugin marketplace now discovers valid manifests at repository roots and subdirectories, groups multiple plugins under each repository, and publishes their versions and exact default-branch commits.+### Fixed+- `pane send-keys` and `agent send-keys` now preserve Shift when sending `shift+tab`, allowing agent permission modes to be cycled programmatically. (#1561, thanks @keinstn and @tomohisa)+## [0.8.0] - 2026-08-03### Addeddiff --git a/src/app/api/panes.rs b/src/app/api/panes.rsindex 72798a1b7..a5f1cbcbf 100644--- a/src/app/api/panes.rs+++ b/src/app/api/panes.rs@@ -1978,6 +1978,24 @@ mod tests {assert!(rx.try_recv().is_err());}+ #[tokio::test]+ async fn api_pane_send_keys_encodes_shift_tab_as_backtab() {+ let (mut app, pane_id, mut rx) = app_with_send_key_runtime(1);++ let response = app.handle_api_request(crate::api::schema::Request {+ id: "req".into(),+ method: crate::api::schema::Method::PaneSendKeys(PaneSendKeysParams {+ pane_id,+ keys: vec!["shift+tab".into()],+ }),+ });++ let success: SuccessResponse = serde_json::from_str(&response).unwrap();+ assert_eq!(success.result, ResponseResult::Ok {});+ assert_eq!(rx.try_recv().unwrap(), bytes::Bytes::from_static(b"\x1b[Z"));+ assert!(rx.try_recv().is_err());+ }+#[tokio::test]async fn api_pane_get_exposes_scroll_metrics() {let (mut app, public_pane_id, pane_id) = app_with_scrollback_runtime();diff --git a/src/pane/input.rs b/src/pane/input.rsindex 38e8138b5..2e60bfc8c 100644--- a/src/pane/input.rs+++ b/src/pane/input.rs@@ -13,7 +13,12 @@ pub(super) fn ghostty_key_event_from_terminal_key(crate::ghostty::ffi::GhosttyKeyAction_GHOSTTY_KEY_ACTION_REPEAT}});- event.set_mods(ghostty_mods_from_key_modifiers(key.modifiers));+ let mut mods = ghostty_mods_from_key_modifiers(key.modifiers);+ if matches!(key.code, crossterm::event::KeyCode::BackTab) {+ // Ghostty represents backtab as Tab with Shift rather than a distinct key.+ mods |= crate::ghostty::MOD_SHIFT;+ }+ event.set_mods(mods);event.set_key(ghostty_key_from_crossterm_key_code(key.code,key.shifted_codepoint,diff --git a/src/pane/terminal.rs b/src/pane/terminal.rsindex b90c63f13..d4f167a9f 100644--- a/src/pane/terminal.rs+++ b/src/pane/terminal.rs@@ -3856,6 +3856,45 @@ mod tests {assert_eq!(encoded, b"a");}+ #[test]+ fn ghostty_backtab_preserves_shift_across_keyboard_protocols() {+ for (kitty_flags, expected) in [+ (None, b"\x1b[Z".as_slice()),+ (Some(1), b"\x1b[9;2u".as_slice()),+ ] {+ let (tx, _rx) = mpsc::channel(4);+ let mut terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap();+ if let Some(flags) = kitty_flags {+ terminal.write(format!("\x1b[>{flags}u").as_bytes());+ }+ let pane = GhosttyPaneTerminal::new(terminal, tx).unwrap();+ let protocol = pane.keyboard_protocol().unwrap();++ for modifiers in [+ crossterm::event::KeyModifiers::empty(),+ crossterm::event::KeyModifiers::SHIFT,+ ] {+ let encoded = pane.encode_terminal_key(+ crate::input::TerminalKey::new(crossterm::event::KeyCode::BackTab, modifiers),+ protocol,+ );+ assert_eq!(encoded, expected, "backtab with modifiers {modifiers:?}");+ }+ }++ let (tx, _rx) = mpsc::channel(4);+ let terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap();+ let pane = GhosttyPaneTerminal::new(terminal, tx).unwrap();+ let encoded = pane.encode_terminal_key(+ crate::input::TerminalKey::new(+ crossterm::event::KeyCode::Tab,+ crossterm::event::KeyModifiers::empty(),+ ),+ crate::input::KeyboardProtocol::Legacy,+ );+ assert_eq!(encoded, b"\t");+ }+#[test]fn ghostty_enter_backspace_release_in_legacy_pane_emits_nothing() {let (tx, _rx) = mpsc::channel(4);