Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Disable auto watch when leaving a call (#57196)
Joseph T. Lyonsa11af2049536
diff --git a/crates/call/src/call_impl/mod.rs b/crates/call/src/call_impl/mod.rsindex 2dba55134a1..6b87c4d8555 100644--- a/crates/call/src/call_impl/mod.rs+++ b/crates/call/src/call_impl/mod.rs@@ -222,6 +222,7 @@ impl AnyActiveCall for ActiveCallEntity {room::Event::LocalScreenShareStopped => {Some(ActiveCallEvent::LocalScreenShareStopped)}+ room::Event::RoomLeft { .. } => Some(ActiveCallEvent::RoomLeft),_ => None,};if let Some(event) = mapped {diff --git a/crates/collab/tests/integration/auto_watch_tests.rs b/crates/collab/tests/integration/auto_watch_tests.rsindex f119e1a4af4..9a1a29c7ead 100644--- a/crates/collab/tests/integration/auto_watch_tests.rs+++ b/crates/collab/tests/integration/auto_watch_tests.rs@@ -430,6 +430,48 @@ async fn test_auto_watch_is_disabled_when_following_collaborator(});}+#[gpui::test]+async fn test_auto_watch_is_disabled_when_leaving_call(+ executor: BackgroundExecutor,+ user_a: &mut TestAppContext,+ user_b: &mut TestAppContext,+ user_c: &mut TestAppContext,+) {+ let mut server = TestServer::start(executor.clone()).await;+ let setup = setup_auto_watch_test(&mut server, user_a, user_b, user_c).await;+ let (workspace_a, user_a) = setup+ .client_a+ .build_workspace(&setup.user_a_project, user_a);++ workspace_a.update_in(user_a, |workspace, window, cx| {+ workspace.toggle_auto_watch(window, cx);+ });+ executor.run_until_parked();++ workspace_a.update(user_a, |workspace, _cx| {+ assert_eq!(+ *workspace.auto_watch_state(),+ AutoWatch::Active { watched_peer: None },+ "auto-watch should be enabled after toggling on"+ );+ });++ let active_call_a = user_a.read(ActiveCall::global);+ active_call_a+ .update(user_a, |call, cx| call.hang_up(cx))+ .await+ .unwrap();+ executor.run_until_parked();++ workspace_a.update(user_a, |workspace, _cx| {+ assert_eq!(+ *workspace.auto_watch_state(),+ AutoWatch::Off,+ "auto-watch should be off after leaving the call"+ );+ });+}+#[track_caller]fn assert_no_screen_share_tabs_exist(workspace: &Workspace, message: &str, cx: &App) {let has_shared_screen_tab = workspacediff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 0f529fc9362..b3bafd0bb6b 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -6685,6 +6685,12 @@ impl Workspace {ActiveCallEvent::LocalScreenShareStopped => {self.handle_auto_watch_local_share_stopped(window, cx);}+ ActiveCallEvent::RoomLeft => {+ if self.auto_watch.enabled() {+ self.auto_watch = AutoWatch::Off;+ cx.notify();+ }+ }}}@@ -8136,6 +8142,7 @@ pub enum ActiveCallEvent {RemoteVideoTracksChanged { participant_id: PeerId },LocalScreenShareStarted,LocalScreenShareStopped,+ RoomLeft,}fn leader_border_for_pane(