A luxe hook runs luxe-notify, which sends one JSON line over a Unix socket to a SwiftUI menu bar app. The app shows a banner, keeps a badge count and history, and brings the terminal forward when you click a banner. Notifies on approvals (PermissionRequested), question prompts (BeforeToolUse, matched to the question tool), errors, and turns that run at least --min-seconds (default 30, timed from BeforeAgentStart to AgentEnd). The menu warns when macOS has notifications blocked for the app. The app writes status.txt beside its socket for debugging. Known limits are in README.md and PLAN.md: a crowded menu bar can hide the icon, and the first test build after a change can fail with a TestingMacros error under Command Line Tools, which make test retries once.
30 lines
1.0 KiB
Swift
30 lines
1.0 KiB
Swift
import Foundation
|
|
|
|
/// What the menu should tell the user about banner delivery. Pure so it can be tested without
|
|
/// UserNotifications, which only exists inside an app bundle.
|
|
public enum BannerPermission: Equatable {
|
|
case unknown
|
|
case allowed
|
|
case denied
|
|
case notDetermined
|
|
|
|
/// `rawValue` is UNAuthorizationStatus: 0 notDetermined, 1 denied, 2 authorized, 3 provisional, 4 ephemeral.
|
|
public init(authorizationRawValue: Int) {
|
|
switch authorizationRawValue {
|
|
case 0: self = .notDetermined
|
|
case 1: self = .denied
|
|
case 2, 3, 4: self = .allowed
|
|
default: self = .unknown
|
|
}
|
|
}
|
|
|
|
/// Nil when nothing needs saying. Unknown stays quiet so the bare-binary dev path shows no warning.
|
|
public var warning: String? {
|
|
switch self {
|
|
case .denied: return "Banners are blocked. Allow luxe Notifier in System Settings > Notifications."
|
|
case .notDetermined: return "Waiting for notification permission."
|
|
case .allowed, .unknown: return nil
|
|
}
|
|
}
|
|
}
|