Fix deafened -> enabled mistranslation

Mikayla Maki created

Fix mislocation of caller query in detach_and_log_error
Fix incorrect wording on livekit integration
Add share_mic action for manually enabling the microphone
Make mic sharing wait until the room has been fully established

Change summary

crates/call/src/room.rs            | 24 +++++++++++++-----------
crates/collab_ui/src/collab_ui.rs  |  9 ++++++++-
crates/gpui/src/executor.rs        |  2 +-
crates/live_kit_client/src/prod.rs |  2 +-
4 files changed, 23 insertions(+), 14 deletions(-)

Detailed changes

crates/call/src/room.rs 🔗

@@ -220,15 +220,6 @@ impl Room {
                 None
             };
 
-            if option_env!("START_MIC").is_some()
-                || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev
-            {
-                let share_mic = room.update(&mut cx, |room, cx| room.share_mic(cx));
-                cx.update(|cx| {
-                    cx.background().spawn(share_mic).detach_and_log_err(cx);
-                });
-            }
-
             match room
                 .update(&mut cx, |room, cx| {
                     room.leave_when_empty = true;
@@ -236,7 +227,18 @@ impl Room {
                 })
                 .await
             {
-                Ok(()) => Ok(room),
+                Ok(()) => {
+                    if option_env!("START_MIC").is_some()
+                        || &*util::channel::RELEASE_CHANNEL != &ReleaseChannel::Dev
+                    {
+                        let share_mic = room.update(&mut cx, |room, cx| room.share_mic(cx));
+                        cx.update(|cx| {
+                            cx.background().spawn(share_mic).detach_and_log_err(cx);
+                        });
+                    }
+
+                    Ok(room)
+                },
                 Err(error) => Err(anyhow!("room creation failed: {:?}", error)),
             }
         })
@@ -1201,7 +1203,7 @@ impl Room {
                     .room
                     .remote_audio_track_publications(&participant.user.id.to_string())
                 {
-                    tasks.push(cx.background().spawn(track.set_enabled(live_kit.deafened)));
+                    tasks.push(cx.background().spawn(track.set_enabled(!live_kit.deafened)));
                 }
             }
 

crates/collab_ui/src/collab_ui.rs 🔗

@@ -16,7 +16,7 @@ use std::sync::Arc;
 use util::ResultExt;
 use workspace::AppState;
 
-actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen]);
+actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen, ShareMic]);
 
 pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
     collab_titlebar_item::init(cx);
@@ -30,6 +30,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
     cx.add_global_action(toggle_screen_sharing);
     cx.add_global_action(toggle_mute);
     cx.add_global_action(toggle_deafen);
+    cx.add_global_action(share_mic);
 }
 
 pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
@@ -60,3 +61,9 @@ pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
             .log_err();
     }
 }
+
+pub fn share_mic(_: &ShareMic, cx: &mut AppContext) {
+    if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
+        room.update(cx, Room::share_mic).detach_and_log_err(cx)
+    }
+}

crates/gpui/src/executor.rs 🔗

@@ -968,9 +968,9 @@ impl<T> Task<T> {
 impl<T: 'static, E: 'static + Display> Task<Result<T, E>> {
     #[track_caller]
     pub fn detach_and_log_err(self, cx: &mut AppContext) {
+        let caller = Location::caller();
         cx.spawn(|_| async move {
             if let Err(err) = self.await {
-                let caller = Location::caller();
                 log::error!("{}:{}: {:#}", caller.file(), caller.line(), err);
             }
         })

crates/live_kit_client/src/prod.rs 🔗

@@ -259,7 +259,7 @@ impl Room {
                 Box::into_raw(Box::new(tx)) as *mut c_void,
             );
         }
-        async { rx.await.unwrap().context("error publishing video track") }
+        async { rx.await.unwrap().context("error publishing audio track") }
     }
 
     pub fn unpublish_track(&self, publication: LocalTrackPublication) {