From 14cef738f7e88645ce63ab0d738998f46d4c18e3 Mon Sep 17 00:00:00 2001 From: unsecretised Date: Thu, 4 Jun 2026 21:52:13 +0800 Subject: [PATCH 1/2] fix: hotkey stops working when mac sleeps used AI to find and implement this fix --- src/app.rs | 1 + src/app/tile.rs | 10 ++++++++++ src/app/tile/update.rs | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/app.rs b/src/app.rs index 69220a5..99c740d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -118,6 +118,7 @@ pub enum Message { FileSearchClear, SetFileSearchSender(tokio::sync::watch::Sender<(String, Vec)>), DebouncedSearch(Id), + CheckEventTap, } #[derive(Debug, Clone)] diff --git a/src/app/tile.rs b/src/app/tile.rs index 3b442d4..5214b6e 100644 --- a/src/app/tile.rs +++ b/src/app/tile.rs @@ -266,6 +266,7 @@ impl Tile { Subscription::run(handle_recipient), Subscription::run(reload_events), Subscription::run(handle_version_and_rankings), + Subscription::run(check_event_tap), Subscription::run(handle_clipboard_history), Subscription::run(handle_file_search), window::close_events().map(Message::HideWindow), @@ -794,6 +795,15 @@ fn reload_events() -> impl futures::Stream { }) } +fn check_event_tap() -> impl futures::Stream { + stream::channel(100, async |mut output| { + loop { + tokio::time::sleep(Duration::from_secs(5)).await; + output.send(Message::CheckEventTap).await.ok(); + } + }) +} + fn handle_version_and_rankings() -> impl futures::Stream { stream::channel(100, async |mut output| { loop { diff --git a/src/app/tile/update.rs b/src/app/tile/update.rs index 35f19f0..4b7fe83 100644 --- a/src/app/tile/update.rs +++ b/src/app/tile/update.rs @@ -948,6 +948,18 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task { Task::none() } + Message::CheckEventTap => { + info!("Re-creating global event tap"); + if let Some(ref sender) = tile.sender { + tile.hotkeys.handle = None; + match global_handler(sender.clone(), tile.hotkeys.all_hotkeys()) { + Ok(handle) => tile.hotkeys.handle = Some(handle), + Err(e) => log::error!("Failed to re-create event tap: {e}"), + } + } + Task::none() + } + Message::DebouncedSearch(id) => { // Only execute if this is still the most recent debounce timer if !tile.debouncer.is_ready() { From a158c4e9afce4e9c0a433907c9555e404b9597fa Mon Sep 17 00:00:00 2001 From: unsecretised Date: Thu, 4 Jun 2026 21:58:44 +0800 Subject: [PATCH 2/2] fix quitting on autoupdate --- src/app/tile/update.rs | 2 -- src/autoupdate.rs | 21 --------------------- 2 files changed, 23 deletions(-) diff --git a/src/app/tile/update.rs b/src/app/tile/update.rs index 4b7fe83..384531d 100644 --- a/src/app/tile/update.rs +++ b/src/app/tile/update.rs @@ -32,7 +32,6 @@ use crate::app::menubar::menu_icon; use crate::app::tile::AppIndex; use crate::app::{Message, Page, tile::Tile}; use crate::autoupdate::download_latest_app; -use crate::autoupdate::relaunch_app; use crate::calculator::Expr; use crate::commands::Function; use crate::config::Config; @@ -154,7 +153,6 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task { if tile.config.auto_update { thread::spawn(|| { download_latest_app().ok(); - relaunch_app(); }); } Task::done(Message::ReloadConfig) diff --git a/src/autoupdate.rs b/src/autoupdate.rs index de34d7b..3a4cf10 100644 --- a/src/autoupdate.rs +++ b/src/autoupdate.rs @@ -188,27 +188,6 @@ fn copy_dir_recursive(src: &std::path::Path, dst: &std::path::Path) -> std::io:: Ok(()) } -pub fn relaunch_app() { - let app_path = match get_app_path() { - Some(p) => p, - None => { - error!("Could not determine current app path for relaunch"); - return; - } - }; - - match std::process::Command::new("open").arg(&app_path).spawn() { - Ok(_) => { - info!("Relaunching app at {:?}", app_path); - std::thread::sleep(std::time::Duration::from_millis(500)); - std::process::exit(0); - } - Err(e) => { - error!("Could not relaunch app: {e}"); - } - } -} - pub fn get_app_path() -> Option { let exe = std::env::current_exe().ok()?;