Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(desktop-gpui): cancel Linux Instant starts during the countdown
Aditya Garud1af7bd0c9271
diff --git a/apps/desktop-gpui/src/session.rs b/apps/desktop-gpui/src/session.rsindex ad48a204a..1763a0f74 100644--- a/apps/desktop-gpui/src/session.rs+++ b/apps/desktop-gpui/src/session.rs@@ -1057,11 +1057,6 @@ impl RecordingSession {}pub fn stop(&mut self, cx: &mut Context<Self>) {- if self.phase == Phase::Starting && self.countdown_remaining.is_some() {- self.countdown_remaining = None;- self.finish(cx);- return;- }#[cfg(target_os = "linux")]if matches!(self.phase, Phase::Starting | Phase::Stopping)&& let Some(attempt) = self.instant_attempt.clone()@@ -1072,6 +1067,10 @@ impl RecordingSession {cx.notify();return;}+ self.countdown_remaining = None;+ self.abort_start_cue();+ self.discard_primed(cx);+ self.phase = Phase::Stopping;self.stop_requested = true;let generation = self.recording_generation;let task =@@ -1079,10 +1078,11 @@ impl RecordingSession {cx.spawn(async move |this, cx| {let result = task.await;this.update(cx, |this, cx| {- if this.recording_generation != generation || this.phase != Phase::Starting || this.active.is_some() { return; }+ if this.recording_generation != generation || this.phase != Phase::Stopping || this.active.is_some() { return; }if matches!(result, Ok(cap_recording::instant_recording::InstantQuiescence::Joined)) {this.finish(cx);} else {+ this.phase = Phase::Starting;this.stop_requested = false;this.clean_control.uncertain = true;this.error = Some("Capture cleanup is unconfirmed. Local files are preserved; use Ctrl+Shift+F9 to retry Stop.".into());@@ -1093,6 +1093,11 @@ impl RecordingSession {cx.notify();return;}+ if self.phase == Phase::Starting && self.countdown_remaining.is_some() {+ self.countdown_remaining = None;+ self.finish(cx);+ return;+ }#[cfg(target_os = "linux")]if crate::app_windows::clean_capture_active(cx)&& clean_capture_stop_must_wait(self.phase, self.clean_control.pending_kind())@@ -1968,6 +1973,55 @@ fn recording_failure_is_current(phase: Phase, current: u64, completed: u64) -> bmod countdown_tests {use super::*;+ #[cfg(target_os = "linux")]+ #[tokio::test(flavor = "multi_thread", worker_threads = 2)]+ async fn countdown_stop_cancels_an_unpolled_instant_start() {+ for countdown in [1, 0] {+ let runtime = tokio::runtime::Handle::current();+ gpui_platform::headless().run(move |cx| {+ gpui_tokio::init_from_handle(cx, runtime);+ let session = RecordingSession::init(cx);+ let attempt = recording::InstantAttempt::new();+ let gate = cap_recording::RecordingStartGate::new();+ let (cue_abort, _) = futures_util::future::AbortHandle::new_pair();+ session.update(cx, |session, cx| {+ session.phase = Phase::Starting;+ session.countdown_remaining = Some(countdown);+ session.countdown_cue_abort = Some(cue_abort.clone());+ session.start_gate = Some(gate.clone());+ session.instant_attempt = Some(attempt.clone());+ session.stop(cx);+ assert_eq!(session.countdown_remaining, None);+ });+ assert!(cue_abort.is_aborted());+ assert!(!gate.is_armed());+ assert_eq!(+ attempt.quiescence(),+ cap_recording::instant_recording::InstantQuiescence::Joined+ );+ session.update(cx, |session, cx| session.stop(cx));+ cx.spawn(async move |cx| {+ for _ in 0..500 {+ if session.read_with(cx, |session, _| session.phase) == Phase::Idle {+ break;+ }+ cx.background_executor()+ .timer(Duration::from_millis(10))+ .await;+ }+ cx.update(|cx| {+ cx.quit();+ let session = session.read(cx);+ assert_eq!(session.phase, Phase::Idle);+ assert!(session.error.is_none());+ assert!(session.start_gate.is_none());+ });+ })+ .detach();+ });+ }+ }+#[test]fn countdown_ticks_until_the_final_step_before_start() {assert_eq!(