aboutsummaryrefslogtreecommitdiff
path: root/src/app/input/navigate.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-20 00:54:05 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-20 00:55:36 +0300
commitd30ab1b54f6b6be95a0cb47ddc38da1d5e088700 (patch)
treeeb2002b408c856d9fcd7a573afe73b917f22cd97 /src/app/input/navigate.rs
parent3f80947678a9723434aa7fddfe23750b5393e24c (diff)
feat: add plugin-driven agent views and startup hooks
Diffstat (limited to 'src/app/input/navigate.rs')
-rw-r--r--src/app/input/navigate.rs48
1 files changed, 40 insertions, 8 deletions
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))
@@ -1877,6 +1876,39 @@ mod tests {
}
#[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"]);