rio icon indicating copy to clipboard operation
rio copied to clipboard

macOS: desktop notifications are delivered silently — they land in Notification Center but never show a banner

Open KennethLj opened this issue 3 months ago • 0 comments

Summary

On macOS, notifications triggered via OSC 9 / OSC 777 are delivered but never presented: no banner appears, and the notification is only discoverable by opening Notification Center.

The cause is that a terminal notification is, almost by definition, emitted by a program running inside the terminal — so Rio is the frontmost app at the moment the notification is posted. macOS does not present a notification posted by the foreground app unless that app opts in through a UNUserNotificationCenterDelegate, and Rio never installs one.

The net effect is that the feature added in #1470 works, but not for the case it was asked for: you only see the notification if you already went looking for it.

Environment

  • Rio 0.5.19 (Homebrew cask, com.raphaelamorim.rio)
  • macOS 26.6 (25G72), Apple Silicon

Steps to reproduce

With Rio focused — i.e. normal usage:

printf '\033]777;notify;Build;finished\a'
# or
printf '\033]9;build finished\a'

Expected: a banner appears. Actual: nothing appears. Opening Notification Center shows the notification, attributed to Rio.

Contrast — fire the same sequence while Rio is not frontmost:

(sleep 5; printf '\033]777;notify;Build;finished\a') &

…then click another app before it fires. The banner appears normally. That difference is the whole bug.

Cause

rio-notifier posts through UNUserNotificationCenter:

// rio-notifier/src/lib.rs
let center = UNUserNotificationCenter::currentNotificationCenter();
// ...
center.addNotificationRequest_withCompletionHandler(&request, None);

but nothing ever sets a delegate on that center — grep -rn 'UNUserNotificationCenterDelegate\|willPresent' across the workspace returns no hits (the setDelegate calls in rio-window are the unrelated NSWindow / NSApplication delegates).

Under the UserNotifications framework, a notification arriving while its own app is in the foreground is presented only if the center's delegate implements userNotificationCenter(_:willPresent:withCompletionHandler:) and calls the completion handler with presentation options. With no delegate, the system delivers the notification to Notification Center without presenting it — exactly the observed behaviour.

KennethLj avatar Aug 08 '26 08:08 KennethLj