Skip to content

Fix macOS "Where is use_default?" dialog on first desktop notification#20

Merged
dcrjodle merged 1 commit into
Ivy-Interactive:developmentfrom
dcrjodle:fix/macos-notification-use-default-dialog
Jul 14, 2026
Merged

Fix macOS "Where is use_default?" dialog on first desktop notification#20
dcrjodle merged 1 commit into
Ivy-Interactive:developmentfrom
dcrjodle:fix/macos-notification-use-default-dialog

Conversation

@dcrjodle

@dcrjodle dcrjodle commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1682 the bug reported in Ivy-Interactive/Ivy-Tendril#1682: on macOS, the first desktop notification sent by a Rustino app pops the OS "Where is use_default?" application-picker dialog.

Root cause: rustino_show_notification never called notify_rust::set_application on macOS, so mac-notification-sys's ensure_application_set() fell back to resolving the literal app name "use_default" via AppleScript (get id of application "use_default" through NSAppleScript) — macOS resolves an unknown app name by showing the "Where is…?" picker.

Fix: on macOS, before the first notification is shown, call notify_rust::set_application exactly once with a pre-validated bundle id. Candidates in order: the app_id FFI param → NSBundle.mainBundle.bundleIdentifiercom.apple.Terminalcom.apple.Finder (upstream's own default). Candidates are validated via NSWorkspace.URLForApplicationWithBundleIdentifier (LaunchServices) before the call, because mac_notification_sys::set_application latches its internal Once even on failure, so it must be called only once and with an id that will be accepted.

app_id was previously ignored on macOS; callers can now pass a real bundle identifier to control which app the notification is attributed to. Display-name values (e.g. "Ivy Tendril") fail LaunchServices validation and safely fall through to the next candidate. Windows (AUMID) and Linux paths are unchanged.

Verified: cargo build, cargo build --release (the command CI runs), cargo clippy --all-targets (no new warnings), cargo test (23 passed) on macOS. The dialog itself can't be reproduced headlessly; the fix rests on the verified call-order in notify-rust 4.14.0 / mac-notification-sys 0.6.12 sources.

🤖 Generated with Claude Code

Ivy-Tendril#1682: the first desktop notification on macOS popped an OS
"Where is use_default?" app-picker dialog. rustino_show_notification
ignored app_id on macOS and called notify_rust::Notification::show()
without ever calling set_application. notify-rust's macOS backend then
lazily resolved the bundle id for the literal string "use_default" via
AppleScript, and macOS showed a picker dialog for the unrecognized app
name.

Fix: before the first notification, call notify_rust::set_application
exactly once (guarded by a std::sync::Once, since mac-notification-sys
latches its own Once even on failure). Try, in order: the app_id FFI
param, the running app's own bundle id (NSBundle mainBundle), then
"com.apple.Terminal", each pre-validated against LaunchServices via
NSWorkspace::URLForApplicationWithBundleIdentifier so we never call
set_application with an id it would reject; fall back to
"com.apple.Finder" (always installed) if nothing validates.

Windows/Linux notification behavior is unchanged.
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