A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Merge main into linux/open-terminal
Claude52f2d37a9ca3
diff --cc windows/README.mdindex dcb73724,b3a84723..8a3252e7--- a/windows/README.md+++ b/windows/README.md@@@ -397,10 -403,12 +403,13 @@@ own windowprocess to the terminal or editor that runs it. A session in a classicconsole window (`cmd.exe` or PowerShell without Windows Terminal) has no suchancestor — conhost owns that window — so its folder opens in VS Code instead,- as it does when `code` is on your `PATH` and nothing was found.+ as it does when `code` is on your `PATH` and nothing was found. Linux walks+ the same tree; what it can bring forward depends on the desktop (see Linux).- - No global keyboard shortcuts yet: a waiting card is folded with its **⌃** or- `Esc` in the island, and reopened by clicking the island or Open in the tray.+ - Global keyboard shortcuts are hot keys on Windows, key grabs on Linux under+ X11, and go through the desktop's GlobalShortcuts portal under Wayland (see+ [Linux](#linux)). A waiting card is also folded with its **⌃** or `Esc` in+ the island, and reopened by clicking the island, Open in the tray or **Go to+ alert**.- Apple Music, the one pill from the Mac catalog with nothing behind it here,is left out.- Not in this version: sending a dropped file by email and dragging Mochi ontodiff --cc windows/src-tauri/Cargo.tomlindex ba601355,b7dee25a..04af099f--- a/windows/src-tauri/Cargo.toml+++ b/windows/src-tauri/Cargo.toml@@@ -50,8 -50,6 +50,9 @@@ libc = "0.2# The GTK that Tauri already runs on, to reach its window for layer-shell and# the input region. libgtk-layer-shell itself is called directly (platform/linux.rs).gtk = "0.18"- # "Open terminal" (platform/linux_focus.rs): KWin's scripting over D-Bus, and- # EWMH on X11. Both already in the tree (keyring, global-hotkey): nothing new- # to download or build.-# Global shortcuts on Wayland through the XDG GlobalShortcuts portal-# (portal.rs). The libdbus binding keyring's Secret Service already links.-dbus = "0.9"++# libdbus, which keyring's Secret Service already links: Wayland global++# shortcuts through the XDG GlobalShortcuts portal (portal.rs), and "Open++# terminal" through KWin's scripting (platform/linux_focus.rs).+dbus = "0.9.12"++# EWMH on X11 for "Open terminal", already in the tree (global-hotkey).+x11rb = { version = "0.13", default-features = false }diff --cc windows/src-tauri/src/shortcuts.rsindex a47c7c4e,cc87e12e..eb7d9196--- a/windows/src-tauri/src/shortcuts.rs+++ b/windows/src-tauri/src/shortcuts.rs@@@ -375,6 -438,251 +438,252 @@@ fn typed_character(shortcut: &Shortcutcrate::platform::ctrl_alt_types(vk, shortcut.mods.contains(Modifiers::SHIFT))}+ // ── Wayland: the GlobalShortcuts portal ───────────────────────────────────────++ /// Glue between `apply` and the portal thread (portal.rs). Each `bind` gets a+ /// new generation; an answer to an older one is dropped, so a slow desktop+ /// dialog can't overwrite what the latest settings asked for.+ #[cfg(target_os = "linux")]+ mod wayland {+ use super::*;+ use crate::portal::{self, Bound, Event, Wanted};++ /// The portal thread, once started.+ #[derive(Default)]+ pub enum Link {+ #[default]+ NotStarted,+ Running { handle: portal::Handle, gen: u64 },+ /// No portal (or no session bus): today's commands instead, for the+ /// rest of the run.+ Gone,+ }++ /// Hands the planned shortcuts to the desktop. False when there is no+ /// portal to hand them to; `apply` then carries on as before.+ pub fn bind<R: Runtime>(+ app: &AppHandle<R>,+ stored: &Bindings,+ plan: &[(&'static ActionDef, Result<Shortcut, ActionStatus>)],+ ) -> bool {+ let Some(registry) = app.try_state::<Registry>() else { return false };+ // Held until the request is sent, so the thread's answer (on_event+ // takes this lock too) always lands after the Pending report below.+ let mut link = registry.wayland.lock().unwrap();+ if matches!(*link, Link::Gone) {+ return false;+ }+ let wanted: Vec<Wanted> = plan+ .iter()+ .filter(|(_, outcome)| outcome.is_ok())+ .map(|(def, _)| Wanted {+ id: def.id.to_string(),+ description: crate::i18n::t(description(def.id)),+ trigger: portal::xdg_trigger(&effective(def, stored).keys),+ })+ .collect();+ *registry.report.lock().unwrap() = plan+ .iter()+ .map(|(def, outcome)| match outcome {+ Err(status) => status.clone(),+ Ok(_) => ActionStatus { id: def.id, status: Status::Pending, typed: None, trigger: None },+ })+ .collect();+ *registry.portal.lock().unwrap() = Some(PortalState::Pending);++ if matches!(*link, Link::NotStarted) {+ let events = app.clone();+ *link = match portal::start(move |event| on_event(&events, event)) {+ Some(handle) => Link::Running { handle, gen: 0 },+ None => Link::Gone,+ };+ }+ let Link::Running { handle, gen } = &mut *link else { return false };+ *gen += 1;+ if !handle.bind(*gen, wanted) {+ *link = Link::Gone;+ return false;+ }+ drop(link);+ let _ = app.emit("shortcuts-status", status(app));+ true+ }++ /// Gives the shortcuts back to the desktop while Settings records a new+ /// one; the next `apply` binds them again.+ pub fn release<R: Runtime>(app: &AppHandle<R>) {+ let Some(registry) = app.try_state::<Registry>() else { return };+ let mut link = registry.wayland.lock().unwrap();+ if let Link::Running { handle, gen } = &mut *link {+ *gen += 1;+ handle.release();+ }+ }++ /// What the portal thread says. Runs on that thread.+ fn on_event<R: Runtime>(app: &AppHandle<R>, event: Event) {+ let Some(registry) = app.try_state::<Registry>() else { return };+ if let Event::Activated(id) = &event {+ if let Some(def) = find(id).filter(|d| d.ported) {+ dispatch(app, def.id);+ }+ return;+ }+ let mut link = registry.wayland.lock().unwrap();+ let current = match &*link {+ Link::Running { gen, .. } => *gen,+ _ => 0,+ };+ {+ let mut report = registry.report.lock().unwrap();+ let mut portal = registry.portal.lock().unwrap();+ match event {+ Event::Bound { gen, shortcuts } if gen == current => {+ crate::log::line("shortcuts: registered with the desktop portal");+ mark_bound(&mut report, shortcuts.as_deref());+ *portal = Some(PortalState::Active);+ }+ Event::Changed { gen, shortcuts } if gen == current => mark_changed(&mut report, &shortcuts),+ Event::Failed { gen, reason } if gen == current => {+ crate::log::line(format!("shortcuts: the desktop portal didn't take them: {reason}"));+ mark_failed(&mut report);+ *portal = None;+ }+ Event::Unavailable(reason) => {+ crate::log::line(format!("shortcuts: no portal, commands instead ({reason})"));+ *link = Link::Gone;+ mark_failed(&mut report);+ *portal = None;+ }+ _ => return,+ }+ }+ drop(link);+ let _ = app.emit("shortcuts-status", status(app));+ }++ fn handed_over(status: Status) -> bool {+ matches!(status, Status::Pending | Status::Active | Status::Refused)+ }++ /// The desktop answered: each shortcut it lists is active, with its keys;+ /// one it left out is refused. `None`: it didn't list them, so all are.+ pub fn mark_bound(report: &mut [ActionStatus], shortcuts: Option<&[Bound]>) {+ for st in report.iter_mut().filter(|st| handed_over(st.status)) {+ let bound = match shortcuts {+ None => Some(None),+ Some(list) => list.iter().find(|b| b.id == st.id).map(|b| b.trigger.clone()),+ };+ match bound {+ Some(trigger) => {+ st.status = Status::Active;+ st.trigger = trigger;+ }+ None => {+ st.status = Status::Refused;+ st.trigger = None;+ }+ }+ }+ }++ /// The user gave some shortcuts other keys in the desktop's settings.+ pub fn mark_changed(report: &mut [ActionStatus], shortcuts: &[Bound]) {+ for st in report.iter_mut().filter(|st| handed_over(st.status)) {+ if let Some(b) = shortcuts.iter().find(|b| b.id == st.id) {+ st.status = Status::Active;+ st.trigger = b.trigger.clone();+ }+ }+ }++ /// No portal after all: what a Wayland session showed before it.+ pub fn mark_failed(report: &mut [ActionStatus]) {+ for st in report.iter_mut().filter(|st| handed_over(st.status)) {+ st.status = Status::Unsupported;+ st.trigger = None;+ }+ }++ #[cfg(test)]+ mod tests {+ use super::*;++ fn report() -> Vec<ActionStatus> {+ plan(&Bindings::new(), |_| None)+ .into_iter()+ .map(|(def, outcome)| match outcome {+ Err(status) => status,+ Ok(_) => ActionStatus { id: def.id, status: Status::Pending, typed: None, trigger: None },+ })+ .collect()+ }++ fn of<'a>(report: &'a [ActionStatus], id: &str) -> &'a ActionStatus {+ report.iter().find(|s| s.id == id).unwrap()+ }++ fn bound(id: &str, trigger: Option<&str>) -> Bound {+ Bound { id: id.into(), trigger: trigger.map(str::to_string) }+ }++ #[test]+ fn the_desktop_answer_marks_each_shortcut() {+ let mut r = report();+ let answer = [bound("openChat", Some("Ctrl+Alt+Space")), bound("goToAlert", None)];+ mark_bound(&mut r, Some(&answer));+ assert_eq!(of(&r, "openChat").status, Status::Active);+ assert_eq!(of(&r, "openChat").trigger.as_deref(), Some("Ctrl+Alt+Space"));+ assert_eq!(of(&r, "goToAlert").status, Status::Active);+ assert_eq!(of(&r, "goToAlert").trigger, None);+ // Left out of the answer.+ assert_eq!(of(&r, "muteToggle").status, Status::Refused);++ assert_eq!(of(&r, "desktopToggle").status, Status::Refused);+ // Never handed over: untouched.+ assert_eq!(of(&r, "toggleIsland").status, Status::Off);- assert_eq!(of(&r, "desktopToggle").status, Status::NotPorted);++ assert_eq!(of(&r, "attachFrontWindow").status, Status::NotPorted);+ }++ #[test]+ fn an_answer_without_a_list_takes_them_all() {+ let mut r = report();+ mark_bound(&mut r, None);+ assert!(r.iter().all(|s| matches!(s.status, Status::Active | Status::Off | Status::NotPorted)));+ assert_eq!(of(&r, "nextPill").status, Status::Active);+ }++ #[test]+ fn new_keys_from_the_desktop_replace_the_old_ones() {+ let mut r = report();+ mark_bound(&mut r, Some(&[bound("openChat", Some("Ctrl+Alt+Space"))]));+ mark_changed(&mut r, &[bound("openChat", Some("Meta+C")), bound("muteToggle", Some("Meta+M"))]);+ assert_eq!(of(&r, "openChat").trigger.as_deref(), Some("Meta+C"));+ assert_eq!(of(&r, "muteToggle").status, Status::Active);+ assert_eq!(of(&r, "muteToggle").trigger.as_deref(), Some("Meta+M"));+ assert_eq!(of(&r, "toggleIsland").status, Status::Off);+ }++ #[test]+ fn a_failure_goes_back_to_unsupported() {+ let mut r = report();+ mark_bound(&mut r, Some(&[bound("openChat", Some("Ctrl+Alt+Space"))]));+ mark_failed(&mut r);+ for s in &r {+ assert!(matches!(s.status, Status::Unsupported | Status::Off | Status::NotPorted), "{}", s.id);+ assert_eq!(s.trigger, None);+ }+ assert_eq!(of(&r, "openChat").status, Status::Unsupported);+ }++ #[test]+ fn every_action_has_a_description() {+ for def in ACTIONS {+ assert_ne!(description(def.id), "Coucou", "{}", def.id);+ }+ }+ }+ }+#[cfg(test)]mod tests {use super::*;