diff --git a/crates/call/src/call_impl/room.rs b/crates/call/src/call_impl/room.rs index 2a540619d4576ec7fcf711b288ecc12bf89fd20c..fc15b4e4395ae7aa3100a165d942a6906cf1976d 100644 --- a/crates/call/src/call_impl/room.rs +++ b/crates/call/src/call_impl/room.rs @@ -524,6 +524,16 @@ impl Room { self.id } + pub fn room_id(&self) -> impl Future> + 'static { + let room = self.live_kit.as_ref().map(|lk| lk.room.clone()); + async move { + let room = room?; + let sid = room.sid().await; + let name = room.name(); + Some(format!("{} (sid: {sid})", name)) + } + } + pub fn status(&self) -> RoomStatus { self.status } diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 618348307f1270e180faf4b1d061b9a942e39fa5..7137af21d315391383d3007c148807a7604a1155 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -37,7 +37,7 @@ use ui::{ }; use util::{ResultExt, TryFutureExt, maybe}; use workspace::{ - Deafen, LeaveCall, Mute, OpenChannelNotes, ScreenShare, ShareProject, Workspace, + CopyRoomId, Deafen, LeaveCall, Mute, OpenChannelNotes, ScreenShare, ShareProject, Workspace, dock::{DockPosition, Panel, PanelEvent}, notifications::{DetachAndPromptErr, NotifyResultExt}, }; @@ -128,6 +128,32 @@ pub fn init(cx: &mut App) { workspace.register_action(|_, _: &LeaveCall, window, cx| { CollabPanel::leave_call(window, cx); }); + workspace.register_action(|workspace, _: &CopyRoomId, window, cx| { + use workspace::notifications::{NotificationId, NotifyTaskExt as _}; + + struct RoomIdCopiedToast; + + if let Some(room) = ActiveCall::global(cx).read(cx).room() { + let romo_id_fut = room.read(cx).room_id(); + cx.spawn(async move |workspace, cx| { + let room_id = romo_id_fut.await.context("Failed to get livekit room")?; + workspace.update(cx, |workspace, cx| { + cx.write_to_clipboard(ClipboardItem::new_string(room_id)); + workspace.show_toast( + workspace::Toast::new( + NotificationId::unique::(), + "Room ID copied to clipboard", + ) + .autohide(), + cx, + ); + }) + }) + .detach_and_notify_err(window, cx); + } else { + workspace.show_error(&"There’s no active call; join one first.", cx); + } + }); workspace.register_action(|workspace, _: &ShareProject, window, cx| { let project = workspace.project().clone(); println!("{project:?}"); diff --git a/crates/livekit_client/src/livekit_client.rs b/crates/livekit_client/src/livekit_client.rs index 30a13bd910d52d82a394804e25371f41685437bf..5d31f802c81678478fdb907c479e5cb63cba0487 100644 --- a/crates/livekit_client/src/livekit_client.rs +++ b/crates/livekit_client/src/livekit_client.rs @@ -98,6 +98,14 @@ impl Room { self.room.connection_state() } + pub fn name(&self) -> String { + self.room.name() + } + + pub async fn sid(&self) -> String { + self.room.sid().await.to_string() + } + pub async fn publish_local_microphone_track( &self, user_name: String, diff --git a/crates/livekit_client/src/test.rs b/crates/livekit_client/src/test.rs index fd3163598203ac26443cae1b733372b6c3bdf1d1..a8222b9a18b719f59ccaebdff6e08b7ee4edef67 100644 --- a/crates/livekit_client/src/test.rs +++ b/crates/livekit_client/src/test.rs @@ -714,6 +714,14 @@ impl Room { self.0.lock().token.clone() } + pub fn name(&self) -> String { + "test_room".to_string() + } + + pub async fn sid(&self) -> String { + "RM_test_session".to_string() + } + pub fn play_remote_audio_track( &self, _track: &RemoteAudioTrack, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index aa100550749142b94df034195385c31dd54dbba3..d5a1c3a291c8e337695b30c1e6e1f3b3b76a3a62 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -7236,7 +7236,9 @@ actions!( /// Shares the current project with collaborators. ShareProject, /// Shares your screen with collaborators. - ScreenShare + ScreenShare, + /// Copies the current room name and session id for debugging purposes. + CopyRoomId, ] ); actions!(