Skip to content

armgit / herdr

Public Imported from GitHub
0

the runtime your coding agents live on

fix: match navigator search terms independently (#4535)

Eric Yueb7781a67e2d7
diff --git a/src/client/shell/aggregate_navigation.rs b/src/client/shell/aggregate_navigation.rs
index b1a4d35fe..67753e8ef 100644
--- a/src/client/shell/aggregate_navigation.rs
+++ b/src/client/shell/aggregate_navigation.rs
@@ -288,7 +288,14 @@ pub(super) fn navigator_rows(
Some(ClientNavigatorFilter::Done) => status == crate::api::schema::AgentStatus::Done,
None => true,
};
- let text = |value: &str| query.is_empty() || value.to_lowercase().contains(&query);
+ let words = query.split_whitespace().collect::<Vec<_>>();
+ let text = |value: &str| {
+ if words.is_empty() {
+ return true;
+ }
+ let value = value.to_lowercase();
+ words.iter().all(|word| value.contains(word))
+ };
let filtering = navigator.filter.is_some() || !query.is_empty();
let federated = endpoints.len() > 1;
let depth_offset = u8::from(federated);
diff --git a/src/client/shell/tests/copy.rs b/src/client/shell/tests/copy.rs
index 617af89b6..112417fce 100644
--- a/src/client/shell/tests/copy.rs
+++ b/src/client/shell/tests/copy.rs
@@ -1080,6 +1080,42 @@ fn navigator_renders_every_terminal_in_workspace_sections() {
assert!(visible.iter().all(|row| !row.contains("second")));
}
+#[test]
+fn navigator_search_matches_non_adjacent_words_without_losing_the_pane_target() {
+ let mut projected = snapshot();
+ projected.panes[0].label = Some("alpha beta gamma".into());
+ let mut state = ClientShellState::new(ClientShellConfig::from_config(&Config::default()));
+ state.set_snapshot(Box::new(projected));
+ state.set_pane_surface(surface());
+ state.open_navigator_overlay();
+ let Some(ClientShellOverlay::Navigator(navigator)) = state.overlay.as_mut() else {
+ panic!("navigator");
+ };
+ for (query, matches) in [
+ ("alpha gamma", true),
+ (" ALP\tGAM ", true),
+ ("gamma alpha", true),
+ ("beta gamma", true),
+ ("alpha missing", false),
+ ("alphagamma", false),
+ ] {
+ navigator.query = query.into();
+ navigator.selected = None;
+ let rows =
+ render::client_navigator_rows(&state.endpoints, &state.active_endpoint_id, navigator);
+ let target =
+ super::super::aggregate_navigation::selected_navigator_target(&rows, navigator);
+ assert_eq!(
+ target,
+ matches.then(|| ClientNavigatorTarget::Pane {
+ endpoint_id: state.active_endpoint_id.clone(),
+ pane_id: "pane_1".into(),
+ }),
+ "query={query:?}"
+ );
+ }
+}
+
#[test]
fn navigator_searches_ancestor_context_and_keeps_split_agents_individually_actionable() {
let mut projected = snapshot();