From 5cd4bfe231ed401325469b8f04be0f24439b2972 Mon Sep 17 00:00:00 2001 From: heidar-droid Date: Sat, 24 Oct 2026 02:28:14 +0200 Subject: [PATCH] fix(desktop-gpui): hold the start cue until capture is ready In Instant mode, start_internal awaits prepare_instant_upload (a network round trip to create the shareable link) before the capture pipeline is built, but the start cue plays on the countdown regardless. On a slow or busy uplink the cue played 2-10 s (once 102 s) before capture began, so the user started talking into nothing and the opening was lost. The cue now waits on an engine_ready watch that flips when the current start resolves Ok. Failed starts still abort the cue via abort_start_cue, and Studio mode (no network on start) is unaffected. Fixes #3035 --- apps/desktop-gpui/src/session.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/desktop-gpui/src/session.rs b/apps/desktop-gpui/src/session.rs index 1763a0f74aa..71cf7ad4a74 100644 --- a/apps/desktop-gpui/src/session.rs +++ b/apps/desktop-gpui/src/session.rs @@ -440,6 +440,10 @@ pub struct RecordingSession { /// A capture pipeline that finished warming up while the countdown or the /// start cue was still running; activated the moment the cue ends. primed: Option, + /// Flips to `true` once the current start's capture pipeline is built. + /// The start cue waits on it, so the cue never plays while start-up + /// (e.g. Instant mode creating the shareable link) is still in flight. + engine_ready: tokio::sync::watch::Sender, /// Teardown of a cancelled primed start still releasing its devices; the /// next start waits for it before locking the mic and camera again. discarding: Option>>, @@ -488,6 +492,7 @@ impl RecordingSession { start_gate: None, start_cue: None, primed: None, + engine_ready: tokio::sync::watch::channel(false).0, discarding: None, pause_control: PauseControlState::default(), pause_control_error: None, @@ -665,6 +670,7 @@ impl RecordingSession { self.start_gate = Some(start_gate); self.start_cue = Some(crate::app_sounds::prime_recording_start_sound()); self.discard_primed(cx); + self.engine_ready.send_replace(false); self.pause_control.invalidate(); self.pause_control.uncertain = false; self.pause_control_error = None; @@ -750,12 +756,17 @@ impl RecordingSession { ) -> std::pin::Pin>> { let gate = self.start_gate.clone().unwrap_or_default(); let cue = self.start_cue.take(); + let mut engine_ready = self.engine_ready.subscribe(); let (abort, registration) = futures_util::future::AbortHandle::new_pair(); self.countdown_cue_abort = Some(abort); let task = gpui_tokio::Tokio::spawn( cx, futures_util::future::Abortable::new( async move { + // The cue tells the user recording has started, so hold it + // until capture can actually begin. A failed start aborts + // this future through `abort_start_cue`. + let _ = engine_ready.wait_for(|ready| *ready).await; match cue { Some(cue) => crate::app_sounds::play_recording_start_sound(cue, gate).await, None => { @@ -840,6 +851,7 @@ impl RecordingSession { } match result { Ok(Ok(active)) => { + this.engine_ready.send_replace(true); if this.countdown_remaining.is_some() { this.primed = Some(active); } else {