Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0e6ae12
fix(recording): stop and save a macOS recording when its capture sour…
richiemcilroy Nov 14, 2026
8968dad
style: rustfmt
richiemcilroy Nov 14, 2026
fc2cf30
test(recording): give the macOS stop-order fixture the stopping flag
richiemcilroy Nov 14, 2026
1eb8fe3
test(recording): model the actor's completion sender in the macOS wat…
richiemcilroy Nov 14, 2026
6ac82b7
test(desktop-gpui): run the capture source test on every platform
richiemcilroy Nov 14, 2026
5bd3197
fix(desktop-gpui): only say a lost-source recording was saved when St…
richiemcilroy Nov 14, 2026
35ffc39
test(desktop-gpui): real-app check that closing the recorded window s…
richiemcilroy Nov 14, 2026
24c34e8
Merge remote-tracking branch 'origin/main' into fix/macos-capture-tar…
richiemcilroy Nov 14, 2026
e33c583
test(desktop-gpui): record a TextEdit window and quit TextEdit in the…
richiemcilroy Nov 14, 2026
b3e3fbc
fix(recording): stop and save a macOS window recording when its windo…
richiemcilroy Nov 15, 2026
3e1e1f3
test(desktop-gpui): record the closing window as a focused-window cap…
richiemcilroy Nov 15, 2026
9f5a6b7
test(desktop-gpui): close only the test's TextEdit document instead o…
richiemcilroy Nov 16, 2026
1277bf9
Merge remote-tracking branch 'origin/main' into fix/macos-capture-tar…
richiemcilroy Nov 16, 2026
2a48b76
test(desktop-gpui): end the test's own TextEdit instance instead of s…
richiemcilroy Nov 16, 2026
67e3cd3
Merge remote-tracking branch 'origin/main' into fix/macos-capture-tar…
richiemcilroy Nov 16, 2026
33e4fb4
fix(recording): only watch for a closed window when the stream record…
richiemcilroy Nov 16, 2026
09bbfed
Merge remote-tracking branch 'origin/main' into HEAD
richiemcilroy Nov 16, 2026
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
2 changes: 2 additions & 0 deletions apps/desktop-gpui/locales/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@ devices_changed_before_start = "Die ausgewählten Geräte haben sich vor Beginn
shortcut_conflict = "Ctrl+Shift+F9 ist einer anderen Cap-Aktion zugewiesen. Ändern Sie dieses Kürzel vor der Aufnahme."
shortcut_description = "Diese Cap-Aufnahme starten oder beenden"
shortcut_hint = "Drücken Sie {shortcut} und lassen Sie los, um zu starten. Mit demselben Kürzel beenden Sie die Aufnahme. Dieses vorübergehende Kürzel ändert Ihre Einstellungen nicht."
source_lost = "Cap hat die Aufnahme beendet, weil das Aufnahmeziel nicht mehr verfügbar war, zum Beispiel weil der Bildschirm in den Ruhezustand gewechselt ist oder das Fenster geschlossen wurde. Alles bis dahin Aufgenommene wurde gespeichert."
source_lost_title = "Aufnahme beendet"
tray_stop_hint = "Aktivieren Sie das Cap-Stopp-Symbol in der Taskleiste, um zu starten. Aktivieren Sie es erneut, um zu beenden. Die Aufnahme beginnt erst, wenn Sie dieses Steuerelement verwenden."
window_unavailable = "Das ausgewählte Fenster ist nicht mehr verfügbar. Wählen Sie es erneut aus."

Expand Down
2 changes: 2 additions & 0 deletions apps/desktop-gpui/locales/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,8 @@ devices_changed_before_start = "Selected devices changed before recording starte
shortcut_conflict = "Ctrl+Shift+F9 is assigned to another Cap action. Change that shortcut before recording."
shortcut_description = { text = "Start or stop this Cap recording", context = "Shown by the Linux desktop when it asks the user to approve a global shortcut." }
shortcut_hint = { text = "Press and release {shortcut} to start. Use the same shortcut to stop. This temporary shortcut does not change your settings.", context = "{shortcut} is a key combination such as Ctrl+Shift+F9." }
source_lost = "Cap stopped recording because what it was capturing went away, for example the display went to sleep or the window closed. Everything recorded up to then was saved."
source_lost_title = "Recording stopped"
tray_stop_hint = "Activate the Cap Stop tray icon to start. Activate the same icon again to stop. Recording will not start until you use that control."
window_unavailable = "The selected window is no longer available. Select it again."

