YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(tray): refresh tray icon after every activation policy reset
Louis Beaumont343eb77529d4
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex d630ebbdf..5231c3c37 100755--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -9007,7 +9007,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.0.260"+version = "2.0.261"dependencies = ["anyhow","async-stream",@@ -9089,7 +9089,7 @@ dependencies = [[[package]]name = "screenpipe-audio"-version = "0.3.54"+version = "0.3.55"dependencies = ["anyhow","bytemuck",@@ -9137,7 +9137,7 @@ dependencies = [[[package]]name = "screenpipe-core"-version = "0.3.54"+version = "0.3.55"dependencies = ["accessibility","accessibility-sys",@@ -9188,7 +9188,7 @@ dependencies = [[[package]]name = "screenpipe-db"-version = "0.3.54"+version = "0.3.55"dependencies = ["anyhow","chrono",@@ -9212,7 +9212,7 @@ dependencies = [[[package]]name = "screenpipe-events"-version = "0.3.54"+version = "0.3.55"dependencies = ["anyhow","chrono",@@ -9228,7 +9228,7 @@ dependencies = [[[package]]name = "screenpipe-integrations"-version = "0.3.54"+version = "0.3.55"dependencies = ["anyhow","image 0.25.9",@@ -9243,7 +9243,7 @@ dependencies = [[[package]]name = "screenpipe-server"-version = "0.3.54"+version = "0.3.55"dependencies = ["anyhow","async-trait",@@ -9307,7 +9307,7 @@ dependencies = [[[package]]name = "screenpipe-vision"-version = "0.3.54"+version = "0.3.55"dependencies = ["accessibility-sys","anyhow",diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rsindex eb1934739..b7297de58 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -265,9 +265,7 @@ pub async fn open_pipe_window(}#[cfg(target_os = "macos")]- if let Err(e) = app_handle.set_activation_policy(tauri::ActivationPolicy::Regular) {- error!("failed to set activation policy: {}", e);- }+ crate::window_api::reset_to_regular_and_refresh_tray(&app_handle);Ok(())}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 879769307..e3ad47a16 100755--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -893,9 +893,7 @@ async fn main() {let _ = window.set_always_on_top(false);let _ = window.set_visible_on_all_workspaces(false);#[cfg(target_os = "macos")]- let _ = window- .app_handle()- .set_activation_policy(tauri::ActivationPolicy::Regular);+ crate::window_api::reset_to_regular_and_refresh_tray(window.app_handle());let _ = window.hide();api.prevent_close();}@@ -1382,7 +1380,7 @@ async fn main() {});#[cfg(target_os = "macos")]- app.set_activation_policy(tauri::ActivationPolicy::Regular);+ crate::window_api::reset_to_regular_and_refresh_tray(&app_handle);// Initialize global shortcutslet app_handle_clone = app_handle.clone();diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs b/apps/screenpipe-app-tauri/src-tauri/src/window_api.rsindex 65a8e91ab..8b87ad95b 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs@@ -12,6 +12,27 @@ use tauri_nspanel::WebviewWindowExt;use crate::{store::OnboardingStore, ServerState};+/// Reset activation policy to Regular and refresh the tray icon.+/// On MacBook Pro models with a notch, toggling between Accessory and Regular+/// can cause macOS to re-layout status bar items, pushing the tray icon behind+/// the notch. Re-setting the icon forces macOS to re-render and reposition it.+#[cfg(target_os = "macos")]+pub fn reset_to_regular_and_refresh_tray(app: &AppHandle) {+ let _ = app.set_activation_policy(tauri::ActivationPolicy::Regular);++ if let Some(tray) = app.tray_by_id("screenpipe_main") {+ // Re-set the icon to force macOS to re-render the NSStatusItem+ // This works around a macOS bug where the tray icon disappears+ // or gets stuck behind the notch after activation policy changes+ if let Ok(icon) = tauri::image::Image::from_path("assets/screenpipe-logo-tray-white.png") {+ let _ = tray.set_visible(false);+ let _ = tray.set_visible(true);+ let _ = tray.set_icon(Some(icon));+ let _ = tray.set_icon_as_template(true);+ }+ }+}+#[derive(Deserialize, Debug)]pub struct OpenLocalPathPayload {path: String,@@ -89,7 +110,7 @@ pub async fn show_specific_window(match event {tauri::WindowEvent::Destroyed | tauri::WindowEvent::CloseRequested { .. } => {info!("Custom window closed, resetting activation policy");- let _ = app_clone.set_activation_policy(tauri::ActivationPolicy::Regular);+ reset_to_regular_and_refresh_tray(&app_clone);}_ => {}}@@ -658,7 +679,7 @@ impl ShowRewindWindow {// This restores the dock icon and tray menu which are hidden in Accessory mode#[cfg(target_os = "macos")]{- let _ = app_clone.set_activation_policy(tauri::ActivationPolicy::Regular);+ reset_to_regular_and_refresh_tray(&app_clone);}let _ = app_clone.emit("window-focused", false).ok();@@ -783,7 +804,7 @@ impl ShowRewindWindow {match event {tauri::WindowEvent::Destroyed | tauri::WindowEvent::CloseRequested { .. } => {info!("Chat window closed, resetting activation policy");- let _ = app_clone.set_activation_policy(tauri::ActivationPolicy::Regular);+ reset_to_regular_and_refresh_tray(&app_clone);}_ => {}}@@ -858,7 +879,7 @@ impl ShowRewindWindow {// Reset to Regular activation policy when hiding the panel// so other windows (like Settings) work normally- let _ = app.set_activation_policy(tauri::ActivationPolicy::Regular);+ reset_to_regular_and_refresh_tray(app);}#[cfg(not(target_os = "macos"))]