Files
cottongin ced6a44ed0 Add luxe Notifier: macOS menu bar app that tells you when luxe needs you
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.
2026-10-24 22:41:42 -04:00

61 lines
2.1 KiB
Swift

import AppKit
import NotifierCore
import SwiftUI
struct MenuContent: View {
@ObservedObject var state: AppState
var body: some View {
VStack(alignment: .leading, spacing: 8) {
if let warning = state.permission.warning {
Label(warning, systemImage: "exclamationmark.triangle.fill")
.font(.caption)
.foregroundStyle(.orange)
}
if state.history.isEmpty {
Text("Nothing waiting on you").foregroundStyle(.secondary)
} else {
ForEach(Array(state.history.prefix(10).enumerated()), id: \.offset) { _, event in
Button { TerminalFocuser.focus(bundleID: event.terminalBundleID) } label: {
EventRow(event: event).frame(maxWidth: .infinity, alignment: .leading)
}
.buttonStyle(.plain)
.help(event.terminalBundleID == nil ? "No terminal recorded for this event" : "Bring the terminal forward")
}
}
Divider()
Toggle("Mute banners", isOn: $state.isMuted)
Toggle("Launch at login", isOn: $state.launchAtLogin)
.disabled(!LoginItem.isAvailable)
HStack {
Button("Clear") { state.clear() }.disabled(state.history.isEmpty)
Spacer()
Button("Quit") { NSApplication.shared.terminate(nil) }
}
}
.padding(12)
.frame(width: 320)
.onAppear {
state.markSeen()
state.refreshPermission()
}
}
}
struct EventRow: View {
let event: NotifyEvent
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(event.title).font(.headline)
Text(event.message).font(.subheadline)
Text(detail).font(.caption).foregroundStyle(.secondary)
}
}
private var detail: String {
let folder = event.cwd.map { URL(fileURLWithPath: $0).lastPathComponent } ?? "unknown folder"
return "\(folder) · \(event.timestamp.formatted(date: .omitted, time: .shortened))"
}
}