Expand Down
2 changes: 2 additions & 0 deletions apps/desktop-gpui/locales/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@ devices_changed_before_start = "Los dispositivos seleccionados cambiaron antes d
shortcut_conflict = "Ctrl+Shift+F9 está asignado a otra acción de Cap. Cambia ese atajo antes de grabar."
shortcut_description = "Iniciar o detener esta grabación de Cap"
shortcut_hint = "Pulsa y suelta {shortcut} para empezar. Usa el mismo atajo para detener. Este atajo temporal no cambia tus ajustes."
source_lost = "Cap detuvo la grabación porque lo que estaba grabando dejó de estar disponible, por ejemplo, la pantalla entró en reposo o se cerró la ventana. Todo lo grabado hasta ese momento se guardó."
source_lost_title = "Grabación detenida"
tray_stop_hint = "Activa el icono de detener de Cap en la bandeja para empezar. Vuelve a activarlo para detener. La grabación no empezará hasta que uses ese control."
window_unavailable = "La ventana seleccionada ya no está disponible. Vuelve a seleccionarla."

Expand Down
2 changes: 2 additions & 0 deletions apps/desktop-gpui/locales/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@ devices_changed_before_start = "Les appareils sélectionnés ont changé avant l
shortcut_conflict = "Ctrl+Shift+F9 est attribué à une autre action de Cap. Modifiez ce raccourci avant d'enregistrer."
shortcut_description = "Lancer ou arrêter cet enregistrement Cap"
shortcut_hint = "Appuyez sur {shortcut} puis relâchez pour démarrer. Utilisez le même raccourci pour arrêter. Ce raccourci temporaire ne modifie pas vos réglages."
source_lost = "Cap a arrêté l'enregistrement, car ce qu'il capturait n'est plus disponible, par exemple l'écran s'est mis en veille ou la fenêtre a été fermée. Tout ce qui a été enregistré jusque-là a été sauvegardé."
source_lost_title = "Enregistrement arrêté"
tray_stop_hint = "Activez l'icône d'arrêt de Cap dans la zone de notification pour démarrer. Activez-la à nouveau pour arrêter. L'enregistrement ne commencera pas tant que vous n'aurez pas utilisé cette commande."
window_unavailable = "La fenêtre sélectionnée n'est plus disponible. Sélectionnez-la à nouveau."

Expand Down
2 changes: 2 additions & 0 deletions apps/desktop-gpui/locales/hi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@ devices_changed_before_start = "रिकॉर्डिंग शुरू ह
shortcut_conflict = "Ctrl+Shift+F9 किसी दूसरे Cap एक्शन को दिया गया है। रिकॉर्ड करने से पहले वह शॉर्टकट बदलें।"
shortcut_description = "यह Cap रिकॉर्डिंग शुरू करें या रोकें"
shortcut_hint = "शुरू करने के लिए {shortcut} दबाकर छोड़ें। रोकने के लिए वही शॉर्टकट इस्तेमाल करें। यह अस्थायी शॉर्टकट आपकी सेटिंग्स नहीं बदलता।"
source_lost = "Cap ने रिकॉर्डिंग रोक दी, क्योंकि जो कैप्चर हो रहा था वह अब उपलब्ध नहीं है, जैसे डिस्प्ले स्लीप में चला गया या विंडो बंद हो गई। तब तक की पूरी रिकॉर्डिंग सेव कर ली गई है।"
source_lost_title = "रिकॉर्डिंग रुक गई"
tray_stop_hint = "शुरू करने के लिए Cap Stop ट्रे आइकन सक्रिय करें। रोकने के लिए वही आइकन फिर से सक्रिय करें। जब तक आप उस कंट्रोल का इस्तेमाल नहीं करते, रिकॉर्डिंग शुरू नहीं होगी।"
window_unavailable = "चुनी गई विंडो अब उपलब्ध नहीं है। इसे फिर से चुनें।"

