Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/desktop-gpui/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActiveRecording>,
/// 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<bool>,
/// 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<Task<Result<(), tokio::task::JoinError>>>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -750,12 +756,17 @@ impl RecordingSession {
) -> std::pin::Pin<Box<dyn Future<Output = ()>>> {
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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Capture can precede the cue

This wait can outlast the gate’s 20-second failsafe. The gate is created before prepare_instant_upload, so a slow request such as the reported 102-second case leaves it expired when capture starts. The first media check then opens the gate before the delayed cue finishes. The cue’s later arm() cannot replace that start time, so the saved recording can include the cue and unwanted lead-in.

Keep the gate closed through the readiness wait, and start its failsafe clock when capture is ready.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/session.rs
Line: 769

Comment:
**Capture can precede the cue**

This wait can outlast the gate’s 20-second failsafe. The gate is created before `prepare_instant_upload`, so a slow request such as the reported 102-second case leaves it expired when capture starts. The first media check then opens the gate before the delayed cue finishes. The cue’s later `arm()` cannot replace that start time, so the saved recording can include the cue and unwanted lead-in.

Keep the gate closed through the readiness wait, and start its failsafe clock when capture is ready.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Readiness wait has no tests

The new wait has no test that exercises it. Existing countdown tests check countdown_advance, and the stop test installs an abort handle without starting play_start_cue. The timing behavior this fix depends on could regress without those tests catching it.

Add tests that hold readiness false, release it, and cancel or fail while waiting. Check that neither the cue nor the gate fires early and that an old attempt cannot release a new cue.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/session.rs
Line: 769

Comment:
**Readiness wait has no tests**

The new wait has no test that exercises it. Existing countdown tests check `countdown_advance`, and the stop test installs an abort handle without starting `play_start_cue`. The timing behavior this fix depends on could regress without those tests catching it.

Add tests that hold readiness false, release it, and cancel or fail while waiting. Check that neither the cue nor the gate fires early and that an old attempt cannot release a new cue.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

match cue {
Some(cue) => crate::app_sounds::play_recording_start_sound(cue, gate).await,
None => {
Expand Down Expand Up @@ -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 {
Expand Down