aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-16 15:29:45 +0300
committerGitHub <noreply@github.com>2026-09-16 15:29:45 +0300
commit68ae6adea0add496cea227030c94e5d3172f4e86 (patch)
treee34f103d9e738bedb493eb5d8a3e52633e2310b9 /src
parentd1a53b2c0e7a365c20a524d75906ae83c6094458 (diff)
fix: let local agent clicks cancel remote handoffs (#4236)
refs #3903
Diffstat (limited to 'src')
-rw-r--r--src/client/shell/endpoint_navigation.rs20
-rw-r--r--src/client/shell/tests/endpoints.rs31
2 files changed, 36 insertions, 15 deletions
diff --git a/src/client/shell/endpoint_navigation.rs b/src/client/shell/endpoint_navigation.rs
index 542bf3f9..6cb8c2c4 100644
--- a/src/client/shell/endpoint_navigation.rs
+++ b/src/client/shell/endpoint_navigation.rs
@@ -92,21 +92,11 @@ impl ClientShellState {
else {
return false;
};
- if !self.endpoint_is_online(&endpoint_id) {
- let label = self.endpoint_label(&endpoint_id).to_owned();
- self.receive_endpoint_unavailable(format!("{label} is reconnecting"));
- outcome.repaint = true;
- } else if endpoint_id == self.active_endpoint_id {
- self.push_endpoint_method(
- crate::api::schema::Method::PaneFocus(crate::api::schema::PaneTarget { pane_id }),
- outcome,
- );
- } else {
- outcome.actions.push(ClientShellAction::ActivateEndpoint {
- endpoint_id,
- target: Some(ClientEndpointFocusTarget::Pane(pane_id)),
- });
- }
+ self.focus_or_activate(
+ endpoint_id,
+ ClientEndpointFocusTarget::Pane(pane_id),
+ outcome,
+ );
true
}
diff --git a/src/client/shell/tests/endpoints.rs b/src/client/shell/tests/endpoints.rs
index 5c00e645..846806f1 100644
--- a/src/client/shell/tests/endpoints.rs
+++ b/src/client/shell/tests/endpoints.rs
@@ -150,6 +150,37 @@ fn switching_machines_preserves_aggregate_agent_scroll_and_visible_rows() {
}
#[test]
+fn local_agent_click_can_cancel_a_pending_remote_switch() {
+ for reconnecting in [false, true] {
+ let (mut state, remote) = state_with_scrollable_agents();
+ assert!(state.activate_endpoint(remote, &mut ClientShellInput::default()));
+ if reconnecting {
+ state.mark_endpoint_disconnected(&ClientEndpointId::Local);
+ }
+ state.compose(100, 28).unwrap();
+ let (rect, _, pane_id) = state
+ .hits
+ .endpoint_agents
+ .iter()
+ .find(|(_, endpoint, _)| endpoint.is_local())
+ .unwrap()
+ .clone();
+ let outcome = state.handle_raw_events(vec![RawInputEvent::Mouse(MouseEvent {
+ kind: MouseEventKind::Down(MouseButton::Left),
+ column: rect.x + 2,
+ row: rect.y,
+ modifiers: KeyModifiers::NONE,
+ })]);
+ assert!(
+ matches!(outcome.actions.as_slice(), [ClientShellAction::ActivateEndpoint {
+ endpoint_id: ClientEndpointId::Local,
+ target: Some(ClientEndpointFocusTarget::Pane(target)),
+ }] if target == &pane_id)
+ );
+ }
+}
+
+#[test]
fn aggregate_agent_scroll_still_clamps_when_rows_shrink_on_activation() {
let (mut state, remote) = state_with_scrollable_agents();
for endpoint_id in [ClientEndpointId::Local, remote.clone()] {