Skip to content

Pending-request notifications on macOS: Notification Center removal and click opens the request #1711

Backlog

Description

@smart-ssh-planner

Goal

On macOS, a pending-request notification disappears from Notification Center once its request is answered or the user returns to the app. Clicking it brings the app to the front and opens the tab of the request.

Context

  • Pending requests: native notification and Dock/taskbar attention while the app is in the background #1709 added:
    • the PendingRequestNotifier trait;
    • the desktop implementation and the OS notification backend boundary in crates/app-shell (show by id, remove by id, remove all);
    • activate_pending_request(id).
  • It also added Dock bouncing (request_user_attention(Critical)).
  • tauri-plugin-notification uses the deprecated NSUserNotification API on macOS (via mac-notification-sys). It can neither remove delivered notifications nor report clicks.

Requirements

  • macOS backend on UNUserNotificationCenter (e.g. objc2-user-notifications):
    • Request authorization on the first pending request. Denied authorization is logged once.
    • The notification identifier is derived from the request id.
    • Remove uses removeDeliveredNotificationsWithIdentifiers: (and pending ones).
    • Remove all removes every pending-request identifier.
  • Delegate:
    • didReceiveNotificationResponse calls activate_pending_request(id).
    • willPresentNotification shows nothing while the app is in the foreground, which matches the "background only" rule.
  • Plugs into the boundary from Pending requests: native notification and Dock/taskbar attention while the app is in the background #1709, with no change to the trait or callers.
  • Removes a request's notification when it ends, and all pending-request notifications when the main window gets focus.
  • Unbundled builds (cargo run/dev without a bundle identifier) cannot use UNUserNotificationCenter. They fall back to the plugin backend and log once.
  • No approve/deny actions in the notification.

Acceptance Criteria

  • On a bundled macOS build, a pending-request notification is removed from Notification Center when its request ends (approved, denied, timeout, tab closed) and when the main window gets focus.
  • Clicking the notification activates the app and switches to the tab of the request.
  • The Dock icon bounces until the app is activated (behaviour from Pending requests: native notification and Dock/taskbar attention while the app is in the background #1709 still works with the new backend).
  • With notification authorization denied, the app logs once without content, keeps bouncing the Dock icon (if that setting is on), and the request flow is unchanged.
  • An unbundled build falls back to the plugin backend without crashing.
  • Unit tests for the identifier mapping and the remove logic with a fake backend. The macOS module compiles in the macOS CI job.
  • Relevant automated tests pass.

Technical Notes

  • Real Notification Center behaviour needs a bundled, signed app on a real Mac. The reviewer lists manual test steps.
  • Delegate callbacks arrive on the main thread. Hand the id to the async runtime and do not block.
  • No content in logs (Spec 0094).

Files: crates/app-shell/src/ (pending_request_notifications backend module for macos), crates/app-shell/Cargo.toml, Cargo.lock, docs/specs/ (pending-request notification spec)

Spec impact: update the pending-request notification spec created by #1709 (macOS behaviour)

Open questions

  • Binding crate: objc2-user-notifications (recommended, matches the objc2 stack Tauri already uses) or hand-written objc2 messages.

Related Work

Metadata

Metadata

Assignees

No one assigned

    Labels

    app-shellenhancement

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions