Skip to content

feat: add preview unusernotifcations backend#280

Merged
hoodie merged 13 commits into
mainfrom
feature/4-18
Jun 14, 2026
Merged

feat: add preview unusernotifcations backend#280
hoodie merged 13 commits into
mainfrom
feature/4-18

Conversation

@hoodie

@hoodie hoodie commented May 31, 2026

Copy link
Copy Markdown
Owner

No description provided.

@hoodie hoodie force-pushed the feature/4-18 branch 5 times, most recently from 6f38161 to 1eca658 Compare May 31, 2026 23:55
@hoodie hoodie changed the title chore: tidy up dependencies feat: add preview unusernotifcations backend May 31, 2026
@hoodie hoodie force-pushed the feature/4-18 branch 3 times, most recently from 0fb4c3d to 46de6e7 Compare June 1, 2026 00:05
@hoodie hoodie marked this pull request as ready for review June 1, 2026 00:06
@hoodie hoodie requested a review from Copilot June 1, 2026 00:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an opt-in macOS notification backend based on UNUserNotificationCenter (preview-macos-un) and adds shared, cross-platform response types so consumers can handle notification outcomes without backend-specific cfg branching.

Changes:

  • Added preview-macos-un backend for macOS (async + blocking send, typed responses incl. inline reply support).
  • Introduced cross-platform response/close types (NotificationResponse, CloseReason, etc.) and adapted XDG backends to emit them.
  • Updated docs, examples, CI (macOS matrix), and added a helper script for running bundled macOS examples.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
src/xdg/zbus_rs.rs Switches zbus XDG backend from legacy action responses to NotificationResponse.
src/xdg/mod.rs Adapts XDG handle APIs to new response types and adds wait_for_response.
src/xdg/dbus_rs.rs Switches dbus XDG backend from legacy action responses to NotificationResponse.
src/response.rs Adds shared response/close types and callback traits.
src/notification.rs Adds macOS preview fields/APIs (InterruptionLevel, new id type, show_async).
src/notification_id.rs Adds cross-platform NotificationId abstraction.
src/macos/usernotifications.rs New UNUserNotificationCenter preview backend implementation + response handling.
src/macos/nsusernotification.rs Moves legacy NSUserNotificationCenter implementation into dedicated module.
src/macos/mod.rs Selects legacy vs preview macOS backend based on preview-macos-un feature.
src/macos.rs Removes old single-file macOS backend (replaced by src/macos/ module).
src/lib.rs Documents preview backend, exports new types/APIs, adjusts macOS exports by feature.
src/interruption_level.rs Adds (currently unused) InterruptionLevel type wrapper/placeholder.
src/error.rs Adds macOS preview error integration and conditional macOS error exports.
run_bundled_example.sh Adds helper script to bundle/sign/run macOS examples and stream logs.
examples/on_close.rs Updates example gating and uses shared CloseReason type.
examples/mac.rs Updates macOS example setup for preview backend vs legacy path.
examples/mac_usernotifications.rs New preview-backend example demonstrating typed responses.
examples/mac_usernotifications_async.rs New async preview-backend example using block_on_main.
examples/mac_app_id.rs Gates legacy macOS app-id example; adds preview-backend message.
examples/interruption_level.rs New example demonstrating interruption level usage.
examples/image_path.rs Updates macOS setup for preview backend vs legacy path.
examples/common/mod.rs Adds shared example setup utilities (logging/auth/key-wait).
examples/at_bus.rs Makes env_logger init non-fatal (try_init).
examples/actions.rs Updates action example to work on XDG + macOS preview backend.
Cargo.toml Adds preview-macos-un feature + deps, new example metadata, bundle metadata.
.github/workflows/build-platforms.yml Expands macOS CI to run with and without preview-macos-un.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/common/mod.rs
Comment thread src/xdg/mod.rs
Comment thread src/xdg/zbus_rs.rs
Comment thread src/response.rs Outdated
Comment thread src/response.rs
Comment thread src/xdg/mod.rs
Comment thread src/xdg/zbus_rs.rs
Comment thread src/response.rs Outdated
Comment thread src/response.rs
Comment thread examples/mac_usernotifications.rs Outdated
@hoodie hoodie force-pushed the feature/4-18 branch 10 times, most recently from fcbb0d8 to fecb847 Compare June 14, 2026 10:33
@hoodie hoodie force-pushed the feature/4-18 branch 2 times, most recently from 41f3ece to e4516ea Compare June 14, 2026 22:19
hoodie added 2 commits June 15, 2026 00:34
This finally enables features provided by UNUserNotificationCenter,
such as interruption levels (Active, Passive, TimeSensitive, Critical),
async/await support, and proper permission handling via
`request_auth_blocking`.

The new backend is gated behind the `preview-macos-un` feature flag
and wraps the `mac-usernotifications` crate. The existing
`NSUserNotification` path is preserved as the default.

Also adds:
- `InterruptionLevel` type and `.urgency()` builder method
- `NotificationId` type for cross-platform handle unification
- `examples/common/mod.rs` for shared bundle/auth setup
- New examples: `mac_usernotifications`, `mac_usernotifications_async`,
  `interruption_level`
- CI matrix extended to test with and without `preview-macos-un`
@hoodie hoodie merged commit 537094d into main Jun 14, 2026
27 checks passed
@hoodie hoodie deleted the feature/4-18 branch June 14, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants