From d30ab1b54f6b6be95a0cb47ddc38da1d5e088700 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Mon, 20 Jul 2026 00:54:05 +0300 Subject: feat: add plugin-driven agent views and startup hooks --- src/app/input/navigate.rs | 48 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'src/app/input/navigate.rs') diff --git a/src/app/input/navigate.rs b/src/app/input/navigate.rs index e1ffeb5d..d151b94d 100644 --- a/src/app/input/navigate.rs +++ b/src/app/input/navigate.rs @@ -724,14 +724,13 @@ impl App { .and_then(crate::workspace::Workspace::focused_pane_id); let current_idx = entries .iter() - .position(|entry| Some(entry.pane_id) == focused) - .unwrap_or(0); - let next_idx = if forward { - (current_idx + 1) % entries.len() - } else if current_idx == 0 { - entries.len() - 1 - } else { - current_idx - 1 + .position(|entry| Some(entry.pane_id) == focused); + let next_idx = match (current_idx, forward) { + (Some(idx), true) => (idx + 1) % entries.len(), + (Some(0), false) => entries.len() - 1, + (Some(idx), false) => idx - 1, + (None, true) => 0, + (None, false) => entries.len() - 1, }; let target = entries.get(next_idx)?; Some((next_idx, target.ws_idx, target.pane_id)) @@ -1876,6 +1875,39 @@ mod tests { app } + #[test] + fn next_agent_starts_at_first_visible_entry_when_focused_agent_is_filtered_out() { + let mut app = app_with_test_workspaces(&["hidden", "first", "second"]); + for ws_idx in 0..app.state.workspaces.len() { + let pane_id = app.state.workspaces[ws_idx].tabs[0].root_pane; + let terminal_id = app.state.workspaces[ws_idx].tabs[0].panes[&pane_id] + .attached_terminal_id + .clone(); + let terminal = app.state.terminals.get_mut(&terminal_id).unwrap(); + terminal.detected_agent = Some(crate::detect::Agent::Claude); + terminal.state = if ws_idx == 0 { + crate::detect::AgentState::Idle + } else { + crate::detect::AgentState::Working + }; + } + app.state.agent_view_override = Some(crate::api::schema::AgentViewSetParams { + source: "example.views".to_string(), + label: None, + filter: Some(crate::api::schema::AgentViewFilter::Eq { + field: crate::api::schema::AgentViewField::Builtin( + crate::api::schema::AgentViewBuiltinField::Status, + ), + value: crate::api::schema::AgentViewValue::String("working".to_string()), + }), + sort: Vec::new(), + }); + + app.execute_tui_navigate_action(NavigateAction::NextAgent, ActionContext::Prefix); + + assert_eq!(app.state.active, Some(1)); + } + #[test] fn default_goto_key_opens_navigator() { let mut state = state_with_workspaces(&["test"]); -- cgit v1.2.3