From 8d5dca8cfe2d580835d3392d0ebdff57f7de7298 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Mon, 11 May 2026 23:47:51 +0300 Subject: feat: add notification target keybind --- src/app/input/navigate.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/app/input/navigate.rs') diff --git a/src/app/input/navigate.rs b/src/app/input/navigate.rs index bb88c46b..ce3d9cf4 100644 --- a/src/app/input/navigate.rs +++ b/src/app/input/navigate.rs @@ -380,6 +380,7 @@ pub(crate) enum NavigateAction { EnterResizeMode, ToggleSidebar, ReloadConfig, + OpenNotificationTarget, Detach, } @@ -463,6 +464,12 @@ fn navigate_action_for_key(state: &AppState, key: &KeyEvent) -> Option { + state.focus_toast_target(); + if state.mode == Mode::Navigate { + leave_navigate_mode(state); + } + } NavigateAction::Detach => { state.detach_requested = true; leave_navigate_mode(state); @@ -652,6 +665,38 @@ mod tests { assert_eq!(state.mode, Mode::Terminal); } + #[test] + fn custom_open_notification_key_focuses_current_toast_target() { + let mut state = state_with_workspaces(&["one", "two"]); + state.active = Some(0); + state.selected = 0; + state.mode = Mode::Navigate; + state.keybinds.open_notification_target = Some((KeyCode::Char('g'), KeyModifiers::empty())); + state.keybinds.open_notification_target_label = Some("g".into()); + let target_workspace_id = state.workspaces[1].id.clone(); + let target_pane = state.workspaces[1].tabs[0].root_pane; + state.toast = Some(crate::app::state::ToastNotification { + kind: crate::app::state::ToastKind::NeedsAttention, + title: "pi needs attention".into(), + context: "two".into(), + target: Some(crate::app::state::ToastTarget { + workspace_id: target_workspace_id, + pane_id: target_pane, + }), + }); + + handle_navigate_key( + &mut state, + KeyEvent::new(KeyCode::Char('g'), KeyModifiers::empty()), + ); + + assert_eq!(state.active, Some(1)); + assert_eq!(state.selected, 1); + assert_eq!(state.workspaces[1].focused_pane_id(), Some(target_pane)); + assert!(state.toast.is_none()); + assert_eq!(state.mode, Mode::Terminal); + } + #[test] fn movement_action_stays_in_navigate_mode() { let mut state = state_with_workspaces(&["a", "b"]); -- cgit v1.2.3