From d1a53b2c0e7a365c20a524d75906ae83c6094458 Mon Sep 17 00:00:00 2001 From: Can Celik Date: Wed, 16 Sep 2026 15:16:45 +0300 Subject: fix: keep local usable when remote machines stall (#4234) refs #3903 --- src/client/shell/tests/endpoint_requests.rs | 40 +++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'src/client/shell/tests/endpoint_requests.rs') diff --git a/src/client/shell/tests/endpoint_requests.rs b/src/client/shell/tests/endpoint_requests.rs index b8805596..1f51f06c 100644 --- a/src/client/shell/tests/endpoint_requests.rs +++ b/src/client/shell/tests/endpoint_requests.rs @@ -258,6 +258,42 @@ impl crate::client::endpoint::EndpointTransport for TestTransport { } } +#[test] +fn local_selection_is_scheduled_ahead_of_a_full_event_queue() { + use crate::client::{ + endpoint::{EndpointNegotiation, EndpointRegistry}, + endpoint_commands::EndpointCommands, + ClientLoopEvent, + }; + let mut endpoints = EndpointRegistry::new( + TestTransport { fail: false }, + 1, + EndpointNegotiation::default(), + ); + let mut commands = EndpointCommands::default(); + let (tx, mut rx) = tokio::sync::mpsc::channel(1); + tx.try_send(ClientLoopEvent::Timer).unwrap(); + let mut scheduled = None; + crate::client::shell_runtime::dispatch_client_shell_actions( + vec![ClientShellAction::ActivateEndpoint { + endpoint_id: ClientEndpointId::Local, + target: Some(ClientEndpointFocusTarget::Workspace("ws_1".into())), + }], + &mut commands, + &mut endpoints, + None, + &mut Vec::new(), + &mut scheduled, + ) + .unwrap(); + let next = scheduled.take().or_else(|| rx.try_recv().ok()); + assert!(matches!(next, Some(ClientLoopEvent::ActivateEndpoint { + endpoint_id: ClientEndpointId::Local, + target: Some(ClientEndpointFocusTarget::Workspace(id)), .. + }) if id == "ws_1")); + assert!(matches!(rx.try_recv(), Ok(ClientLoopEvent::Timer))); +} + #[test] fn dispatcher_cancels_worktree_requests_on_frozen_surface_or_failed_send() { use crate::client::endpoint::{EndpointNegotiation, EndpointRegistry}; @@ -272,14 +308,14 @@ fn dispatcher_cancels_worktree_requests_on_frozen_surface_or_failed_send() { ); endpoints.set_surface_active(&ClientEndpointId::Local, fail_send); let mut commands = EndpointCommands::default(); - let (tx, _rx) = tokio::sync::mpsc::channel(16); + let mut scheduled = None; let (replay, repaint) = crate::client::shell_runtime::dispatch_client_shell_actions( actions, &mut commands, &mut endpoints, Some(&mut state), &mut Vec::new(), - &tx, + &mut scheduled, ) .unwrap(); assert!(repaint); -- cgit v1.2.3