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.
This commit is contained in:
42
Tests/NotifierCoreTests/TurnTimerTests.swift
Normal file
42
Tests/NotifierCoreTests/TurnTimerTests.swift
Normal file
@@ -0,0 +1,42 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import NotifierCore
|
||||
|
||||
struct TurnTimerTests {
|
||||
private let start = Date(timeIntervalSince1970: 1_000)
|
||||
|
||||
@Test func aTurnLongerThanTheMinimumNotifies() {
|
||||
#expect(TurnTimer.shouldNotify(startedAt: start, endedAt: start.addingTimeInterval(45), minimumSeconds: 30))
|
||||
}
|
||||
|
||||
@Test func aQuickTurnIsSuppressed() {
|
||||
#expect(!TurnTimer.shouldNotify(startedAt: start, endedAt: start.addingTimeInterval(5), minimumSeconds: 30))
|
||||
}
|
||||
|
||||
@Test func aTurnExactlyAtTheMinimumNotifies() {
|
||||
#expect(TurnTimer.shouldNotify(startedAt: start, endedAt: start.addingTimeInterval(30), minimumSeconds: 30))
|
||||
}
|
||||
|
||||
@Test func aMissingStartErrsTowardNotifying() {
|
||||
#expect(TurnTimer.shouldNotify(startedAt: nil, endedAt: start, minimumSeconds: 30))
|
||||
}
|
||||
|
||||
@Test func recordedStartIsReadBack() throws {
|
||||
let directory = NSTemporaryDirectory() + "turntimer-\(UUID().uuidString)"
|
||||
defer { try? FileManager.default.removeItem(atPath: directory) }
|
||||
try TurnTimer.recordStart(at: start, directory: directory)
|
||||
#expect(TurnTimer.readStart(directory: directory) == start)
|
||||
}
|
||||
|
||||
@Test func aMissingStartFileReadsAsNil() {
|
||||
#expect(TurnTimer.readStart(directory: "/tmp/does-not-exist-\(UUID().uuidString)") == nil)
|
||||
}
|
||||
|
||||
@Test func aCorruptStartFileReadsAsNilInsteadOfCrashing() throws {
|
||||
let directory = NSTemporaryDirectory() + "turntimer-\(UUID().uuidString)"
|
||||
defer { try? FileManager.default.removeItem(atPath: directory) }
|
||||
try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true)
|
||||
try "not a number".write(toFile: TurnTimer.startFilePath(directory: directory), atomically: true, encoding: .utf8)
|
||||
#expect(TurnTimer.readStart(directory: directory) == nil)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user