Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: retire Tauri Dock presence during GPUI handoff
Richie McIlroy94cdc7a1f38c
diff --git a/apps/desktop/src-tauri/src/gpui_app.rs b/apps/desktop/src-tauri/src/gpui_app.rsindex 480954238..d352638a2 100644--- a/apps/desktop/src-tauri/src/gpui_app.rs+++ b/apps/desktop/src-tauri/src/gpui_app.rs@@ -862,6 +862,26 @@ fn spawn_detached(path: &std::path::Path, args: &[String]) -> Result<(), String>Ok(())}+#[cfg(target_os = "macos")]+pub(crate) fn retire_foreground_parent_for_handoff(app: &AppHandle) {+ if app+ .webview_windows()+ .values()+ .any(|window| !window.is_fullscreen().is_ok_and(|fullscreen| !fullscreen))+ {+ warn!(+ "Keeping the handoff parent's activation policy because fullscreen state is active or unavailable"+ );+ return;+ }++ // A foreground parent exiting with a surviving child leaves a macOS background Dock tile.+ match app.set_activation_policy(tauri::ActivationPolicy::Accessory) {+ Ok(()) => info!("Requested retirement of Tauri's Dock presence for the GPUI handoff"),+ Err(error) => warn!(%error, "Could not retire Tauri's Dock presence for the GPUI handoff"),+ }+}+#[tauri::command]#[specta::specta]pub async fn gpui_app_available(app: AppHandle) -> bool {@@ -919,6 +939,27 @@ pub async fn switch_to_gpui_app(app: AppHandle) -> Result<(), String> {}Ok(())})?;+ #[cfg(target_os = "macos")]+ {+ let handle = app.clone();+ let (sender, receiver) = tokio::sync::oneshot::channel();+ match app.run_on_main_thread(move || {+ retire_foreground_parent_for_handoff(&handle);+ let _ = sender.send(());+ }) {+ Ok(()) => {+ if !matches!(+ tokio::time::timeout(std::time::Duration::from_secs(2), receiver).await,+ Ok(Ok(()))+ ) {+ warn!(+ "The GPUI handoff's Dock transition was not acknowledged before shutdown"+ );+ }+ }+ Err(error) => warn!(%error, "Could not schedule the GPUI handoff's Dock transition"),+ }+ }crate::complete_admitted_app_exit(app).await;Ok(())}diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex dc847504c..2db5ee967 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -6075,6 +6075,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {if app.try_state::<gpui_app::StartupRedirectState>().is_none() {app.manage(gpui_app::StartupRedirectState::default());}+ gpui_app::retire_foreground_parent_for_handoff(&app);let app = app.clone();tokio::spawn(async move {tokio::time::sleep(Duration::from_millis(750)).await;diff --git a/apps/desktop/src-tauri/src/permissions.rs b/apps/desktop/src-tauri/src/permissions.rsindex 8f66b9b99..4acd9cf9f 100644--- a/apps/desktop/src-tauri/src/permissions.rs+++ b/apps/desktop/src-tauri/src/permissions.rs@@ -149,6 +149,10 @@ fn macos_focus_permission_window(app: &tauri::AppHandle) {#[cfg(target_os = "macos")]fn macos_activate_permission_request(app: &tauri::AppHandle) {+ if crate::app_is_exiting(app) {+ return;+ }+if let Err(err) = app.set_dock_visibility(true) {tracing::warn!("Failed to show dock icon for permission request: {err}");}@@ -210,7 +214,7 @@ pub(crate) fn prepare_macos_panel_window(#[cfg(target_os = "macos")]pub(crate) fn sync_macos_dock_visibility(app: &tauri::AppHandle) {- if MACOS_PENDING_PANEL_WINDOWS.load(Ordering::Acquire) > 0 {+ if crate::app_is_exiting(app) || MACOS_PENDING_PANEL_WINDOWS.load(Ordering::Acquire) > 0 {return;}