From e061fbaebc84ae7c3b6777c1782bf4cc454a5254 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Wed, 25 Mar 2026 22:46:46 +0100 Subject: [PATCH] call: Update call location when active multi workspace changes (#52441) ## Context This fixes a participant location out of sync bug when the active workspace changes in a multi workspace. It wouldn't update the project id, which breaks following. ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A --- crates/call/src/call_impl/mod.rs | 34 ++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/call/src/call_impl/mod.rs b/crates/call/src/call_impl/mod.rs index e060ec5edae6277a92c2c09ab54ded449bc56e11..b4bad6d2f350c3caa03eccbb8ca6582a71c6128c 100644 --- a/crates/call/src/call_impl/mod.rs +++ b/crates/call/src/call_impl/mod.rs @@ -17,8 +17,8 @@ use room::Event; use settings::Settings; use std::sync::Arc; use workspace::{ - ActiveCallEvent, AnyActiveCall, GlobalAnyActiveCall, Pane, RemoteCollaborator, SharedScreen, - Workspace, + ActiveCallEvent, AnyActiveCall, GlobalAnyActiveCall, MultiWorkspace, MultiWorkspaceEvent, Pane, + RemoteCollaborator, SharedScreen, Workspace, }; pub use livekit_client::{RemoteVideoTrack, RemoteVideoTrackView, RemoteVideoTrackViewEvent}; @@ -28,6 +28,36 @@ use crate::call_settings::CallSettings; pub fn init(client: Arc, user_store: Entity, cx: &mut App) { let active_call = cx.new(|cx| ActiveCall::new(client, user_store, cx)); + let active_call_handle = active_call.downgrade(); + + cx.observe_new(move |_multi_workspace: &mut MultiWorkspace, window, cx| { + let Some(window) = window else { + return; + }; + + let active_call_handle = active_call_handle.clone(); + cx.subscribe_in( + &cx.entity(), + window, + move |multi_workspace, _, event: &MultiWorkspaceEvent, window, cx| { + if !matches!(event, MultiWorkspaceEvent::ActiveWorkspaceChanged) + && window.is_window_active() + { + return; + } + + let project = multi_workspace.workspace().read(cx).project().clone(); + if let Ok(task) = active_call_handle.update(cx, |active_call, cx| { + active_call.set_location(Some(&project), cx) + }) { + task.detach_and_log_err(cx); + } + }, + ) + .detach(); + }) + .detach(); + cx.set_global(GlobalAnyActiveCall(Arc::new(ActiveCallEntity(active_call)))) }