collab: Add action to copy room id (#44004)

Adds a `collab: copy room id` action which copies the live kit room name
and session ID to the clipboard.

Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga
2025-12-02 16:27:36 +00:00
committed by GitHub
parent 2db237aa52
commit 3d58738548
5 changed files with 56 additions and 2 deletions
+10
View File
@@ -524,6 +524,16 @@ impl Room {
self.id
}
pub fn room_id(&self) -> impl Future<Output = Option<String>> + '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
}
+27 -1
View File
@@ -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::<RoomIdCopiedToast>(),
"Room ID copied to clipboard",
)
.autohide(),
cx,
);
})
})
.detach_and_notify_err(window, cx);
} else {
workspace.show_error(&"Theres no active call; join one first.", cx);
}
});
workspace.register_action(|workspace, _: &ShareProject, window, cx| {
let project = workspace.project().clone();
println!("{project:?}");
@@ -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,
+8
View File
@@ -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,
+3 -1
View File
@@ -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!(