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.
28 lines
810 B
Swift
28 lines
810 B
Swift
import Foundation
|
|
|
|
/// Holds what the menu shows. Kept free of UI types so the badge and mute rules can be tested.
|
|
public final class NotificationCenterModel {
|
|
public private(set) var history: [NotifyEvent] = []
|
|
public private(set) var unseenCount = 0
|
|
public var isMuted = false
|
|
public var maxHistory = 50
|
|
|
|
public init() {}
|
|
|
|
/// Returns true when a banner should be shown for this event.
|
|
@discardableResult
|
|
public func receive(_ event: NotifyEvent) -> Bool {
|
|
history.insert(event, at: 0)
|
|
if history.count > maxHistory { history.removeLast(history.count - maxHistory) }
|
|
unseenCount += 1
|
|
return !isMuted
|
|
}
|
|
|
|
public func markAllSeen() { unseenCount = 0 }
|
|
|
|
public func clear() {
|
|
history.removeAll()
|
|
unseenCount = 0
|
|
}
|
|
}
|