Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(desktop-gpui): raise the camera outside the gpui borrow and re-test overlay activation
Richie McIlroy77a2f41f6268
diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rsindex e6a00c55a..db702d9d9 100644--- a/apps/desktop-gpui/src/app_windows.rs+++ b/apps/desktop-gpui/src/app_windows.rs@@ -2606,7 +2606,7 @@ fn open_overlay(window.refresh();}).ok();- cx.update(raise_camera_above_overlays);+ raise_camera_above_overlays(cx);}).detach();}@@ -4334,24 +4334,32 @@ pub(crate) fn studio_camera_snapshot(/// Keep the camera bubble above the picker overlays. Not filtered on/// `window_is_visible` off macOS: Windows' camera is shown asynchronously and/// X11 has no visibility probe, and neither raise path shows a hidden window.-pub(crate) fn raise_camera_above_overlays(cx: &mut App) {- if camera_preview_is_inline(cx) {+/// Lift the camera preview back over the picker overlays. The raise runs+/// outside any gpui update: ordering a window front calls straight back into+/// gpui, which drops those callbacks while the app is borrowed.+pub(crate) fn raise_camera_above_overlays(cx: &mut gpui::AsyncApp) {+ let Some(camera) = cx.update(camera_to_raise) else {return;+ };+ if let Err(error) = camera.raise() {+ tracing::warn!(%error, "could not raise the camera above the target picker");+ }+}++fn camera_to_raise(cx: &mut App) -> Option<CameraFrame> {+ if camera_preview_is_inline(cx) {+ return None;}#[cfg(target_os = "linux")]if clean_capture_active(cx) {- return;+ return None;}- let Some(camera) = camera_frame(cx) else {- return;- };+ let camera = camera_frame(cx)?;#[cfg(target_os = "macos")]if !camera.visible {- return;- }- if let Err(error) = camera.raise() {- tracing::warn!(%error, "could not raise the camera above the target picker");+ return None;}+ Some(camera)}fn camera_snapshot(cx: &mut App) -> Option<CameraSnapshot> {diff --git a/apps/desktop-gpui/src/picker_probe.rs b/apps/desktop-gpui/src/picker_probe.rsindex ab2f84819..ce902c2bd 100644--- a/apps/desktop-gpui/src/picker_probe.rs+++ b/apps/desktop-gpui/src/picker_probe.rs@@ -48,15 +48,31 @@ pub fn run(main: WindowHandle<MainWindow>, cx: &mut App) {)});}+ // Opening an overlay already raises the camera, so hand focus to+ // the main window first: the activation below then has to raise+ // it again by itself.+ main.update(cx, |_, window, _| window.activate_window())+ .ok();+ sleep(cx, 600).await;+ let overlays = cx.update(|cx| cx.global::<app_windows::AppWindows>().overlays.clone());+ let inactive_before = cx.update(|cx| {+ overlays.iter().all(|(_, overlay)| {+ overlay+ .update(cx, |_, window, _| !window.is_window_active())+ .unwrap_or(true)+ })+ });cx.update(|cx| {- for (_, overlay) in cx.global::<app_windows::AppWindows>().overlays.clone() {+ for (_, overlay) in &overlays {overlay.update(cx, |_, window, _| window.activate_window()).ok();}});sleep(cx, 800).await;- modes.push(cx.update(|cx| probe_mode(label, cx)));+ let mut mode = cx.update(|cx| probe_mode(label, cx));+ mode["overlayInactiveBeforeActivation"] = inactive_before.into();+ modes.push(mode);cx.update(app_windows::dismiss_target_overlays);sleep(cx, 400).await;}diff --git a/apps/desktop-gpui/src/target_overlay.rs b/apps/desktop-gpui/src/target_overlay.rsindex 4afc0e5ce..12a15e054 100644--- a/apps/desktop-gpui/src/target_overlay.rs+++ b/apps/desktop-gpui/src/target_overlay.rs@@ -903,7 +903,8 @@ impl OverlayWindow {// lifts it to the top of its band on Windows and X11, over the camera.cx.observe_window_activation(window, |_, window, cx| {if window.is_window_active() {- cx.defer(app_windows::raise_camera_above_overlays);+ cx.spawn(async move |_, cx| app_windows::raise_camera_above_overlays(cx))+ .detach();}}).detach();diff --git a/scripts/picker-smoke/run.sh b/scripts/picker-smoke/run.shindex 7241a4981..5b5d13fd2 100755--- a/scripts/picker-smoke/run.sh+++ b/scripts/picker-smoke/run.sh@@ -1,8 +1,4 @@#!/usr/bin/env bash-# Runs cap-gpui's picker probe (src/picker_probe.rs) in a throwaway profile and-# fails unless every check in its report passed.-#-# scripts/picker-smoke/run.sh <cap-gpui binary> <out dir>set -euo pipefailAPP=$1