Expand Down
2 changes: 2 additions & 0 deletions apps/desktop-gpui/locales/ja.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@ devices_changed_before_start = "録画の開始前に選択したデバイスが
shortcut_conflict = "Ctrl+Shift+F9はCapの別の操作に割り当てられています。録画の前にそのショートカットを変更してください。"
shortcut_description = "このCap録画を開始または停止"
shortcut_hint = "{shortcut}を押して離すと開始します。同じショートカットで停止できます。この一時的なショートカットは設定を変更しません。"
source_lost = "録画対象が使用できなくなったため、Capは録画を停止しました(ディスプレイのスリープ、ウィンドウを閉じた場合など)。それまでに録画した内容はすべて保存されています。"
source_lost_title = "録画を停止しました"
tray_stop_hint = "Capの停止トレイアイコンをクリックすると開始します。同じアイコンをもう一度クリックすると停止します。このコントロールを使うまで録画は始まりません。"
window_unavailable = "選択したウィンドウは使用できなくなりました。もう一度選択してください。"

Expand Down
2 changes: 2 additions & 0 deletions apps/desktop-gpui/locales/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@ devices_changed_before_start = "录制开始前所选设备已更改。请重新
shortcut_conflict = "Ctrl+Shift+F9 已分配给另一个 Cap 操作。请在录制前更改该快捷键。"
shortcut_description = "开始或停止此 Cap 录制"
shortcut_hint = "按下并松开 {shortcut} 开始录制。再次使用同一快捷键即可停止。此临时快捷键不会更改你的设置。"
source_lost = "Cap 已停止录制,因为录制的对象已不可用(例如显示器进入睡眠或窗口已关闭)。此前录制的内容已全部保存。"
source_lost_title = "录制已停止"
tray_stop_hint = "点击 Cap 的“停止”托盘图标即可开始。再次点击同一图标即可停止。在你使用该控件之前,录制不会开始。"
window_unavailable = "所选窗口已不可用。请重新选择。"

Expand Down
8 changes: 8 additions & 0 deletions apps/desktop-gpui/src/i18n/dialogs_surface_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ fn dialog_surfaces_match_the_literals_they_replaced() {
tr::dialog::file::unconfirmed(),
"Cap could not confirm that the file dialog closed. Close any remaining file dialog and restart Cap before trying again.",
),
(
tr::dialog::capture::source_lost(),
"Cap stopped recording because what it was capturing went away, for example the display went to sleep or the window closed. Everything recorded up to then was saved.",
),
(
tr::dialog::capture::source_lost_title(),
"Recording stopped",
),
(
tr::dialog::storage::stopped_kept(),
"Recording stopped because storage is low. Your recording files were kept. Free up space, then recover the recording below.",
Expand Down
19 changes: 17 additions & 2 deletions apps/desktop-gpui/src/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,22 @@ impl MainWindow {
}
if phase == Phase::Idle && previous_phase != Phase::Idle {
this.scan_incomplete_recordings(window, cx, std::time::Duration::ZERO);
if let Some(notice) = session.read(cx).storage_notice.clone() {
let notice = {
let session = session.read(cx);
session
.storage_notice
.clone()
.map(|notice| (tr::main::storage::title(), notice))
.or_else(|| {
session.capture_source_lost.then(|| {
Comment thread
capy-ai[bot] marked this conversation as resolved.
Resolved
(
tr::dialog::capture::source_lost_title(),
tr::dialog::capture::source_lost().into(),
)
Comment thread
richiemcilroy marked this conversation as resolved.
Resolved
})
})
};
if let Some((title, notice)) = notice {
let main = cx.global::<app_windows::AppWindows>().main;
cx.spawn(async move |_, cx| {
let receiver = cx.update(|cx| {
Expand All @@ -1088,7 +1103,7 @@ impl MainWindow {
main.update(cx, |_, window, cx| {
window.prompt(
gpui::PromptLevel::Warning,
tr::main::storage::title(),
title,
Some(&notice),
&[gpui::PromptButton::cancel(tr::common::ok())],
cx,
Expand Down
37 changes: 36 additions & 1 deletion apps/desktop-gpui/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ pub struct RecordingSession {
pub error: Option<String>,
pub storage_warning: bool,
pub storage_notice: Option<String>,
/// The last recording stopped because what it captured went away.
pub capture_source_lost: bool,
stopped_for_low_storage: bool,
stopped_elapsed: Option<Duration>,
/// The config of the live (or last) recording, kept for restart.
Expand Down Expand Up @@ -505,6 +507,7 @@ impl RecordingSession {
error: None,
storage_warning: false,
storage_notice: None,
capture_source_lost: false,
stopped_for_low_storage: false,
stopped_elapsed: None,
last_config: None,
Expand Down Expand Up @@ -787,6 +790,7 @@ impl RecordingSession {
self.error = None;
self.storage_warning = false;
self.storage_notice = None;
self.capture_source_lost = false;
self.stopped_for_low_storage = false;
self.stopped_elapsed = None;
self.last_config = Some(config.clone());
Expand Down Expand Up @@ -1093,7 +1097,9 @@ impl RecordingSession {
let generation = self.recording_generation;
let task = gpui_tokio::Tokio::spawn(cx, done);
self.failure_monitor = Some(cx.spawn(async move |this, cx| {
let error = match task.await {
let outcome = task.await;
let source_lost = capture_ended_cleanly(&outcome);
let error = match outcome {
Ok(Ok(())) => "Recording ended unexpectedly.".to_string(),
Ok(Err(error)) => error.to_string(),
Err(error) => format!("Recording completion task failed: {error}"),
Expand All @@ -1104,6 +1110,13 @@ impl RecordingSession {
{
return;
}
if source_lost {
tracing::warn!("capture source went away; stopping and saving the recording");
this.capture_source_lost = true;
this.stop(cx);
cx.notify();
return;
}
tracing::error!(%error, "recording pipeline failed");
this.pipeline_failed = true;
this.error = Some(error);
Expand Down Expand Up @@ -1489,11 +1502,13 @@ impl RecordingSession {
}
Ok(Err(error)) => {
tracing::error!("recording failed to stop cleanly: {error:#}");
this.capture_source_lost = false;
this.storage_notice = low_storage.then(|| tr::dialog::storage::stopped_kept().into());
this.error = Some(format!("{error:#}"));
}
Err(join_error) => {
tracing::error!("recording stop task died: {join_error}");
this.capture_source_lost = false;
this.storage_notice = low_storage.then(|| tr::dialog::storage::stopped_kept().into());
this.error = Some("Stop task failed.".into());
}
Expand Down Expand Up @@ -2200,6 +2215,16 @@ fn sleep_action(
}
}

/// On macOS a pipeline only finishes cleanly before Stop when ScreenCaptureKit
/// lost what it was capturing: the display slept or went away, the window
/// closed, or sharing was stopped from the menu bar. Everything captured so far
/// is intact, so the recording is stopped and saved instead of failed.
fn capture_ended_cleanly<E>(
outcome: &Result<Result<(), cap_recording::PipelineDoneError>, E>,
) -> bool {
cfg!(target_os = "macos") && matches!(outcome, Ok(Ok(())))
}

fn recording_failure_is_current(phase: Phase, current: u64, completed: u64) -> bool {
current == completed && matches!(phase, Phase::Recording { .. })
}
Expand Down Expand Up @@ -2798,6 +2823,16 @@ mod instant_terminal_tests {
mod recording_failure_tests {
use super::*;

/// A capture that lost its source ends cleanly before Stop; it is stopped
/// and saved rather than treated as a failure (#3578).
#[test]
fn a_capture_that_ends_cleanly_before_stop_is_saved_not_failed() {
let ended: Result<Result<(), cap_recording::PipelineDoneError>, ()> = Ok(Ok(()));
assert_eq!(capture_ended_cleanly(&ended), cfg!(target_os = "macos"));
let task_died: Result<Result<(), cap_recording::PipelineDoneError>, ()> = Err(());
assert!(!capture_ended_cleanly(&task_died));
}

#[test]
fn only_current_recording_failure_can_request_stop() {
for paused in [false, true] {
Expand Down
Loading
Loading