From 46381516b7bd7b6915ded698d93e92760b4221d7 Mon Sep 17 00:00:00 2001 From: haexmas <154434630+haexmas@users.noreply.github.com> Date: Thu, 8 Oct 2026 19:14:19 +0200 Subject: [PATCH] feat(notification): report actions on desktop (#3671) * feat(notification): report actions on desktop A click on a notification (tap) or on one of the actions of its action type now reaches the JavaScript onAction listeners on desktop, and the new Rust Notification::on_action on every platform. On Linux and the BSDs the click comes from the notification server's ActionInvoked signal; on Windows and macOS from notify-rust's wait_for_response, which needs notify-rust 4.18. register_action_types, remove_active (Linux and the BSDs) and the listener commands are implemented for desktop, so they no longer fail with "command not found". The api example sends a notification with two actions and shows the action it hears. Closes #2150, closes #1903. * fix(notification): complete desktop action API * cleanup --------- Co-authored-by: Haex Co-authored-by: Lucas Nogueira --- .changes/notification-desktop-actions.md | 8 + Cargo.lock | 69 +-- examples/api/src/views/Notifications.svelte | 40 +- plugins/notification/Cargo.toml | 5 +- plugins/notification/guest-js/index.ts | 50 +- plugins/notification/src/commands.rs | 56 ++ plugins/notification/src/desktop.rs | 591 +++++++++++++++++++- plugins/notification/src/lib.rs | 37 +- plugins/notification/src/mobile.rs | 35 ++ plugins/notification/src/models.rs | 85 ++- 10 files changed, 868 insertions(+), 108 deletions(-) create mode 100644 .changes/notification-desktop-actions.md diff --git a/.changes/notification-desktop-actions.md b/.changes/notification-desktop-actions.md new file mode 100644 index 000000000..fe3be17b0 --- /dev/null +++ b/.changes/notification-desktop-actions.md @@ -0,0 +1,8 @@ +--- +"notification": minor:feat +"notification-js": minor:feat +--- + +Report actions on desktop: a click on a notification (`tap`) or on one of the actions of its action type reaches `onAction` and the new Rust `Notification::on_action`, which also works on mobile. `registerActionTypes`, `removeActive` (Linux and the BSDs) and the listener commands no longer fail with "command not found" on desktop. + +The `onAction` callback is now typed with the new `ActionPerformed` interface, which is what every platform sends, instead of `Options`. Callbacks annotated with `Options` must be updated. diff --git a/Cargo.lock b/Cargo.lock index ba6f4c343..71f986eee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2137,9 +2137,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" dependencies = [ "fastrand", "futures-core", @@ -3561,14 +3561,16 @@ checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" [[package]] name = "mac-notification-sys" -version = "0.6.4" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b95dfb34071d1592b45622bf93e315e3a72d414b6782aca9a015c12bec367ef" +checksum = "fd604973958ddcc11b561193c0fb96ba146506ef2f231ef2e7c35fd2cbc9beca" dependencies = [ "cc", + "log", "objc2 0.6.4", "objc2-foundation 0.3.2", "time", + "uuid", ] [[package]] @@ -3832,9 +3834,9 @@ dependencies = [ [[package]] name = "notify-rust" -version = "4.11.7" +version = "4.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6442248665a5aa2514e794af3b39661a8e73033b1cc5e59899e1276117ee4400" +checksum = "fe430c879247371c47fdedd328ad4e301e6b30b533c5fd5db1c06d75253d0e46" dependencies = [ "futures-lite", "log", @@ -6821,6 +6823,7 @@ dependencies = [ "thiserror 2.0.12", "time", "url", + "zbus", ] [[package]] @@ -7168,12 +7171,12 @@ dependencies = [ [[package]] name = "tauri-winrt-notification" -version = "0.7.3" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed071c670382e85fc2f48ae706492d8c338f4f89bf72520d32f8abfe880aade" +checksum = "f37a6c354fd28fc9e322ed9bd47e3959576dad28c9d58ea1cf888cce1c7ccb36" dependencies = [ "thiserror 2.0.12", - "windows 0.61.1", + "windows 0.62.2", "windows-version", ] @@ -8318,38 +8321,16 @@ dependencies = [ "windows_x86_64_msvc 0.36.1", ] -[[package]] -name = "windows" -version = "0.61.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5ee8f3d025738cb02bad7868bbb5f8a6327501e870bf51f1b455b0a2454a419" -dependencies = [ - "windows-collections 0.2.0", - "windows-core 0.61.0", - "windows-future 0.2.0", - "windows-link 0.1.1", - "windows-numerics 0.2.0", -] - [[package]] name = "windows" version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" dependencies = [ - "windows-collections 0.3.2", + "windows-collections", "windows-core 0.62.2", - "windows-future 0.3.2", - "windows-numerics 0.3.1", -] - -[[package]] -name = "windows-collections" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" -dependencies = [ - "windows-core 0.61.0", + "windows-future", + "windows-numerics", ] [[package]] @@ -8387,16 +8368,6 @@ dependencies = [ "windows-strings 0.5.1", ] -[[package]] -name = "windows-future" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a1d6bbefcb7b60acd19828e1bc965da6fcf18a7e39490c5f8be71e54a19ba32" -dependencies = [ - "windows-core 0.61.0", - "windows-link 0.1.1", -] - [[package]] name = "windows-future" version = "0.3.2" @@ -8442,16 +8413,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-numerics" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" -dependencies = [ - "windows-core 0.61.0", - "windows-link 0.1.1", -] - [[package]] name = "windows-numerics" version = "0.3.1" diff --git a/examples/api/src/views/Notifications.svelte b/examples/api/src/views/Notifications.svelte index 11273fdc3..1c14259c4 100644 --- a/examples/api/src/views/Notifications.svelte +++ b/examples/api/src/views/Notifications.svelte @@ -1,8 +1,43 @@