Repository navigation
desktop: Let a host hand its notifications to the app it embeds - #986
Merged
Merged
Conversation
An app that makes its own AppView instead of calling run_app had no notification delegate on macOS (no banners in front, lost presses) and no AppUserModelID or activator on Windows (nothing showed). macOS now installs the delegate when an AppView is made, keeping one the host set; Windows starts toasts for a top-level AppView unless the process has an id of its own. Agent: rust-maintainer
…-notifications # Conflicts: # crates/nsh-platform-windows/src/app.rs
An AppView a host makes used to take the process's notifications on its own: on Windows it set the process's AppUserModelID (and with it the taskbar grouping of the host's own windows), on macOS it took the notification center's delegate. The process is the host's, so that is now its choice: AppOptions::notifications hands them to the view's app, and run_app sets it. Without it the permission is unavailable, show resolves false and the badge stays the host's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
huacnlee
marked this pull request as ready for review
November 6, 2026 03:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Notifications only worked under
run_app. A host that builds its ownAppViewhad no way to let the app it embeds show notifications on macOS and Windows.The process belongs to the host, so handing its notifications over is now the host's explicit choice rather than something
AppView::newguesses (an earlier revision of this PR took them for every top-level view, which changed the host's own taskbar identity on Windows):AppOptions::notifications(macOS, Windows, Linux;falseby default,run_appsets it). When set, the view's app owns the process's notifications:UNUserNotificationCenterdelegate (a delegate the host already set stays), so banners show while the app is in front and presses reach it.run_appstill installs it before launching finishes, so a press that starts the app is not lost.app_idas its AppUserModelID, registers it withtitleandiconfor toasts and hears their presses. The first such view's app wins.Notifications.permission()/requestPermission()resolve"unavailable",show()resolvesfalseandsetBadgeleaves the host's badge alone. The JS API is unchanged.Public API
nsh_platform_macos::AppOptions::notifications: bool— the view's app owns the process's notifications.nsh_platform_windows::AppOptions::notifications: bool— same, on Windows.nsh_platform_linux::AppOptions::notifications: bool— same field for one shape on the desktops;run_appsets it.Behavior change (not API): on macOS and Windows, an
AppViewa host makes no longer has notifications unless it sets the field.Docs:
docs/dev/embedding.md, the macOS / Windows guides (en, zh-CN) and theNotificationsplatform table.Not covered
tests/compatcase: the field is embedder (Rust host) API, not something apps use.Verification
cargo clippyon the Linux crates, fmt.🤖 Noop (rust-maintainer) · AI agent acting for @huacnlee
🤖 Generated with Claude Code