From c94c964b08b6851855b75b4772b58b235f1be981 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 11:43:41 +0400 Subject: [PATCH 01/43] List valid animations and accept short animation names, preferring larger assets Add nyathing list to print valid animations in sorted order. Allow selecting animations by their name without the size suffix, choosing the 54x36 version when both sizes are available. Update the help and README with the new command and selection behavior. --- README.md | 13 +++++++++-- Sources/Nyathing/CLI.swift | 46 +++++++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1678537..5957e60 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,23 @@ custom animation: ```sh nyathing sleep 5 - nyathing --animation nyan_54x36.png sleep 5 + nyathing --animation nyan sleep 5 ``` `--animation` (or `-a`) selects an animation from Nyathing's user animation -directory. Without it, the CLI uses `nyathing_36x36.png`, regardless of the +directory. You can use the short name before the frame-size suffix and `.png` +(for example, `nyan` instead of `nyan_54x36.png`). If both `nyan_36x36.png` +and `nyan_54x36.png` exist, Nyathing chooses the larger `54x36` animation. +Without `--animation`, the CLI uses `nyathing_36x36.png`, regardless of the configured server default. Quote paths containing spaces as usual in your shell. Relative command paths are resolved from the current working directory. +List valid installed animations with: + +```sh + nyathing list +``` + To view available options or check the installed version: ```sh diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 0ed2e83..5268cc0 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -38,18 +38,23 @@ struct CLIArguments { let command: String let arguments: [String] - static let usage = """ - Nyathing displays playful animations in the macOS menu bar while commands run. + static var usage: String { + let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String + ?? "Development build" + return """ + Nyathing \(version) displays playful animations in the macOS menu bar while commands run. Usage: nyathing [--animation FILE | -a FILE] COMMAND [ARGUMENT ...] nyathing uninstall + nyathing list nyathing --help nyathing --version Commands: COMMAND [ARGUMENT ...] Run a command while showing an activity animation. uninstall Remove the installed app and CLI command. + list List available valid animations. Options: -a, --animation FILE Select an animation from the user animations folder. @@ -60,6 +65,7 @@ struct CLIArguments { nyathing sleep 5 nyathing --animation nyan_54x36.png make test """ + } static func parse(_ arguments: [String]) throws -> CLIArguments { var values = arguments @@ -107,6 +113,15 @@ enum NyathingCLI { return 0 } do { + if arguments == ["list"] { + _ = try AppConfiguration.load() + let directory = AppConfiguration.configurationDirectory + .appendingPathComponent("animations", isDirectory: true) + for filename in SpriteAnimation.loadAll(in: directory).keys.sorted() { + print(filename) + } + return 0 + } let parsed = try CLIArguments.parse(arguments) return try execute(parsed) } catch { @@ -120,10 +135,10 @@ enum NyathingCLI { let configuration = try AppConfiguration.load() let animationsDirectory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) - try validateAnimation(cli.animation, in: animationsDirectory) + let animation = try resolveAnimation(cli.animation, in: animationsDirectory) let keepaliveInterval = keepaliveInterval(for: configuration) let client = try LocalAPIClient.connectOrStartServer() - let activity = try client.command(["command": "start", "animation": cli.animation]) + let activity = try client.command(["command": "start", "animation": animation]) guard let activityID = activity["activity_id"] as? String else { throw CLIError.api("The server returned an invalid activity response.") } @@ -180,11 +195,26 @@ enum NyathingCLI { } static func validateAnimation(_ filename: String, in directory: URL) throws { - guard !filename.contains("/"), !filename.contains("\\"), - (try? SpriteAnimation.load(from: directory.appendingPathComponent(filename))) != nil - else { - throw CLIError.animationUnavailable(filename) + _ = try resolveAnimation(filename, in: directory) + } + + static func resolveAnimation(_ name: String, in directory: URL) throws -> String { + guard !name.contains("/"), !name.contains("\\") else { + throw CLIError.animationUnavailable(name) + } + let stem = name.replacingOccurrences( + of: #"_(?:36x36|54x36)\.png$"#, with: "", options: [.caseInsensitive, .regularExpression]) + guard let files = try? FileManager.default.contentsOfDirectory( + at: directory, includingPropertiesForKeys: nil) + else { throw CLIError.animationUnavailable(name) } + for size in ["54x36", "36x36"] { + let expected = "\(stem)_\(size).png" + guard let file = files.first(where: { + $0.lastPathComponent.caseInsensitiveCompare(expected) == .orderedSame + }), let animation = try? SpriteAnimation.load(from: file) else { continue } + return animation.filename } + throw CLIError.animationUnavailable(name) } static func keepaliveInterval(for configuration: AppConfiguration) -> TimeInterval { From 7adf56a4ee6b75b4312cbce40a4b91aa0ecc83b6 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 18:15:16 +0400 Subject: [PATCH 02/43] Forward activity descriptions through the start API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Accept optional descriptions when starting activities and retain them through expiration, using “No description provided” when absent. Preserve timed-out activity details for later error reporting. Have the CLI describe each activity using the child command and its arguments joined by spaces. Add tests for API description forwarding, timeout retention and fallback, and CLI formatting. --- Sources/Nyathing/ActivityLifecycle.swift | 30 +++++++++-- Sources/Nyathing/CLI.swift | 10 +++- Sources/Nyathing/LocalAPIServer.swift | 9 ++-- Sources/Nyathing/main.swift | 13 ++--- .../ConfigurationAndAPITests.swift | 50 +++++++++++++++++-- 5 files changed, 92 insertions(+), 20 deletions(-) diff --git a/Sources/Nyathing/ActivityLifecycle.swift b/Sources/Nyathing/ActivityLifecycle.swift index 988024a..045b8ef 100644 --- a/Sources/Nyathing/ActivityLifecycle.swift +++ b/Sources/Nyathing/ActivityLifecycle.swift @@ -2,14 +2,24 @@ import Foundation /// Tracks activity ownership, per-activity expiration generations, and disconnect accounting. struct ActivityLifecycle { + static let missingDescription = "No description provided" + private(set) var activities: [UUID: String] = [:] + private(set) var descriptions: [UUID: String] = [:] private(set) var expirationDeadlines: [UUID: UInt64] = [:] + private(set) var timedOutActivities: [ExpiredActivity] = [] private(set) var disconnectedCount = 0 + struct ExpiredActivity: Equatable { + let animation: String + let description: String + } + @discardableResult - mutating func start(animation: String, deadline: UInt64) -> UUID { + mutating func start(animation: String, description: String? = nil, deadline: UInt64) -> UUID { let id = UUID() activities[id] = animation + descriptions[id] = description ?? Self.missingDescription expirationDeadlines[id] = deadline return id } @@ -23,18 +33,22 @@ struct ActivityLifecycle { @discardableResult mutating func stop(_ id: UUID) -> String? { expirationDeadlines.removeValue(forKey: id) + descriptions.removeValue(forKey: id) return activities.removeValue(forKey: id) } - /// Expires an activity only for its current deadline and increments the disconnect count once. + /// Expires an activity at its current deadline and returns its description for error reporting. @discardableResult - mutating func expire(_ id: UUID, deadline: UInt64) -> String? { + mutating func expire(_ id: UUID, deadline: UInt64) -> ExpiredActivity? { guard expirationDeadlines[id] == deadline, - let animation = activities.removeValue(forKey: id) + let animation = activities.removeValue(forKey: id), + let description = descriptions.removeValue(forKey: id) else { return nil } expirationDeadlines.removeValue(forKey: id) disconnectedCount += 1 - return animation + let expired = ExpiredActivity(animation: animation, description: description) + timedOutActivities.append(expired) + return expired } func animation(for id: UUID) -> String? { @@ -45,6 +59,10 @@ struct ActivityLifecycle { expirationDeadlines[id] } + func description(for id: UUID) -> String? { + descriptions[id] + } + func activityCount(for animation: String) -> Int { activities.values.reduce(into: 0) { count, value in if value == animation { count += 1 } @@ -57,7 +75,9 @@ struct ActivityLifecycle { mutating func reset() { activities.removeAll() + descriptions.removeAll() expirationDeadlines.removeAll() + timedOutActivities.removeAll() disconnectedCount = 0 } } diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 5268cc0..e9575e7 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -138,7 +138,11 @@ enum NyathingCLI { let animation = try resolveAnimation(cli.animation, in: animationsDirectory) let keepaliveInterval = keepaliveInterval(for: configuration) let client = try LocalAPIClient.connectOrStartServer() - let activity = try client.command(["command": "start", "animation": animation]) + let activity = try client.command([ + "command": "start", + "animation": animation, + "description": activityDescription(command: cli.command, arguments: cli.arguments), + ]) guard let activityID = activity["activity_id"] as? String else { throw CLIError.api("The server returned an invalid activity response.") } @@ -217,6 +221,10 @@ enum NyathingCLI { throw CLIError.animationUnavailable(name) } + static func activityDescription(command: String, arguments: [String]) -> String { + ([command] + arguments).joined(separator: " ") + } + static func keepaliveInterval(for configuration: AppConfiguration) -> TimeInterval { min(configuration.keepaliveInterval, configuration.activityTimeout / 2) } diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index fe2df23..6131429 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -4,7 +4,7 @@ import Foundation /// Serves the local JSON Lines API over a current-user Unix domain socket. final class LocalAPIServer { private let defaultAnimation: String - private let onStart: (String) throws -> String + private let onStart: (String, String?) throws -> String private let onKeepalive: (String) throws -> Void private let onStop: (String) throws -> Void private let socketPath: String @@ -16,7 +16,7 @@ final class LocalAPIServer { init( socketPath: String = LocalAPIServer.socketPath, defaultAnimation: String = "nyathing_36x36.png", - onStart: @escaping (String) throws -> String, + onStart: @escaping (String, String?) throws -> String, onKeepalive: @escaping (String) throws -> Void, onStop: @escaping (String) throws -> Void ) { @@ -216,7 +216,10 @@ final class LocalAPIServer { case "start": let animation = request["animation"] as? String ?? defaultAnimation guard !animation.isEmpty else { throw LocalAPIError.invalidRequest } - return ["ok": true, "activity_id": try onStart(animation)] + return [ + "ok": true, + "activity_id": try onStart(animation, request["description"] as? String), + ] case "keepalive": guard let activityID = request["activity_id"] as? String, !activityID.isEmpty else { throw LocalAPIError.invalidRequest diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 6c3f2e5..5ff2a98 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -194,10 +194,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let generation = apiGeneration apiServer = LocalAPIServer( defaultAnimation: defaultAnimation, - onStart: { [weak self] filename in + onStart: { [weak self] filename, description in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } - return self.startActivity(animation: filename).uuidString + return self.startActivity(animation: filename, description: description).uuidString } }, onKeepalive: { [weak self] activityID in @@ -236,10 +236,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate { /// Begins an activity for a named animation, sharing its status item with matching activities. @discardableResult - func startActivity(animation filename: String) -> UUID { + func startActivity(animation filename: String, description: String? = nil) -> UUID { let deadline = DispatchTime.now() + activityTimeout let deadlineUptime = deadline.uptimeNanoseconds - let id = lifecycle.start(animation: filename, deadline: deadlineUptime) + let id = lifecycle.start( + animation: filename, description: description, deadline: deadlineUptime) scheduleActivityExpiration(id, deadlineUptime: deadlineUptime) if let active = activeAnimations[filename] { active.activityIDs.insert(id) @@ -370,8 +371,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } return } - guard let filename = lifecycle.expire(id, deadline: deadlineUptime) else { return } - removeActivityFromStatusItem(id, animation: filename) + guard let expired = lifecycle.expire(id, deadline: deadlineUptime) else { return } + removeActivityFromStatusItem(id, animation: expired.animation) presentActivityTimeout() } diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 9d90f4f..2cbb5b2 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -52,6 +52,13 @@ final class CLITests: XCTestCase { try NyathingCLI.validateAnimation("../nyan_54x36.png", in: animationsDirectory)) } + func testActivityDescriptionJoinsChildCommandAndArguments() { + XCTAssertEqual( + NyathingCLI.activityDescription(command: "./run me", arguments: ["--flag", "a b"]), + "./run me --flag a b") + XCTAssertEqual(NyathingCLI.activityDescription(command: "sleep", arguments: []), "sleep") + } + func testKeepaliveIntervalPrecedesConfiguredActivityTimeout() { let configuration = AppConfiguration( keepaliveInterval: 5, activityTimeout: 0.8, autoStart: false, @@ -219,11 +226,39 @@ final class ActivityLifecycleTests: XCTestCase { XCTAssertNil( lifecycle.expire(second, deadline: 20), "An obsolete timeout must not expire a renewed activity.") - XCTAssertEqual(lifecycle.expire(second, deadline: 40), "same_36x36.png") + XCTAssertEqual( + lifecycle.expire(second, deadline: 40), + ActivityLifecycle.ExpiredActivity( + animation: "same_36x36.png", description: ActivityLifecycle.missingDescription)) XCTAssertEqual(lifecycle.disconnectedCount, 1) XCTAssertEqual(lifecycle.activityCount(for: "same_36x36.png"), 0) - XCTAssertEqual(lifecycle.expire(distinct, deadline: 30), "other_36x36.png") + XCTAssertEqual( + lifecycle.expire(distinct, deadline: 30), + ActivityLifecycle.ExpiredActivity( + animation: "other_36x36.png", description: ActivityLifecycle.missingDescription)) XCTAssertEqual(lifecycle.disconnectedCount, 2) + XCTAssertEqual(lifecycle.timedOutActivities.count, 2) + } + + func testDescriptionsAreRetainedThroughTimeoutAndDefaultWhenAbsent() { + var lifecycle = ActivityLifecycle() + let described = lifecycle.start( + animation: "nyathing_36x36.png", description: "build test", deadline: 10) + let undescribed = lifecycle.start(animation: "nyathing_36x36.png", deadline: 20) + + XCTAssertEqual(lifecycle.description(for: described), "build test") + XCTAssertEqual(lifecycle.description(for: undescribed), ActivityLifecycle.missingDescription) + XCTAssertEqual( + lifecycle.expire(described, deadline: 10), + ActivityLifecycle.ExpiredActivity(animation: "nyathing_36x36.png", description: "build test")) + XCTAssertEqual( + lifecycle.expire(undescribed, deadline: 20), + ActivityLifecycle.ExpiredActivity( + animation: "nyathing_36x36.png", description: ActivityLifecycle.missingDescription)) + XCTAssertEqual( + lifecycle.timedOutActivities.map(\.description), [ + "build test", ActivityLifecycle.missingDescription, + ]) } func testResetClearsActivitiesDeadlinesAndDisconnectCount() throws { @@ -238,6 +273,7 @@ final class ActivityLifecycleTests: XCTestCase { XCTAssertEqual(lifecycle.disconnectedCount, 0) XCTAssertNil(lifecycle.animation(for: activeID)) XCTAssertNil(lifecycle.deadline(for: activeID)) + XCTAssertTrue(lifecycle.timedOutActivities.isEmpty) XCTAssertEqual(lifecycle.activityCount(for: "same_36x36.png"), 0) } } @@ -251,14 +287,16 @@ final class LocalAPIServerTests: XCTestCase { let socketPath = directory.appendingPathComponent("api.sock").path let lock = NSLock() var startedAnimations: [String] = [] + var startedDescriptions: [String?] = [] var stoppedIDs: [String] = [] let server = LocalAPIServer( socketPath: socketPath, defaultAnimation: "nyan_54x36.png", - onStart: { animation in + onStart: { animation, description in lock.lock() defer { lock.unlock() } startedAnimations.append(animation) + startedDescriptions.append(description) return "activity-\(startedAnimations.count)" }, onKeepalive: { _ in }, onStop: { id in @@ -271,8 +309,9 @@ final class LocalAPIServerTests: XCTestCase { let first = try UnixJSONClient(path: socketPath) XCTAssertEqual( - try first.command(["command": "start", "animation": "same_36x36.png"])["activity_id"] - as? String, + try first.command([ + "command": "start", "animation": "same_36x36.png", "description": "first client", + ])["activity_id"] as? String, "activity-1") XCTAssertEqual( try first.command(["command": "keepalive", "activity_id": "activity-1"])["ok"] as? Bool, @@ -292,6 +331,7 @@ final class LocalAPIServerTests: XCTestCase { XCTAssertEqual( startedAnimations, ["same_36x36.png", "same_36x36.png", "nyan_54x36.png"]) XCTAssertEqual(stoppedIDs, ["activity-1"]) + XCTAssertEqual(startedDescriptions, ["first client", nil, nil]) lock.unlock() let responseLock = NSLock() From a5e25060c1abf5587707c05e54a861ef361e8dfb Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 18:24:53 +0400 Subject: [PATCH 03/43] Clear timeout errors when resetting disconnect count Resetting the disconnected count now also clears outstanding timeout records and refreshes the status indicator and its visibility. Replace the animated warning with a static timeout-error indicator showing the outstanding count. Add a lifecycle test for reset behavior. --- Sources/Nyathing/ActivityLifecycle.swift | 1 + Sources/Nyathing/main.swift | 44 +++++-------------- .../ConfigurationAndAPITests.swift | 12 +++++ 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/Sources/Nyathing/ActivityLifecycle.swift b/Sources/Nyathing/ActivityLifecycle.swift index 045b8ef..1c24c81 100644 --- a/Sources/Nyathing/ActivityLifecycle.swift +++ b/Sources/Nyathing/ActivityLifecycle.swift @@ -71,6 +71,7 @@ struct ActivityLifecycle { mutating func resetDisconnectedCount() { disconnectedCount = 0 + timedOutActivities.removeAll() } mutating func reset() { diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 5ff2a98..fbd124a 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -48,8 +48,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private var defaultAnimation = "nyathing_36x36.png" private var apiServer: LocalAPIServer? private var apiGeneration = 0 - private var warningFrames: [NSImage] = [] - private var warningFrameIndex = 0 func applicationDidFinishLaunching(_ notification: Notification) { let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) @@ -133,8 +131,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { @objc private func resetDisconnectedCount() { lifecycle.resetDisconnectedCount() - warningFrames = [] - warningFrameIndex = 0 + updateMainStatusItemVisibility() updateMainStatusItem() } @@ -230,8 +227,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { activeAnimations.removeAll() updateMainStatusItemVisibility() lifecycle.reset() - warningFrames = [] - warningFrameIndex = 0 } /// Begins an activity for a named animation, sharing its status item with matching activities. @@ -284,17 +279,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } } - /// Displays the timeout effect after lifecycle accounting records an expired activity. + /// Refreshes the static error indicator after lifecycle accounting records a timeout. private func presentActivityTimeout() { - let directory = AppConfiguration.configurationDirectory.appendingPathComponent( - "animations", isDirectory: true) - if let explosion = SpriteAnimation.loadAll(in: directory)["explosion_36x36.png"] { - warningFrames = explosion.frames - warningFrameIndex = 0 - } else { - warningFrames = [] - NyathingLog.write("Explosion animation explosion_36x36.png is missing or invalid") - } + updateMainStatusItemVisibility() updateMainStatusItem() } @@ -381,30 +368,21 @@ final class AppDelegate: NSObject, NSApplicationDelegate { active.frameIndex = (active.frameIndex + 1) % active.frames.count updateActivityStatus(active) } - if !warningFrames.isEmpty { - warningFrameIndex += 1 - if warningFrameIndex >= warningFrames.count { - warningFrames = [] - warningFrameIndex = 0 - } - } updateMainStatusItem() } private func updateMainStatusItemVisibility() { - mainStatusItem?.isVisible = activeAnimations.isEmpty + mainStatusItem?.isVisible = activeAnimations.isEmpty || !lifecycle.timedOutActivities.isEmpty } private func updateMainStatusItem() { guard let button = mainStatusItem?.button else { return } - if lifecycle.disconnectedCount > 0 { - button.image = - warningFrames.isEmpty - ? NSImage( - systemSymbolName: "exclamationmark.triangle.fill", - accessibilityDescription: "Disconnected clients") - : warningFrames[warningFrameIndex] - button.title = "\(lifecycle.disconnectedCount)" + let outstandingErrorCount = lifecycle.timedOutActivities.count + if outstandingErrorCount > 0 { + button.image = NSImage( + systemSymbolName: "exclamationmark.triangle.fill", + accessibilityDescription: "Outstanding timeout errors") + button.title = "\(outstandingErrorCount)" } else { button.image = staticAppIcon @@ -414,7 +392,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } button.image?.isTemplate = false button.image?.accessibilityDescription = - lifecycle.disconnectedCount > 0 ? "Disconnected clients" : "Nyathing" + outstandingErrorCount > 0 ? "Outstanding timeout errors" : "Nyathing" } private static func builtInGhostFrames() -> [NSImage] { diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 2cbb5b2..536dfcf 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -261,6 +261,18 @@ final class ActivityLifecycleTests: XCTestCase { ]) } + func testResetDisconnectedCountClearsOutstandingTimeouts() { + var lifecycle = ActivityLifecycle() + let id = lifecycle.start(animation: "nyathing_36x36.png", deadline: 10) + _ = lifecycle.expire(id, deadline: 10) + XCTAssertEqual(lifecycle.timedOutActivities.count, 1) + + lifecycle.resetDisconnectedCount() + + XCTAssertEqual(lifecycle.disconnectedCount, 0) + XCTAssertTrue(lifecycle.timedOutActivities.isEmpty) + } + func testResetClearsActivitiesDeadlinesAndDisconnectCount() throws { var lifecycle = ActivityLifecycle() let id = lifecycle.start(animation: "nyathing_36x36.png", deadline: 10) From c97d3869aff44e3131fb836752fc184fcfe1c819 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 19:19:43 +0400 Subject: [PATCH 04/43] Add an interface for acknowledging timeout errors Give expired activities stable IDs so errors can be acknowledged individually. Add a menu item and window for reviewing timeout descriptions, update the disconnected count as errors are acknowledged, and keep the main status item visible while idle. Refresh the error list and status item when lifecycle state changes. Add coverage for acknowledging individual timeouts with matching descriptions. --- Sources/Nyathing/ActivityLifecycle.swift | 12 ++- Sources/Nyathing/main.swift | 88 ++++++++++++++++++- .../ConfigurationAndAPITests.swift | 26 +++++- 3 files changed, 118 insertions(+), 8 deletions(-) diff --git a/Sources/Nyathing/ActivityLifecycle.swift b/Sources/Nyathing/ActivityLifecycle.swift index 1c24c81..83f84e7 100644 --- a/Sources/Nyathing/ActivityLifecycle.swift +++ b/Sources/Nyathing/ActivityLifecycle.swift @@ -10,7 +10,8 @@ struct ActivityLifecycle { private(set) var timedOutActivities: [ExpiredActivity] = [] private(set) var disconnectedCount = 0 - struct ExpiredActivity: Equatable { + struct ExpiredActivity: Equatable, Identifiable { + let id: UUID let animation: String let description: String } @@ -46,7 +47,7 @@ struct ActivityLifecycle { else { return nil } expirationDeadlines.removeValue(forKey: id) disconnectedCount += 1 - let expired = ExpiredActivity(animation: animation, description: description) + let expired = ExpiredActivity(id: id, animation: animation, description: description) timedOutActivities.append(expired) return expired } @@ -69,6 +70,13 @@ struct ActivityLifecycle { } } + mutating func acknowledgeTimeout(_ id: UUID) -> Bool { + guard let index = timedOutActivities.firstIndex(where: { $0.id == id }) else { return false } + timedOutActivities.remove(at: index) + disconnectedCount = max(0, disconnectedCount - 1) + return true + } + mutating func resetDisconnectedCount() { disconnectedCount = 0 timedOutActivities.removeAll() diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index fbd124a..780bca5 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -48,6 +48,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private var defaultAnimation = "nyathing_36x36.png" private var apiServer: LocalAPIServer? private var apiGeneration = 0 + private var errorsWindow: NSWindow? + private var errorsStackView: NSStackView? func applicationDidFinishLaunching(_ notification: Notification) { let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) @@ -81,6 +83,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let menu = NSMenu() menu.addItem(withTitle: "About Nyathing", action: #selector(showAbout), keyEquivalent: "") menu.addItem(.separator()) + menu.addItem( + withTitle: "View Errors", action: #selector(viewErrors), keyEquivalent: "") menu.addItem( withTitle: "Reset Disconnected Count", action: #selector(resetDisconnectedCount), keyEquivalent: "") @@ -129,10 +133,85 @@ final class AppDelegate: NSObject, NSApplicationDelegate { NSApp.terminate(nil) } + @objc private func viewErrors() { + if errorsWindow == nil { + let window = NSWindow( + contentRect: NSRect(x: 0, y: 0, width: 480, height: 320), + styleMask: [.titled, .closable, .miniaturizable, .resizable], + backing: .buffered, defer: false) + window.title = "Timeout Errors" + window.isReleasedWhenClosed = false + + let scrollView = NSScrollView() + scrollView.hasVerticalScroller = true + scrollView.translatesAutoresizingMaskIntoConstraints = false + let stack = NSStackView() + stack.orientation = .vertical + stack.alignment = .leading + stack.spacing = 10 + stack.setContentHuggingPriority(.required, for: .vertical) + stack.setContentCompressionResistancePriority(.required, for: .vertical) + stack.translatesAutoresizingMaskIntoConstraints = false + scrollView.documentView = stack + window.contentView = scrollView + NSLayoutConstraint.activate([ + stack.leadingAnchor.constraint(equalTo: scrollView.contentView.leadingAnchor, constant: 12), + stack.trailingAnchor.constraint(equalTo: scrollView.contentView.trailingAnchor, constant: -12), + stack.topAnchor.constraint(equalTo: scrollView.contentView.topAnchor, constant: 12), + stack.widthAnchor.constraint(equalTo: scrollView.contentView.widthAnchor, constant: -24), + stack.heightAnchor.constraint( + greaterThanOrEqualTo: scrollView.contentView.heightAnchor, constant: -24), + ]) + errorsWindow = window + errorsStackView = stack + } + refreshErrorsWindow() + errorsWindow?.center() + errorsWindow?.makeKeyAndOrderFront(nil) + NSApp.activate(ignoringOtherApps: true) + } + + @objc private func acknowledgeError(_ sender: NSButton) { + guard let id = UUID(uuidString: sender.identifier?.rawValue ?? ""), + lifecycle.acknowledgeTimeout(id) + else { return } + updateMainStatusItemVisibility() + updateMainStatusItem() + refreshErrorsWindow() + } + + private func refreshErrorsWindow() { + guard let stack = errorsStackView else { return } + stack.arrangedSubviews.forEach { stack.removeArrangedSubview($0); $0.removeFromSuperview() } + if lifecycle.timedOutActivities.isEmpty { + let emptyLabel = NSTextField(labelWithString: "No errors") + emptyLabel.lineBreakMode = .byWordWrapping + stack.addArrangedSubview(emptyLabel) + return + } + for error in lifecycle.timedOutActivities { + let row = NSStackView() + row.orientation = .horizontal + row.alignment = .centerY + row.spacing = 12 + row.distribution = .fill + let descriptionLabel = NSTextField(wrappingLabelWithString: error.description) + descriptionLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + let acknowledgeButton = NSButton( + title: "Acknowledge", target: self, action: #selector(acknowledgeError(_:))) + acknowledgeButton.identifier = NSUserInterfaceItemIdentifier(error.id.uuidString) + row.addArrangedSubview(descriptionLabel) + row.addArrangedSubview(acknowledgeButton) + stack.addArrangedSubview(row) + row.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true + } + } + @objc private func resetDisconnectedCount() { lifecycle.resetDisconnectedCount() updateMainStatusItemVisibility() updateMainStatusItem() + refreshErrorsWindow() } @objc private func reloadFromMenu() { @@ -225,8 +304,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate { NSStatusBar.system.removeStatusItem(active.statusItem) } activeAnimations.removeAll() - updateMainStatusItemVisibility() lifecycle.reset() + updateMainStatusItemVisibility() + updateMainStatusItem() + refreshErrorsWindow() } /// Begins an activity for a named animation, sharing its status item with matching activities. @@ -241,6 +322,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { active.activityIDs.insert(id) updateActivityStatus(active) updateMainStatusItemVisibility() + updateMainStatusItem() return id } @@ -258,6 +340,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { activeAnimations[filename] = active updateActivityStatus(active) updateMainStatusItemVisibility() + updateMainStatusItem() return id } @@ -283,6 +366,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private func presentActivityTimeout() { updateMainStatusItemVisibility() updateMainStatusItem() + refreshErrorsWindow() } private func updateActivityStatus(_ active: ActiveAnimation) { @@ -372,7 +456,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } private func updateMainStatusItemVisibility() { - mainStatusItem?.isVisible = activeAnimations.isEmpty || !lifecycle.timedOutActivities.isEmpty + mainStatusItem?.isVisible = true } private func updateMainStatusItem() { diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 536dfcf..b5ad7ee 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -229,13 +229,13 @@ final class ActivityLifecycleTests: XCTestCase { XCTAssertEqual( lifecycle.expire(second, deadline: 40), ActivityLifecycle.ExpiredActivity( - animation: "same_36x36.png", description: ActivityLifecycle.missingDescription)) + id: second, animation: "same_36x36.png", description: ActivityLifecycle.missingDescription)) XCTAssertEqual(lifecycle.disconnectedCount, 1) XCTAssertEqual(lifecycle.activityCount(for: "same_36x36.png"), 0) XCTAssertEqual( lifecycle.expire(distinct, deadline: 30), ActivityLifecycle.ExpiredActivity( - animation: "other_36x36.png", description: ActivityLifecycle.missingDescription)) + id: distinct, animation: "other_36x36.png", description: ActivityLifecycle.missingDescription)) XCTAssertEqual(lifecycle.disconnectedCount, 2) XCTAssertEqual(lifecycle.timedOutActivities.count, 2) } @@ -250,17 +250,35 @@ final class ActivityLifecycleTests: XCTestCase { XCTAssertEqual(lifecycle.description(for: undescribed), ActivityLifecycle.missingDescription) XCTAssertEqual( lifecycle.expire(described, deadline: 10), - ActivityLifecycle.ExpiredActivity(animation: "nyathing_36x36.png", description: "build test")) + ActivityLifecycle.ExpiredActivity( + id: described, animation: "nyathing_36x36.png", description: "build test")) XCTAssertEqual( lifecycle.expire(undescribed, deadline: 20), ActivityLifecycle.ExpiredActivity( - animation: "nyathing_36x36.png", description: ActivityLifecycle.missingDescription)) + id: undescribed, animation: "nyathing_36x36.png", + description: ActivityLifecycle.missingDescription)) XCTAssertEqual( lifecycle.timedOutActivities.map(\.description), [ "build test", ActivityLifecycle.missingDescription, ]) } + func testAcknowledgesTimeoutsIndividuallyEvenWhenDescriptionsMatch() { + var lifecycle = ActivityLifecycle() + let first = lifecycle.start(animation: "one", description: "same", deadline: 10) + let second = lifecycle.start(animation: "two", description: "same", deadline: 20) + _ = lifecycle.expire(first, deadline: 10) + _ = lifecycle.expire(second, deadline: 20) + + XCTAssertTrue(lifecycle.acknowledgeTimeout(first)) + XCTAssertEqual(lifecycle.timedOutActivities.map(\.id), [second]) + XCTAssertEqual(lifecycle.disconnectedCount, 1) + XCTAssertFalse(lifecycle.acknowledgeTimeout(first)) + XCTAssertTrue(lifecycle.acknowledgeTimeout(second)) + XCTAssertTrue(lifecycle.timedOutActivities.isEmpty) + XCTAssertEqual(lifecycle.disconnectedCount, 0) + } + func testResetDisconnectedCountClearsOutstandingTimeouts() { var lifecycle = ActivityLifecycle() let id = lifecycle.start(animation: "nyathing_36x36.png", deadline: 10) From 85a367295f3b0f6d749e5107d662ee10d97d81e0 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 19:27:40 +0400 Subject: [PATCH 05/43] Implement random animation selection Prefer a valid user animation named random; otherwise choose uniformly from the available animations, falling back to the built-in ghost when none are available. Add tests for selection, name precedence, and fallback. --- Sources/Nyathing/CLI.swift | 13 ++++++ .../ConfigurationAndAPITests.swift | 44 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index e9575e7..eecde18 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -98,6 +98,8 @@ enum CLIError: LocalizedError { } enum NyathingCLI { + static let builtInGhostAnimation = "__built_in_ghost__" + static func run(_ arguments: [String]) -> Int32 { if arguments == ["uninstall"] { return NyathingUninstaller.run() @@ -206,6 +208,17 @@ enum NyathingCLI { guard !name.contains("/"), !name.contains("\\") else { throw CLIError.animationUnavailable(name) } + if name == "random" { + if let namedAnimation = try? resolveNamedAnimation(name, in: directory) { + return namedAnimation + } + let available = SpriteAnimation.loadAll(in: directory) + return available.keys.sorted().randomElement() ?? builtInGhostAnimation + } + return try resolveNamedAnimation(name, in: directory) + } + + private static func resolveNamedAnimation(_ name: String, in directory: URL) throws -> String { let stem = name.replacingOccurrences( of: #"_(?:36x36|54x36)\.png$"#, with: "", options: [.caseInsensitive, .regularExpression]) guard let files = try? FileManager.default.contentsOfDirectory( diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index b5ad7ee..26dd973 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -52,6 +52,50 @@ final class CLITests: XCTestCase { try NyathingCLI.validateAnimation("../nyan_54x36.png", in: animationsDirectory)) } + func testRandomAnimationSelectsFromAvailableAnimations() throws { + let directory = FileManager.default.temporaryDirectory + .appendingPathComponent("NyathingRandom-\\(UUID().uuidString)", isDirectory: true) + defer { try? FileManager.default.removeItem(at: directory) } + _ = try AppConfiguration.load(in: directory) + let animationsDirectory = directory.appendingPathComponent("animations", isDirectory: true) + let listedAnimations = Set(SpriteAnimation.loadAll(in: animationsDirectory).keys) + + let selected = try NyathingCLI.resolveAnimation("random", in: animationsDirectory) + + XCTAssertFalse(listedAnimations.isEmpty) + XCTAssertTrue(listedAnimations.contains(selected)) + } + + func testNamedRandomAnimationTakesPrecedence() throws { + let directory = FileManager.default.temporaryDirectory + .appendingPathComponent("NyathingRandom-\\(UUID().uuidString)", isDirectory: true) + defer { try? FileManager.default.removeItem(at: directory) } + _ = try AppConfiguration.load(in: directory) + let animationsDirectory = directory.appendingPathComponent("animations", isDirectory: true) + let randomAnimation = animationsDirectory.appendingPathComponent("random_36x36.png") + try FileManager.default.copyItem( + at: animationsDirectory.appendingPathComponent("nyathing_36x36.png"), to: randomAnimation) + + XCTAssertEqual( + try NyathingCLI.resolveAnimation("random", in: animationsDirectory), "random_36x36.png") + } + + func testRandomAnimationFallsBackToBuiltInGhostWhenPoolIsEmpty() throws { + let directory = FileManager.default.temporaryDirectory + .appendingPathComponent("NyathingRandom-\\(UUID().uuidString)", isDirectory: true) + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + defer { try? FileManager.default.removeItem(at: directory) } + + let selected = try NyathingCLI.resolveAnimation("random", in: directory) + + XCTAssertEqual(selected, NyathingCLI.builtInGhostAnimation) + if case .builtInGhost = AnimationResolution.resolve(selected, available: [:]) { + XCTAssertTrue(true) + } else { + XCTFail("An empty random selection pool must resolve to the built-in ghost.") + } + } + func testActivityDescriptionJoinsChildCommandAndArguments() { XCTAssertEqual( NyathingCLI.activityDescription(command: "./run me", arguments: ["--flag", "a b"]), From b881b7eabf8b343a801c84bf07facc34dd6c70c1 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 19:46:32 +0400 Subject: [PATCH 06/43] Formatting --- Sources/Nyathing/CLI.swift | 62 ++++++++++--------- Sources/Nyathing/main.swift | 8 ++- .../ConfigurationAndAPITests.swift | 6 +- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index eecde18..fa0f2fc 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -39,32 +39,33 @@ struct CLIArguments { let arguments: [String] static var usage: String { - let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String + let version = + Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "Development build" return """ - Nyathing \(version) displays playful animations in the macOS menu bar while commands run. - - Usage: - nyathing [--animation FILE | -a FILE] COMMAND [ARGUMENT ...] - nyathing uninstall - nyathing list - nyathing --help - nyathing --version - - Commands: - COMMAND [ARGUMENT ...] Run a command while showing an activity animation. - uninstall Remove the installed app and CLI command. - list List available valid animations. - - Options: - -a, --animation FILE Select an animation from the user animations folder. - --help Show this help. - --version Show the app version. - - Examples: - nyathing sleep 5 - nyathing --animation nyan_54x36.png make test - """ + Nyathing \(version) displays playful animations in the macOS menu bar while commands run. + + Usage: + nyathing [--animation FILE | -a FILE] COMMAND [ARGUMENT ...] + nyathing uninstall + nyathing list + nyathing --help + nyathing --version + + Commands: + COMMAND [ARGUMENT ...] Run a command while showing an activity animation. + uninstall Remove the installed app and CLI command. + list List available valid animations. + + Options: + -a, --animation FILE Select an animation from the user animations folder. + --help Show this help. + --version Show the app version. + + Examples: + nyathing sleep 5 + nyathing --animation nyan_54x36.png make test + """ } static func parse(_ arguments: [String]) throws -> CLIArguments { @@ -221,14 +222,17 @@ enum NyathingCLI { private static func resolveNamedAnimation(_ name: String, in directory: URL) throws -> String { let stem = name.replacingOccurrences( of: #"_(?:36x36|54x36)\.png$"#, with: "", options: [.caseInsensitive, .regularExpression]) - guard let files = try? FileManager.default.contentsOfDirectory( - at: directory, includingPropertiesForKeys: nil) + guard + let files = try? FileManager.default.contentsOfDirectory( + at: directory, includingPropertiesForKeys: nil) else { throw CLIError.animationUnavailable(name) } for size in ["54x36", "36x36"] { let expected = "\(stem)_\(size).png" - guard let file = files.first(where: { - $0.lastPathComponent.caseInsensitiveCompare(expected) == .orderedSame - }), let animation = try? SpriteAnimation.load(from: file) else { continue } + guard + let file = files.first(where: { + $0.lastPathComponent.caseInsensitiveCompare(expected) == .orderedSame + }), let animation = try? SpriteAnimation.load(from: file) + else { continue } return animation.filename } throw CLIError.animationUnavailable(name) diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 780bca5..9484f04 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -156,7 +156,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { window.contentView = scrollView NSLayoutConstraint.activate([ stack.leadingAnchor.constraint(equalTo: scrollView.contentView.leadingAnchor, constant: 12), - stack.trailingAnchor.constraint(equalTo: scrollView.contentView.trailingAnchor, constant: -12), + stack.trailingAnchor.constraint( + equalTo: scrollView.contentView.trailingAnchor, constant: -12), stack.topAnchor.constraint(equalTo: scrollView.contentView.topAnchor, constant: 12), stack.widthAnchor.constraint(equalTo: scrollView.contentView.widthAnchor, constant: -24), stack.heightAnchor.constraint( @@ -182,7 +183,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private func refreshErrorsWindow() { guard let stack = errorsStackView else { return } - stack.arrangedSubviews.forEach { stack.removeArrangedSubview($0); $0.removeFromSuperview() } + for subview in Array(stack.arrangedSubviews) { + stack.removeArrangedSubview(subview) + subview.removeFromSuperview() + } if lifecycle.timedOutActivities.isEmpty { let emptyLabel = NSTextField(labelWithString: "No errors") emptyLabel.lineBreakMode = .byWordWrapping diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 26dd973..cc83b9c 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -279,7 +279,8 @@ final class ActivityLifecycleTests: XCTestCase { XCTAssertEqual( lifecycle.expire(distinct, deadline: 30), ActivityLifecycle.ExpiredActivity( - id: distinct, animation: "other_36x36.png", description: ActivityLifecycle.missingDescription)) + id: distinct, animation: "other_36x36.png", + description: ActivityLifecycle.missingDescription)) XCTAssertEqual(lifecycle.disconnectedCount, 2) XCTAssertEqual(lifecycle.timedOutActivities.count, 2) } @@ -302,7 +303,8 @@ final class ActivityLifecycleTests: XCTestCase { id: undescribed, animation: "nyathing_36x36.png", description: ActivityLifecycle.missingDescription)) XCTAssertEqual( - lifecycle.timedOutActivities.map(\.description), [ + lifecycle.timedOutActivities.map(\.description), + [ "build test", ActivityLifecycle.missingDescription, ]) } From 592581fbbb730954a4b7999df4b456a0278d6e70 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 19:51:27 +0400 Subject: [PATCH 07/43] Add per-activity keepalive and timeout settings to API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow start requests to override the configured keepalive interval and activity timeout, falling back to config defaults when omitted. Track each activity’s timeout independently and document the optional API fields. Update the CLI to pass its configured values. --- README.md | 5 +++- Sources/Nyathing/CLI.swift | 2 ++ Sources/Nyathing/LocalAPIServer.swift | 26 ++++++++++++++++--- Sources/Nyathing/main.swift | 24 +++++++++++++---- .../ConfigurationAndAPITests.swift | 2 +- 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5957e60..b1dd8ac 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,10 @@ connect at the same time. Request lines are limited to 1 MiB. Commands: - Start an activity: `{"command":"start","animation":"nyan_54x36.png"}` - returns `{"ok":true,"activity_id":"…"}`. The animation is identified by + returns `{"ok":true,"activity_id":"…"}`. Optional + `keepalive_interval_seconds` and `activity_timeout_seconds` fields override + the corresponding `config.toml` defaults for this activity; both must be + positive numbers. The animation is identified by its filename. The `animation` field is optional; when omitted, Nyathing uses the animation selected by `default_animation` in `config.toml`. If a requested animation is unavailable or invalid, Nyathing uses the built-in diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index fa0f2fc..210e7f0 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -145,6 +145,8 @@ enum NyathingCLI { "command": "start", "animation": animation, "description": activityDescription(command: cli.command, arguments: cli.arguments), + "keepalive_interval_seconds": String(configuration.keepaliveInterval), + "activity_timeout_seconds": String(configuration.activityTimeout), ]) guard let activityID = activity["activity_id"] as? String else { throw CLIError.api("The server returned an invalid activity response.") diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index 6131429..c93ea67 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -4,7 +4,9 @@ import Foundation /// Serves the local JSON Lines API over a current-user Unix domain socket. final class LocalAPIServer { private let defaultAnimation: String - private let onStart: (String, String?) throws -> String + private let defaultKeepaliveInterval: TimeInterval + private let defaultActivityTimeout: TimeInterval + private let onStart: (String, String?, TimeInterval, TimeInterval) throws -> String private let onKeepalive: (String) throws -> Void private let onStop: (String) throws -> Void private let socketPath: String @@ -16,11 +18,15 @@ final class LocalAPIServer { init( socketPath: String = LocalAPIServer.socketPath, defaultAnimation: String = "nyathing_36x36.png", - onStart: @escaping (String, String?) throws -> String, + defaultKeepaliveInterval: TimeInterval = 5, + defaultActivityTimeout: TimeInterval = 5, + onStart: @escaping (String, String?, TimeInterval, TimeInterval) throws -> String, onKeepalive: @escaping (String) throws -> Void, onStop: @escaping (String) throws -> Void ) { self.defaultAnimation = defaultAnimation + self.defaultKeepaliveInterval = defaultKeepaliveInterval + self.defaultActivityTimeout = defaultActivityTimeout self.onStart = onStart self.onKeepalive = onKeepalive self.onStop = onStop @@ -216,9 +222,14 @@ final class LocalAPIServer { case "start": let animation = request["animation"] as? String ?? defaultAnimation guard !animation.isEmpty else { throw LocalAPIError.invalidRequest } + let keepaliveInterval = try seconds( + request["keepalive_interval_seconds"], default: defaultKeepaliveInterval) + let activityTimeout = try seconds( + request["activity_timeout_seconds"], default: defaultActivityTimeout) return [ "ok": true, - "activity_id": try onStart(animation, request["description"] as? String), + "activity_id": try onStart( + animation, request["description"] as? String, keepaliveInterval, activityTimeout), ] case "keepalive": guard let activityID = request["activity_id"] as? String, !activityID.isEmpty else { @@ -259,6 +270,15 @@ final class LocalAPIServer { } } + private func seconds(_ value: Any?, default fallback: TimeInterval) throws -> TimeInterval { + guard let value else { return fallback } + guard let number = value as? NSNumber, number.doubleValue.isFinite, number.doubleValue > 0 + else { + throw LocalAPIError.invalidRequest + } + return number.doubleValue + } + private var isRunning: Bool { lock.lock() defer { lock.unlock() } diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 9484f04..05e78ba 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -45,6 +45,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private var activeAnimations: [String: ActiveAnimation] = [:] private var lifecycle = ActivityLifecycle() private var activityTimeout: TimeInterval = 5 + private var keepaliveInterval: TimeInterval = 5 + private var activityTimeouts: [UUID: TimeInterval] = [:] private var defaultAnimation = "nyathing_36x36.png" private var apiServer: LocalAPIServer? private var apiGeneration = 0 @@ -252,6 +254,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { NyathingLog.report(error, context: "Unable to configure login launch") } activityTimeout = configuration.activityTimeout + keepaliveInterval = configuration.keepaliveInterval defaultAnimation = configuration.defaultAnimation try startAPIServer() } catch { @@ -274,10 +277,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let generation = apiGeneration apiServer = LocalAPIServer( defaultAnimation: defaultAnimation, - onStart: { [weak self] filename, description in + defaultKeepaliveInterval: keepaliveInterval, + defaultActivityTimeout: activityTimeout, + onStart: { [weak self] filename, description, _, timeout in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } - return self.startActivity(animation: filename, description: description).uuidString + return self.startActivity( + animation: filename, description: description, activityTimeout: timeout + ).uuidString } }, onKeepalive: { [weak self] activityID in @@ -316,11 +323,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate { /// Begins an activity for a named animation, sharing its status item with matching activities. @discardableResult - func startActivity(animation filename: String, description: String? = nil) -> UUID { - let deadline = DispatchTime.now() + activityTimeout + func startActivity( + animation filename: String, description: String? = nil, + activityTimeout timeout: TimeInterval? = nil + ) -> UUID { + let timeout = timeout ?? activityTimeout + let deadline = DispatchTime.now() + timeout let deadlineUptime = deadline.uptimeNanoseconds let id = lifecycle.start( animation: filename, description: description, deadline: deadlineUptime) + activityTimeouts[id] = timeout scheduleActivityExpiration(id, deadlineUptime: deadlineUptime) if let active = activeAnimations[filename] { active.activityIDs.insert(id) @@ -351,6 +363,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { /// Ends an activity without counting it as a disconnect. func stopActivity(_ id: UUID) { guard let filename = lifecycle.stop(id) else { return } + activityTimeouts.removeValue(forKey: id) removeActivityFromStatusItem(id, animation: filename) } @@ -417,7 +430,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } private func keepaliveActivity(_ id: UUID) -> Bool { - let deadline = DispatchTime.now() + activityTimeout + let deadline = DispatchTime.now() + (activityTimeouts[id] ?? activityTimeout) let deadlineUptime = deadline.uptimeNanoseconds guard lifecycle.keepalive(id, deadline: deadlineUptime) else { return false } scheduleActivityExpiration(id, deadlineUptime: deadlineUptime) @@ -447,6 +460,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { return } guard let expired = lifecycle.expire(id, deadline: deadlineUptime) else { return } + activityTimeouts.removeValue(forKey: id) removeActivityFromStatusItem(id, animation: expired.animation) presentActivityTimeout() } diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index cc83b9c..21ea234 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -368,7 +368,7 @@ final class LocalAPIServerTests: XCTestCase { let server = LocalAPIServer( socketPath: socketPath, defaultAnimation: "nyan_54x36.png", - onStart: { animation, description in + onStart: { animation, description, _, _ in lock.lock() defer { lock.unlock() } startedAnimations.append(animation) From 722fcbb22ea73fae7d9332a74c7192f88d3ca0c2 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 19:58:10 +0400 Subject: [PATCH 08/43] Show animations in the main menu bar status item Display active animation frames in place of the default app icon, then restore the icon when no activities remain. Move the version to its own section in the CLI help output. --- Sources/Nyathing/CLI.swift | 5 ++++- Sources/Nyathing/main.swift | 12 ++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 210e7f0..e13ff44 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -43,7 +43,10 @@ struct CLIArguments { Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "Development build" return """ - Nyathing \(version) displays playful animations in the macOS menu bar while commands run. + Nyathing displays playful animations in the macOS menu bar while commands run. + + Version: + \(version) Usage: nyathing [--animation FILE | -a FILE] COMMAND [ARGUMENT ...] diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 05e78ba..d340161 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -76,9 +76,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { animationTimer?.invalidate() apiGeneration += 1 apiServer?.stop() - for active in activeAnimations.values { - NSStatusBar.system.removeStatusItem(active.statusItem) - } } private func configureMenu(for item: NSStatusItem) { @@ -311,9 +308,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } private func clearRuntimeState() { - for active in activeAnimations.values { - NSStatusBar.system.removeStatusItem(active.statusItem) - } activeAnimations.removeAll() lifecycle.reset() updateMainStatusItemVisibility() @@ -350,7 +344,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { case .asset(let animation): frames = animation.frames case .builtInGhost: frames = Self.builtInGhostFrames() } - let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) + guard let statusItem = mainStatusItem else { return id } let active = ActiveAnimation( filename: filename, statusItem: statusItem, frames: frames, activityIDs: [id]) activeAnimations[filename] = active @@ -371,9 +365,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate { guard let active = activeAnimations[filename] else { return } active.activityIDs.remove(id) if active.activityIDs.isEmpty { - NSStatusBar.system.removeStatusItem(active.statusItem) activeAnimations.removeValue(forKey: filename) updateMainStatusItemVisibility() + updateMainStatusItem() } else { updateActivityStatus(active) } @@ -485,6 +479,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { systemSymbolName: "exclamationmark.triangle.fill", accessibilityDescription: "Outstanding timeout errors") button.title = "\(outstandingErrorCount)" + } else if let active = activeAnimations.values.first { + updateActivityStatus(active) } else { button.image = staticAppIcon From 5055e419bb1b3696f62dc96caa477111a1e118d4 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 20:07:52 +0400 Subject: [PATCH 09/43] Add CLI commands to manage the background server Use a LaunchAgent to start, stop, and check the server from the terminal. Keep the server launch argument internal, update CLI help, and document the new commands in the README. --- README.md | 7 +++- Sources/Nyathing/CLI.swift | 23 +++++++++- Sources/Nyathing/Diagnostics.swift | 67 +++++++++++++++++++++++++++--- Sources/Nyathing/main.swift | 2 +- 4 files changed, 90 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b1dd8ac..87c2a08 100644 --- a/README.md +++ b/README.md @@ -216,13 +216,16 @@ repository root. ### Run the server -Build and launch the menu-bar server: +Build and launch the menu-bar server in the background: ```sh swift build -swift run nyathing --server +swift run nyathing server start +swift run nyathing server status +swift run nyathing server stop ``` + ### Run the CLI The CLI runs a command while displaying an activity animation. For example: diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index e13ff44..d36ecd4 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -51,6 +51,7 @@ struct CLIArguments { Usage: nyathing [--animation FILE | -a FILE] COMMAND [ARGUMENT ...] nyathing uninstall + nyathing server start|stop|status nyathing list nyathing --help nyathing --version @@ -58,6 +59,7 @@ struct CLIArguments { Commands: COMMAND [ARGUMENT ...] Run a command while showing an activity animation. uninstall Remove the installed app and CLI command. + server Manage the background server (start, stop, status). list List available valid animations. Options: @@ -119,6 +121,25 @@ enum NyathingCLI { return 0 } do { + if arguments.count == 2, arguments[0] == "server" { + let configurationDirectory = AppConfiguration.configurationDirectory + switch arguments[1] { + case "start": + try LaunchAgentSupport.startServer(in: configurationDirectory) + print("Nyathing server started in the background.") + return 0 + case "stop": + try LaunchAgentSupport.stopServer(in: configurationDirectory) + print("Nyathing server stopped.") + return 0 + case "status": + let running = LaunchAgentSupport.serverIsRunning() + print(running ? "Nyathing server is running." : "Nyathing server is not running.") + return running ? 0 : 1 + default: + throw CLIError.usage + } + } if arguments == ["list"] { _ = try AppConfiguration.load() let directory = AppConfiguration.configurationDirectory @@ -293,7 +314,7 @@ private final class LocalAPIClient { if let connected = try? connect() { return connected } let process = Process() process.executableURL = URL(fileURLWithPath: CommandLine.arguments[0]).standardizedFileURL - process.arguments = ["--server"] + process.arguments = [LaunchAgentSupport.serverArgument] process.standardInput = FileHandle.nullDevice process.standardOutput = FileHandle.nullDevice process.standardError = FileHandle.nullDevice diff --git a/Sources/Nyathing/Diagnostics.swift b/Sources/Nyathing/Diagnostics.swift index 586aa65..0db2c62 100644 --- a/Sources/Nyathing/Diagnostics.swift +++ b/Sources/Nyathing/Diagnostics.swift @@ -75,12 +75,63 @@ enum NyathingLog { enum LaunchAgentSupport { static let label = "com.nyathing.Nyathing" + static let serverArgument = "--nyathing-server" + + private static var agentURL: URL { + FileManager.default.homeDirectoryForCurrentUser + .appendingPathComponent("Library/LaunchAgents", isDirectory: true) + .appendingPathComponent("\(label).plist") + } + + private static var serviceTarget: String { + "gui/\(getuid())/\(label)" + } + + static func startServer(in configurationDirectory: URL) throws { + try configure(enabled: true, in: configurationDirectory) + if launchctl(["print", serviceTarget]).status == 0 { return } + try runLaunchctl(["bootstrap", "gui/\(getuid())", agentURL.path]) + } + + static func stopServer(in configurationDirectory: URL) throws { + if launchctl(["print", serviceTarget]).status == 0 { + try runLaunchctl(["bootout", serviceTarget]) + } + try? FileManager.default.removeItem(at: agentURL) + } + + static func serverIsRunning() -> Bool { + launchctl(["print", serviceTarget]).status == 0 + } + + private static func runLaunchctl(_ arguments: [String]) throws { + let result = launchctl(arguments) + guard result.status == 0 else { + let detail = result.output.trimmingCharacters(in: .whitespacesAndNewlines) + throw LaunchAgentError.launchctl(detail.isEmpty ? "launchctl failed." : detail) + } + } + + private static func launchctl(_ arguments: [String]) -> (status: Int32, output: String) { + let process = Process() + process.executableURL = URL(fileURLWithPath: "/bin/launchctl") + process.arguments = arguments + let pipe = Pipe() + process.standardOutput = pipe + process.standardError = pipe + do { + try process.run() + let output = pipe.fileHandleForReading.readDataToEndOfFile() + process.waitUntilExit() + return (process.terminationStatus, String(data: output, encoding: .utf8) ?? "") + } catch { + return (1, error.localizedDescription) + } + } /// Installs or removes the user's login agent according to the auto-start setting. static func configure(enabled: Bool, in configurationDirectory: URL) throws { - let launchAgentsDirectory = FileManager.default.homeDirectoryForCurrentUser - .appendingPathComponent("Library/LaunchAgents", isDirectory: true) - let agentURL = launchAgentsDirectory.appendingPathComponent("\(label).plist") + let launchAgentsDirectory = agentURL.deletingLastPathComponent() let legacyURL = configurationDirectory.appendingPathComponent("\(label).plist") if enabled { @@ -89,7 +140,7 @@ enum LaunchAgentSupport { } let plist: [String: Any] = [ "Label": label, - "ProgramArguments": [executable], + "ProgramArguments": [executable, serverArgument], "RunAtLoad": true, ] let data = try PropertyListSerialization.data( @@ -110,7 +161,13 @@ enum LaunchAgentSupport { enum LaunchAgentError: LocalizedError { case executableUnavailable + case launchctl(String) var errorDescription: String? { - "Unable to determine Nyathing's executable path for the LaunchAgent plist." + switch self { + case .executableUnavailable: + return "Unable to determine Nyathing's executable path for the LaunchAgent plist." + case .launchctl(let message): + return "Unable to manage the Nyathing server: \(message)" + } } } diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index d340161..b87c3e2 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -2,7 +2,7 @@ import AppKit import Foundation let arguments = Array(CommandLine.arguments.dropFirst()) -if arguments == ["--server"] { +if arguments == [LaunchAgentSupport.serverArgument] { runNyathingApplication(serverMode: true) exit(EXIT_SUCCESS) } From d49ea4feae84cbbdbf95a86398d3118a44eb44eb Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 20:12:27 +0400 Subject: [PATCH 10/43] Improve the timeout errors list Separate error rows with dividers and add indentation before each description. Close the errors window after the last warning is acknowledged. --- Sources/Nyathing/main.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index b87c3e2..5da3d56 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -178,6 +178,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate { updateMainStatusItemVisibility() updateMainStatusItem() refreshErrorsWindow() + if lifecycle.timedOutActivities.isEmpty { + errorsWindow?.close() + errorsWindow = nil + errorsStackView = nil + } } private func refreshErrorsWindow() { @@ -192,17 +197,27 @@ final class AppDelegate: NSObject, NSApplicationDelegate { stack.addArrangedSubview(emptyLabel) return } - for error in lifecycle.timedOutActivities { + for (index, error) in lifecycle.timedOutActivities.enumerated() { + if index > 0 { + let separator = NSBox() + separator.boxType = .separator + stack.addArrangedSubview(separator) + separator.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true + } let row = NSStackView() row.orientation = .horizontal row.alignment = .centerY row.spacing = 12 row.distribution = .fill + let leadingInset = NSView() + leadingInset.setContentHuggingPriority(.required, for: .horizontal) + leadingInset.widthAnchor.constraint(equalToConstant: 8).isActive = true let descriptionLabel = NSTextField(wrappingLabelWithString: error.description) descriptionLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) let acknowledgeButton = NSButton( title: "Acknowledge", target: self, action: #selector(acknowledgeError(_:))) acknowledgeButton.identifier = NSUserInterfaceItemIdentifier(error.id.uuidString) + row.addArrangedSubview(leadingInset) row.addArrangedSubview(descriptionLabel) row.addArrangedSubview(acknowledgeButton) stack.addArrangedSubview(row) From 3e639572fbd1337c9f777389a3a78789e55c57bc Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 21:05:25 +0400 Subject: [PATCH 11/43] Show concurrent animations side by side Give each distinct animation its own menu bar item and hide the static icon while animations are active. Resolve random animation requests through the API, and send timing settings as JSON numbers so CLI activities are accepted by the server. Start the test animation runner in server mode. --- Scripts/run-test-animation.py | 2 +- Sources/Nyathing/CLI.swift | 6 +++--- Sources/Nyathing/main.swift | 28 ++++++++++++++++------------ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Scripts/run-test-animation.py b/Scripts/run-test-animation.py index 19a111f..0cc2ae0 100644 --- a/Scripts/run-test-animation.py +++ b/Scripts/run-test-animation.py @@ -58,7 +58,7 @@ def configured_seconds(text, key, default): activity_ids = [] try: if not api_is_ready(): - app = subprocess.Popen([".build/debug/nyathing"]) + app = subprocess.Popen([".build/debug/nyathing", "--nyathing-server"]) started_here = True startup_deadline = time.monotonic() + 30 while not api_is_ready(): diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index d36ecd4..c84fe80 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -169,8 +169,8 @@ enum NyathingCLI { "command": "start", "animation": animation, "description": activityDescription(command: cli.command, arguments: cli.arguments), - "keepalive_interval_seconds": String(configuration.keepaliveInterval), - "activity_timeout_seconds": String(configuration.activityTimeout), + "keepalive_interval_seconds": NSNumber(value: configuration.keepaliveInterval), + "activity_timeout_seconds": NSNumber(value: configuration.activityTimeout), ]) guard let activityID = activity["activity_id"] as? String else { throw CLIError.api("The server returned an invalid activity response.") @@ -355,7 +355,7 @@ private final class LocalAPIClient { return LocalAPIClient(descriptor: fd) } - func command(_ request: [String: String]) throws -> [String: Any] { + func command(_ request: [String: Any]) throws -> [String: Any] { lock.lock() defer { lock.unlock() } var data = try JSONSerialization.data(withJSONObject: request) diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 5da3d56..1ec499f 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -336,14 +336,20 @@ final class AppDelegate: NSObject, NSApplicationDelegate { animation filename: String, description: String? = nil, activityTimeout timeout: TimeInterval? = nil ) -> UUID { + let directory = AppConfiguration.configurationDirectory.appendingPathComponent( + "animations", isDirectory: true) + let animations = SpriteAnimation.loadAll(in: directory) + let resolvedFilename = filename == "random" + ? (try? NyathingCLI.resolveAnimation(filename, in: directory)) ?? filename + : filename let timeout = timeout ?? activityTimeout let deadline = DispatchTime.now() + timeout let deadlineUptime = deadline.uptimeNanoseconds let id = lifecycle.start( - animation: filename, description: description, deadline: deadlineUptime) + animation: resolvedFilename, description: description, deadline: deadlineUptime) activityTimeouts[id] = timeout scheduleActivityExpiration(id, deadlineUptime: deadlineUptime) - if let active = activeAnimations[filename] { + if let active = activeAnimations[resolvedFilename] { active.activityIDs.insert(id) updateActivityStatus(active) updateMainStatusItemVisibility() @@ -351,18 +357,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate { return id } - let directory = AppConfiguration.configurationDirectory.appendingPathComponent( - "animations", isDirectory: true) - let animations = SpriteAnimation.loadAll(in: directory) let frames: [NSImage] - switch AnimationResolution.resolve(filename, available: animations) { + switch AnimationResolution.resolve(resolvedFilename, available: animations) { case .asset(let animation): frames = animation.frames case .builtInGhost: frames = Self.builtInGhostFrames() } - guard let statusItem = mainStatusItem else { return id } + let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) + configureMenu(for: statusItem) let active = ActiveAnimation( - filename: filename, statusItem: statusItem, frames: frames, activityIDs: [id]) - activeAnimations[filename] = active + filename: resolvedFilename, statusItem: statusItem, frames: frames, activityIDs: [id]) + activeAnimations[resolvedFilename] = active updateActivityStatus(active) updateMainStatusItemVisibility() updateMainStatusItem() @@ -381,6 +385,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { active.activityIDs.remove(id) if active.activityIDs.isEmpty { activeAnimations.removeValue(forKey: filename) + NSStatusBar.system.removeStatusItem(active.statusItem) updateMainStatusItemVisibility() updateMainStatusItem() } else { @@ -476,6 +481,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private func advanceAnimations() { for active in activeAnimations.values { + guard !active.frames.isEmpty else { continue } active.frameIndex = (active.frameIndex + 1) % active.frames.count updateActivityStatus(active) } @@ -483,7 +489,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } private func updateMainStatusItemVisibility() { - mainStatusItem?.isVisible = true + mainStatusItem?.isVisible = activeAnimations.isEmpty || !lifecycle.timedOutActivities.isEmpty } private func updateMainStatusItem() { @@ -494,8 +500,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { systemSymbolName: "exclamationmark.triangle.fill", accessibilityDescription: "Outstanding timeout errors") button.title = "\(outstandingErrorCount)" - } else if let active = activeAnimations.values.first { - updateActivityStatus(active) } else { button.image = staticAppIcon From 3907b9b36b448fd54349f9bd928b187955cb4493 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 23:42:51 +0400 Subject: [PATCH 12/43] Document random animation selection Explain the --animation random option, including the precedence of animations named random_36x36.png and random_54x36.png, fallback selection, and the built-in ghost behavior when no valid animations are available. --- README.md | 18 ++++++++++++++++-- .../Nyathing/Resources/explosion_36x36.png | Bin 23605 -> 0 bytes 2 files changed, 16 insertions(+), 2 deletions(-) delete mode 100644 Sources/Nyathing/Resources/explosion_36x36.png diff --git a/README.md b/README.md index 87c2a08..f50d024 100644 --- a/README.md +++ b/README.md @@ -102,8 +102,22 @@ directory. You can use the short name before the frame-size suffix and `.png` (for example, `nyan` instead of `nyan_54x36.png`). If both `nyan_36x36.png` and `nyan_54x36.png` exist, Nyathing chooses the larger `54x36` animation. Without `--animation`, the CLI uses `nyathing_36x36.png`, regardless of the -configured server default. Quote paths containing spaces as usual in your shell. -Relative command paths are resolved from the current working directory. +configured server default. + +Set `--animation` to `random` to choose a random valid animation from the user +animations directory for that run. + +If a valid `random_36x36.png` or `random_54x36.png` exists, Nyathing plays that +named animation, preferring `54x36` when both are available. Otherwise, it +chooses randomly from the valid user animations. If none are available, Nyathing +uses its built-in ghost animation: + +```sh + nyathing --animation random sleep 5 +``` + +Quote paths containing spaces as usual in your shell. Relative command paths +are resolved from the current working directory. List valid installed animations with: diff --git a/Sources/Nyathing/Resources/explosion_36x36.png b/Sources/Nyathing/Resources/explosion_36x36.png deleted file mode 100644 index 88aa1b507b35fa80fb68c07e079b4c53b38c7d47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23605 zcma%hgKsWQu=ZQq)~RjVwr%&+c2D2hwr$(CZMUaBwS9kIzWWEC@f$|LT75a9n`jled?jUv8Qe@9o&-Y((gpZ8@+-!z&X*9_NzF3FJmM8O;1O{LsPKGLUdV)E(l>JIJ;-+4PHA zveKzq80SA5zsrn1J>XvVrUw*6Gl1|0AA;UNbNGMj77Df>JSUBu_>qYCRYQwJ|hs$ivWw~oE39)z8bie7(>Ip~L@9A_v2nb!w7LM}m>YpBN&IvZgH4$T+SpD`&nh} zh7S=mNEmer+)5mZ7_*cR9 z<-IVmZz!VbT%8MQZ}$YYpdDl@##m0d1y{yBi*Y9yOMWf zex6PY(DD8Hb3%r>T_XRzdWKL)CRDK1RWSM*$bs+(2HL+VS+Ezhc0@SQyP2N!e_ja* z$1K0?pQ>&q95Tl*|DGPW3Sfa?Vr6&;e8TW`cA-^avK_8II6z1^GwMIKIi3V81js@< zK1lZ?(8dk6`->xP?oVj!FS`p}EbNW=C*}SZXGi9v`1x%E3EfUMTFAEzAD!=FM8O?* z9kmBGFM)<{rJq;2;Im!YLDqP}^XVU_xkI~`2xVNgP#nhi(fLHSL**(W)I}76dT&M% z;y6mxwFO^EDvga}HtfzP;+dvtQ~}O7PCs;}*8~OPR{}3k$7+9_A;z!v_dEb_C-N2S zpgZuq>%2Wq_L=s2;H8Xx=dM%FRdb=M1aQ&w?U@)5I%iMy-Nd99cG>q^V4@eSh?||G zEeMJ>&fc;}+4R4h-55fR;fB}_wT!3ANU zg<+xQ2XCrTInhr5Z$ng9Ep2!b(1+P6JaHmb1TzfkYIsRlPWO|^J~i?{{uMa+#N$xm z-_P40WD+%YN+YOC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avx4rbG35h&0B5M|^JfrnC62QIy{9JCfWuzufI2 z+;!F}ru?Pm!h@ft$K~Aa3hvp5MmYVEGSR0O1!mlFLPl_kBP1;#mpxuYD##|#q&Djb z!$O)|?AKj4aP;ay?T`o@#Abm@@f zJCJ*Gp|Fhz*Zx;Q8g5QX5ks{LH%>uU8Zl9^xBu6|W(3I^ zfNU&5w!+q)w*Llzhl_`wotvATTTq9KSD2Syn3tE0i%Xb`i;wB+%KrhlxY;<``TxHG snZS2;|A2S@y8-0rV(SI6baDT`Fns^Lq=gIt`yT^PlvR_d{b&*P9|~@aVgLXD From 3781f15c5abf6fb68f3b3407553fee6a8777d285 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Thu, 19 Nov 2026 23:59:06 +0400 Subject: [PATCH 13/43] Add Bash and Zsh shell completion Add nyathing completion zsh|bash to generate shell-specific completion scripts for CLI commands, server actions, and live animation names. Document shell setup in the README and test completions against the documented commands. --- README.md | 25 +++++- Sources/Nyathing/CLI.swift | 84 +++++++++++++++++++ Sources/Nyathing/main.swift | 3 +- .../ConfigurationAndAPITests.swift | 37 ++++++++ 4 files changed, 147 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f50d024..50d5282 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Without `--animation`, the CLI uses `nyathing_36x36.png`, regardless of the configured server default. Set `--animation` to `random` to choose a random valid animation from the user -animations directory for that run. +animations directory for that run. If a valid `random_36x36.png` or `random_54x36.png` exists, Nyathing plays that named animation, preferring `54x36` when both are available. Otherwise, it @@ -132,6 +132,29 @@ To view available options or check the installed version: nyathing --version ``` +## Shell completion + +Nyathing can generate completion scripts for Zsh and Bash. Add the appropriate +command to your shell configuration file to enable completion in new shells. + +For Zsh, add this to `~/.zshrc`: + +```sh + autoload -Uz compinit + compinit + eval "$(nyathing completion zsh)" +``` + +For Bash, add this to `~/.bashrc`: + +```sh + eval "$(nyathing completion bash)" +``` + +The completion script offers Nyathing commands and options, including server +subcommands. It fetches available animations with `nyathing list` when +completing an animation argument, so the suggestions reflect installed files. + ## Animation file format Animation files are single horizontal PNG sprite sheets. Supported frame sizes diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index c84fe80..aa734e3 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -53,6 +53,7 @@ struct CLIArguments { nyathing uninstall nyathing server start|stop|status nyathing list + nyathing completion zsh|bash nyathing --help nyathing --version @@ -61,6 +62,7 @@ struct CLIArguments { uninstall Remove the installed app and CLI command. server Manage the background server (start, stop, status). list List available valid animations. + completion SHELL Print shell completion code for zsh or bash. Options: -a, --animation FILE Select an animation from the user animations folder. @@ -110,6 +112,14 @@ enum NyathingCLI { if arguments == ["uninstall"] { return NyathingUninstaller.run() } + if arguments.count == 2, arguments[0] == "completion" { + guard let script = ShellCompletion.script(for: arguments[1]) else { + FileHandle.standardError.write(Data("Supported shells: zsh, bash\\n".utf8)) + return 1 + } + print(script, terminator: "") + return 0 + } if arguments.isEmpty || arguments == ["--help"] { print(CLIArguments.usage) return 0 @@ -303,6 +313,80 @@ enum NyathingCLI { } } +enum ShellCompletion { + static let supportedCommands = ["server", "list", "uninstall", "completion"] + + static func script(for shell: String) -> String? { + let commands = supportedCommands.joined(separator: " ") + switch shell { + case "zsh": + return #""" + #compdef nyathing + + _nyathing() { + local -a commands animations + commands=(\#(commands)) + + case "${words[CURRENT-1]}" in + -a|--animation) + animations=(random ${(f)"$(nyathing list 2>/dev/null)"}) + compadd -- "${animations[@]}" + return + ;; + server) + compadd -- start stop status + return + ;; + completion) + compadd -- zsh bash + return + ;; + esac + + if (( CURRENT == 2 )); then + compadd -- "${commands[@]}" --animation -a --help --version + fi + } + + compdef _nyathing nyathing + """# + case "bash": + return #""" + _nyathing() { + local cur prev animations + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + case "$prev" in + -a|--animation) + animations="$(nyathing list 2>/dev/null)" + COMPREPLY=( $(compgen -W "random $animations" -- "$cur") ) + return + ;; + server) + COMPREPLY=( $(compgen -W "start stop status" -- "$cur") ) + return + ;; + completion) + COMPREPLY=( $(compgen -W "zsh bash" -- "$cur") ) + return + ;; + esac + + if (( COMP_CWORD == 1 )); then + COMPREPLY=( $(compgen -W "\#(commands)" -- "$cur") ) + COMPREPLY+=( $(compgen -W "--animation -a --help --version" -- "$cur") ) + fi + } + complete -F _nyathing nyathing + """# + default: + return nil + } + } +} + private final class LocalAPIClient { private let descriptor: Int32 private let lock = NSLock() diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 1ec499f..b1f74b4 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -339,7 +339,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let directory = AppConfiguration.configurationDirectory.appendingPathComponent( "animations", isDirectory: true) let animations = SpriteAnimation.loadAll(in: directory) - let resolvedFilename = filename == "random" + let resolvedFilename = + filename == "random" ? (try? NyathingCLI.resolveAnimation(filename, in: directory)) ?? filename : filename let timeout = timeout ?? activityTimeout diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 21ea234..9cf999b 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -115,6 +115,43 @@ final class CLITests: XCTestCase { XCTAssertEqual(NyathingCLI.keepaliveInterval(for: shorterConfiguredInterval), 0.2) } + func testZshCompletionTracksCLICommandsAndDynamicAnimations() throws { + let script = try XCTUnwrap(ShellCompletion.script(for: "zsh")) + + for command in documentedCLICommands { + XCTAssertTrue(script.contains(command)) + } + XCTAssertTrue(script.contains("nyathing list")) + XCTAssertTrue(script.contains("start stop status")) + XCTAssertTrue(script.contains("compadd -- zsh bash")) + } + + func testBashCompletionTracksCLICommandsAndDynamicAnimations() throws { + let script = try XCTUnwrap(ShellCompletion.script(for: "bash")) + + for command in documentedCLICommands { + XCTAssertTrue(script.contains(command)) + } + XCTAssertTrue(script.contains("nyathing list")) + XCTAssertTrue(script.contains("start stop status")) + XCTAssertTrue(script.contains("zsh bash")) + } + + func testCompletionRejectsUnsupportedShells() { + XCTAssertNil(ShellCompletion.script(for: "fish")) + } + + private var documentedCLICommands: [String] { + let commandsSection = + CLIArguments.usage + .components(separatedBy: "Commands:\n").last? + .components(separatedBy: "\n\nOptions:").first ?? "" + return commandsSection.split(separator: "\n").compactMap { line in + let command = line.split(whereSeparator: \.isWhitespace).first.map(String.init) + return command == "COMMAND" ? nil : command + } + } + func testHelpAndVersionAreOnlyAvailableAsOptions() throws { XCTAssertEqual(try CLIArguments.parse(["help"]).command, "help") XCTAssertEqual(try CLIArguments.parse(["version"]).command, "version") From 5f6e6635bcebad9f47201976ff0950671a93e3c8 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 00:06:43 +0400 Subject: [PATCH 14/43] Fix server status and restart Check the LaunchAgent process rather than registration when reporting server status. Kickstart a registered but stopped job so server start can recover it. Remove the test assertion for the deleted explosion animation, and correct the newline in the shell completion error message. --- Sources/Nyathing/CLI.swift | 2 +- Sources/Nyathing/Diagnostics.swift | 13 +++++++++++-- Tests/NyathingTests/ConfigurationAndAPITests.swift | 5 ----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index aa734e3..e579193 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -114,7 +114,7 @@ enum NyathingCLI { } if arguments.count == 2, arguments[0] == "completion" { guard let script = ShellCompletion.script(for: arguments[1]) else { - FileHandle.standardError.write(Data("Supported shells: zsh, bash\\n".utf8)) + FileHandle.standardError.write(Data("Supported shells: zsh, bash\n".utf8)) return 1 } print(script, terminator: "") diff --git a/Sources/Nyathing/Diagnostics.swift b/Sources/Nyathing/Diagnostics.swift index 0db2c62..020c7b5 100644 --- a/Sources/Nyathing/Diagnostics.swift +++ b/Sources/Nyathing/Diagnostics.swift @@ -89,7 +89,10 @@ enum LaunchAgentSupport { static func startServer(in configurationDirectory: URL) throws { try configure(enabled: true, in: configurationDirectory) - if launchctl(["print", serviceTarget]).status == 0 { return } + if launchctl(["print", serviceTarget]).status == 0 { + try runLaunchctl(["kickstart", serviceTarget]) + return + } try runLaunchctl(["bootstrap", "gui/\(getuid())", agentURL.path]) } @@ -101,7 +104,13 @@ enum LaunchAgentSupport { } static func serverIsRunning() -> Bool { - launchctl(["print", serviceTarget]).status == 0 + let result = launchctl(["print", serviceTarget]) + guard result.status == 0 else { return false } + return result.output.components(separatedBy: .newlines).contains { line in + guard line.trimmingCharacters(in: .whitespaces).hasPrefix("pid = ") else { return false } + let value = line.trimmingCharacters(in: .whitespaces).dropFirst("pid = ".count) + return Int(value).map { $0 > 0 } ?? false + } } private static func runLaunchctl(_ arguments: [String]) throws { diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 9cf999b..c9d2291 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -218,11 +218,6 @@ final class ConfigurationTests: XCTestCase { let matrix = try SpriteAnimation.load(from: matrixURL) XCTAssertEqual(matrix.frameSize, NSSize(width: 36, height: 36)) XCTAssertEqual(matrix.frames.count, 16) - let explosionURL = temporaryDirectory.appendingPathComponent("animations/explosion_36x36.png") - XCTAssertTrue(FileManager.default.fileExists(atPath: explosionURL.path)) - let explosion = try SpriteAnimation.load(from: explosionURL) - XCTAssertEqual(explosion.frameSize, NSSize(width: 36, height: 36)) - XCTAssertEqual(explosion.frames.count, 16) } func testRemovesObsoleteIconSettingAndKeepsDefaultAnimation() throws { From 0b697b5e6b44adec5c03e5dccae3738c19284f87 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 00:35:28 +0400 Subject: [PATCH 15/43] Improve CLI diagnostics and executable resolution Explain why an animation cannot be used, including when it is missing, invalid, or specified as a path. Resolve the CLI executable through PATH when starting the server, and add a regression test. Add a make install target to install the app and CLI symlink. --- Makefile | 5 ++- Sources/Nyathing/CLI.swift | 42 +++++++++++++------ .../ConfigurationAndAPITests.swift | 15 +++++++ 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index cbeaa02..872e0e9 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash .DEFAULT_GOAL := help -.PHONY: help format lint test package run install-app install-cli-link uninstall +.PHONY: help format lint test package run install-app install-cli-link install uninstall help: @printf '%s\n' \ @@ -11,6 +11,7 @@ help: ' test Run the Swift test suite' \ ' package Build the macOS installer package' \ ' run Run animations for five seconds (ANIMATIONS="a b" optional)' \ + ' install Install the app and CLI symlink' \ ' install-app Build and install Nyathing.app in /Applications' \ ' install-cli-link Create the /usr/local/bin/nyathing symlink' \ ' uninstall Force-remove the app, CLI command, and user data' @@ -33,6 +34,8 @@ install-app: install-cli-link: bash Scripts/install-cli-link.sh +install: install-app install-cli-link + uninstall: bash Scripts/force-uninstall.sh diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index e579193..48aea58 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -91,15 +91,15 @@ struct CLIArguments { enum CLIError: LocalizedError { case usage - case animationUnavailable(String) + case animationUnavailable(String, String) case server(String) case api(String) var errorDescription: String? { switch self { case .usage: return CLIArguments.usage - case .animationUnavailable(let filename): - return "Animation not found or invalid: \(filename)." + case .animationUnavailable(let filename, let reason): + return "Animation '\(filename)' \(reason)" case .server(let message), .api(let message): return message } } @@ -243,7 +243,8 @@ enum NyathingCLI { static func resolveAnimation(_ name: String, in directory: URL) throws -> String { guard !name.contains("/"), !name.contains("\\") else { - throw CLIError.animationUnavailable(name) + throw CLIError.animationUnavailable( + name, "must be a filename, not a path. Use 'nyathing list' to see available animations.") } if name == "random" { if let namedAnimation = try? resolveNamedAnimation(name, in: directory) { @@ -261,17 +262,29 @@ enum NyathingCLI { guard let files = try? FileManager.default.contentsOfDirectory( at: directory, includingPropertiesForKeys: nil) - else { throw CLIError.animationUnavailable(name) } + else { + throw CLIError.animationUnavailable( + name, + "could not be checked because the animations directory is unavailable at \(directory.path)." + ) + } for size in ["54x36", "36x36"] { let expected = "\(stem)_\(size).png" guard let file = files.first(where: { $0.lastPathComponent.caseInsensitiveCompare(expected) == .orderedSame - }), let animation = try? SpriteAnimation.load(from: file) + }) else { continue } - return animation.filename + do { + return try SpriteAnimation.load(from: file).filename + } catch { + throw CLIError.animationUnavailable(name, "is invalid: \(error.localizedDescription).") + } } - throw CLIError.animationUnavailable(name) + throw CLIError.animationUnavailable( + name, + "was not found in \(directory.path). Expected a valid '*_36x36.png' or '*_54x36.png' file. Use 'nyathing list' to see available animations." + ) } static func activityDescription(command: String, arguments: [String]) -> String { @@ -282,7 +295,7 @@ enum NyathingCLI { min(configuration.keepaliveInterval, configuration.activityTimeout / 2) } - static func resolveExecutable(_ command: String) throws -> String { + static func resolveExecutable(_ command: String, searchPath: String? = nil) throws -> String { if command.contains("/") { let path = URL( fileURLWithPath: command, @@ -300,9 +313,11 @@ enum NyathingCLI { if FileManager.default.isExecutableFile(atPath: currentDirectoryPath) { return currentDirectoryPath } - let paths = ProcessInfo.processInfo.environment[ - "PATH", default: "/usr/bin:/bin:/usr/sbin:/sbin" - ].split(separator: ":") + let paths = + (searchPath + ?? ProcessInfo.processInfo.environment[ + "PATH", default: "/usr/bin:/bin:/usr/sbin:/sbin" + ]).split(separator: ":") for directory in paths { let path = URL(fileURLWithPath: String(directory)).appendingPathComponent(command).path if FileManager.default.isExecutableFile(atPath: path) { return path } @@ -397,7 +412,8 @@ private final class LocalAPIClient { static func connectOrStartServer() throws -> LocalAPIClient { if let connected = try? connect() { return connected } let process = Process() - process.executableURL = URL(fileURLWithPath: CommandLine.arguments[0]).standardizedFileURL + let executable = try NyathingCLI.resolveExecutable(CommandLine.arguments[0]) + process.executableURL = URL(fileURLWithPath: executable) process.arguments = [LaunchAgentSupport.serverArgument] process.standardInput = FileHandle.nullDevice process.standardOutput = FileHandle.nullDevice diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index c9d2291..842b2ae 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -174,6 +174,21 @@ final class CLITests: XCTestCase { XCTAssertEqual(try NyathingCLI.resolveExecutable(name), executable.path) } + + func testResolvesBareArgv0ThroughPathForStartingServer() throws { + let directory = FileManager.default.temporaryDirectory + .appendingPathComponent("NyathingPATH-\(UUID().uuidString)", isDirectory: true) + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + defer { try? FileManager.default.removeItem(at: directory) } + + let executable = directory.appendingPathComponent("nyathing") + try Data("#!/bin/sh\\nexit 0\\n".utf8).write(to: executable) + XCTAssertEqual(chmod(executable.path, 0o755), 0) + + XCTAssertEqual( + try NyathingCLI.resolveExecutable("nyathing", searchPath: directory.path), + executable.path) + } } final class ConfigurationTests: XCTestCase { From 93d7e9d6498595b2b563086e368f421e05ab6978 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 01:02:36 +0400 Subject: [PATCH 16/43] List active animations in status menus Show active task descriptions and their animation icons at the top of each status menu, ordered by start time. Refresh the menus as activities start and stop, and clear ordering state when runtime state resets. --- Sources/Nyathing/main.swift | 67 +++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index b1f74b4..0abeaa1 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -47,6 +47,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private var activityTimeout: TimeInterval = 5 private var keepaliveInterval: TimeInterval = 5 private var activityTimeouts: [UUID: TimeInterval] = [:] + private var activityStartOrder: [UUID: UInt64] = [:] + private var nextActivityStartOrder: UInt64 = 0 private var defaultAnimation = "nyathing_36x36.png" private var apiServer: LocalAPIServer? private var apiGeneration = 0 @@ -80,8 +82,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private func configureMenu(for item: NSStatusItem) { let menu = NSMenu() - menu.addItem(withTitle: "About Nyathing", action: #selector(showAbout), keyEquivalent: "") - menu.addItem(.separator()) + let activities = activeTaskMenuItems() + for menuItem in activities { menu.addItem(menuItem) } + if !activities.isEmpty { menu.addItem(.separator()) } menu.addItem( withTitle: "View Errors", action: #selector(viewErrors), keyEquivalent: "") menu.addItem( @@ -93,11 +96,61 @@ final class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem( withTitle: "Open Configuration", action: #selector(openConfiguration), keyEquivalent: "") menu.addItem(.separator()) + menu.addItem(withTitle: "About Nyathing", action: #selector(showAbout), keyEquivalent: "") menu.addItem(withTitle: "Quit Nyathing", action: #selector(quit), keyEquivalent: "q") for menuItem in menu.items { menuItem.target = self } item.menu = menu } + private func activeTaskMenuItems() -> [NSMenuItem] { + let rows = activityStartOrder.keys.sorted { + activityStartOrder[$0, default: 0] > activityStartOrder[$1, default: 0] + } + let font = NSFont.menuFont(ofSize: 0) + let widestActionTitle = + [ + "View Errors", "Reset Disconnected Count", "Reload Configuration and Animations", + "Open Configuration", "About Nyathing", "Quit Nyathing", + ].map { ($0 as NSString).size(withAttributes: [.font: font]).width }.max() ?? 0 + let iconColumnWidth: CGFloat = 16 + let horizontalMenuPadding: CGFloat = 16 + let availableWidth = max(0, widestActionTitle - iconColumnWidth - horizontalMenuPadding) + return rows.compactMap { id in + guard let animation = lifecycle.animation(for: id), + let active = activeAnimations[animation], let icon = active.frames.first, + let description = lifecycle.description(for: id) + else { return nil } + let item = NSMenuItem( + title: Self.truncatedMenuDescription(description, font: font, width: availableWidth), + action: nil, keyEquivalent: "") + let menuIcon = (icon.copy() as? NSImage) ?? icon + menuIcon.size = NSSize(width: iconColumnWidth, height: iconColumnWidth) + item.image = menuIcon + item.isEnabled = false + return item + } + } + + private static func truncatedMenuDescription(_ text: String, font: NSFont, width: CGFloat) + -> String + { + let attributes: [NSAttributedString.Key: Any] = [.font: font] + guard (text as NSString).size(withAttributes: attributes).width > width else { return text } + let ellipsis = "…" + var result = text + while !result.isEmpty, + ((result + ellipsis) as NSString).size(withAttributes: attributes).width > width + { + result.removeLast() + } + return result.isEmpty ? ellipsis : result + ellipsis + } + + private func refreshStatusItemMenus() { + if let mainStatusItem { configureMenu(for: mainStatusItem) } + for active in activeAnimations.values { configureMenu(for: active.statusItem) } + } + @objc private func showAbout() { let repositoryURL = URL(string: "https://github.com/dokwork/nyathing")! let credits = NSMutableAttributedString( @@ -324,6 +377,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private func clearRuntimeState() { activeAnimations.removeAll() + activityStartOrder.removeAll() + nextActivityStartOrder = 0 lifecycle.reset() updateMainStatusItemVisibility() updateMainStatusItem() @@ -348,6 +403,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let deadlineUptime = deadline.uptimeNanoseconds let id = lifecycle.start( animation: resolvedFilename, description: description, deadline: deadlineUptime) + activityStartOrder[id] = nextActivityStartOrder + nextActivityStartOrder &+= 1 activityTimeouts[id] = timeout scheduleActivityExpiration(id, deadlineUptime: deadlineUptime) if let active = activeAnimations[resolvedFilename] { @@ -355,6 +412,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { updateActivityStatus(active) updateMainStatusItemVisibility() updateMainStatusItem() + refreshStatusItemMenus() return id } @@ -371,6 +429,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { updateActivityStatus(active) updateMainStatusItemVisibility() updateMainStatusItem() + refreshStatusItemMenus() return id } @@ -378,7 +437,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate { func stopActivity(_ id: UUID) { guard let filename = lifecycle.stop(id) else { return } activityTimeouts.removeValue(forKey: id) + activityStartOrder.removeValue(forKey: id) removeActivityFromStatusItem(id, animation: filename) + refreshStatusItemMenus() } private func removeActivityFromStatusItem(_ id: UUID, animation filename: String) { @@ -476,7 +537,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } guard let expired = lifecycle.expire(id, deadline: deadlineUptime) else { return } activityTimeouts.removeValue(forKey: id) + activityStartOrder.removeValue(forKey: id) removeActivityFromStatusItem(id, animation: expired.animation) + refreshStatusItemMenus() presentActivityTimeout() } From 6cfc6a8de6b7666a76c5c71554a841e9d23bc903 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 01:13:49 +0400 Subject: [PATCH 17/43] Hide the View Errors menu item when no errors are pending --- Sources/Nyathing/main.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 0abeaa1..482f4b1 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -85,8 +85,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let activities = activeTaskMenuItems() for menuItem in activities { menu.addItem(menuItem) } if !activities.isEmpty { menu.addItem(.separator()) } - menu.addItem( - withTitle: "View Errors", action: #selector(viewErrors), keyEquivalent: "") + if !lifecycle.timedOutActivities.isEmpty { + menu.addItem( + withTitle: "View Errors", action: #selector(viewErrors), keyEquivalent: "") + } menu.addItem( withTitle: "Reset Disconnected Count", action: #selector(resetDisconnectedCount), keyEquivalent: "") From 9c5432952e2b0583ca4c94576038ac6776cd34fb Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 09:39:36 +0400 Subject: [PATCH 18/43] Document the server protocol and refine menu presentation Add field tables and request examples for each API command, and clarify the CLI and timeout behavior in the README. Align the server and CLI screenshots to the right. Simplify the menu by removing the disconnected-count reset action, shortening the About and Quit labels, and separating them. Remove the obsolete lifecycle reset method and its test. --- README.md | 155 ++++++++++++++---- Sources/Nyathing/ActivityLifecycle.swift | 5 - Sources/Nyathing/main.swift | 19 +-- .../ConfigurationAndAPITests.swift | 12 -- assets/nyathing-cli.png | Bin 0 -> 43675 bytes assets/nyathing-server.png | Bin 0 -> 61738 bytes 6 files changed, 127 insertions(+), 64 deletions(-) create mode 100644 assets/nyathing-cli.png create mode 100644 assets/nyathing-server.png diff --git a/README.md b/README.md index 50d5282..ef9c7c1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Nyathing brings background processes to life with playful animations in the macOS menu bar. Clients start an animation when work begins and stop it when the task is done. -## Install +## 🢃 Install Download the installer package from the repository's **Releases** page. Open the package and follow the Installer prompts to install `Nyathing.app` in @@ -51,6 +51,8 @@ Alternatively, build and run `Nyathing` locally using the instructions in ## Nyathing server +

nyathing-server

+ Nyathing exposes a local API over a Unix domain stream socket. The socket path is `$XDG_RUNTIME_DIR/nyathing.sock` when `XDG_RUNTIME_DIR` is set; otherwise it is `$TMPDIR/nyathing-.sock` (usually `/tmp`). The socket is restricted to the @@ -61,33 +63,15 @@ Nyathing returns one JSON object followed by a newline for each request. A connection can carry multiple request/response pairs, and multiple clients may connect at the same time. Request lines are limited to 1 MiB. -Commands: - -- Start an activity: `{"command":"start","animation":"nyan_54x36.png"}` - returns `{"ok":true,"activity_id":"…"}`. Optional - `keepalive_interval_seconds` and `activity_timeout_seconds` fields override - the corresponding `config.toml` defaults for this activity; both must be - positive numbers. The animation is identified by - its filename. The `animation` field is optional; when omitted, Nyathing uses - the animation selected by `default_animation` in `config.toml`. If a - requested animation is unavailable or invalid, Nyathing uses the built-in - ghost animation. -- Refresh a running activity: `{"command":"keepalive","activity_id":"…"}` - returns `{"ok":true}` and resets its expiration timer. -- End an activity: `{"command":"stop","activity_id":"…"}` returns - `{"ok":true}` and does not count as a disconnect. - -Errors return `{"ok":false,"error":"…"}`. This includes malformed requests, -unknown commands, and unknown activity IDs. Send keepalives periodically; the -activity expires after `activity_timeout_seconds` without one. Expiration -increments the disconnected-client count and plays `explosion_36x36.png` when -available. Explicitly stopping an activity does not count as a disconnect. -Use **Reset Disconnected Count** in the menu to clear the count. - -## Run terminal commands with Nyathing - -Run a command with `nyathing` to display an animation while it runs. Nyathing -starts the activity, keeps it alive while the command runs, then stops it. +For the complete message formats, field requirements, and response schemas, +see [Server communication protocol](#server-communication-protocol). + +## Nyathing CLI + +

nyathing-cli

+ +Nyathing provides a command-line utility for wrapping long-running terminal +commands in an animation. For example, show an animation while waiting five seconds, with or without a custom animation: @@ -132,7 +116,7 @@ To view available options or check the installed version: nyathing --version ``` -## Shell completion +## ❯ Shell completion Nyathing can generate completion scripts for Zsh and Bash. Add the appropriate command to your shell configuration file to enable completion in new shells. @@ -163,7 +147,7 @@ width must be a positive multiple of it. Name files with the frame size suffix, for example `nyan_54x36.png`. The app validates assets on startup and reload; invalid assets are ignored and logged. Playback runs at 10 frames per second. -## Configuration +## ⚙ Configuration On first launch, Nyathing creates its configuration directory and adds these built-in animations: @@ -201,7 +185,112 @@ Use **Reload Configuration and Animations** in the menu after changing configuration or animation files. Reload clears active client activities and the disconnected-client count. -## Minimal Python client example +## {} Server communication protocol + +The server communicates over a Unix domain `SOCK_STREAM` socket using UTF-8 +JSON Lines. Each message is a JSON object followed by `\n`; each request +receives exactly one response. A connection may carry multiple sequential +request/response pairs. A request line may be at most 1 MiB. The socket is +accessible only to the current user, whose identity is also checked when +connecting. + +### Request messages + +Every request has this common envelope: + +```json +{ + "command": "" +} +``` + +The `command` property is required and must be a string. The following command +messages are supported: + +| Command | Description | +| --- | --- | +| `start` | Starts an activity and returns its identifier. | +| `keepalive` | Refreshes an activity's expiration timer. | +| `stop` | Ends an activity without counting it as a disconnect. | + +#### `start` request + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `command` | string | Yes | Must be `start`. | +| `animation` | string | No | Animation filename. Defaults to the server's configured animation; unavailable or invalid names use the built-in ghost. | +| `description` | string | No | Description shown for the activity. If omitted or not a string, the server uses its default description. | +| `keepalive_interval_seconds` | number | No | Positive, finite keepalive interval in seconds. Defaults to the server configuration. | +| `activity_timeout_seconds` | number | No | Positive, finite inactivity timeout in seconds. Defaults to the server configuration. | + +Examples: + +```json +{"command":"start","animation":"nyan_54x36.png"} +``` +or +```json +{"command":"start","animation":"nyan_54x36.png","description":"make test","keepalive_interval_seconds":5,"activity_timeout_seconds":15} +``` + +#### `keepalive` request + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `command` | string | Yes | Must be `keepalive`. | +| `activity_id` | string (UUID) | Yes | Identifier returned by the corresponding `start` request. | + +Example: + +```json +{"command":"keepalive","activity_id":""} +``` + +Send keepalives periodically, typically at the interval specified in the +`start` request. If the server does not receive one within the configured +`activity_timeout_seconds`, the activity expires and increments the +disconnected-client count. + +#### `stop` request + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `command` | string | Yes | Must be `stop`. | +| `activity_id` | string (UUID) | Yes | Identifier returned by the corresponding `start` request. Stopping an activity does not count as a disconnect. | + +Example: + +```json +{"command":"stop","activity_id":""} +``` + +### Response messages + +A successful `start` response contains the activity identifier: + +```json +{"ok":true,"activity_id":""} +``` + +Successful `keepalive` and `stop` responses are: + +```json +{"ok":true} +``` + +A failed request returns an error response: + +```json +{"ok":false,"error":""} +``` + +Errors include malformed requests, unknown commands or activity identifiers, +invalid timeout values, and request lines over the size limit. An activity +expires if the server does not receive a keepalive within its configured +timeout. Expiration increments the disconnected-client count; an explicit +`stop` does not. + +## ✦ Minimal Python client example ```python import json @@ -235,7 +324,7 @@ Set `auto_start = false` and reload to remove the LaunchAgent. If you move `Nyathing.app`, enable auto-start again and reload so the LaunchAgent records the app's new location. -## Troubleshooting +## ⚡︎ Troubleshooting Startup and runtime diagnostics are written to `$XDG_STATE_HOME/nyathing/nyathing.log`, or @@ -246,7 +335,7 @@ If the socket path is already in use, quit the existing instance before launching another. Invalid animation files are reported in the log; correct them and reload. -## Build from source +## ⚒ Build from source Requires macOS 12+ and Swift 5.9 or later. Run the commands below from the repository root. diff --git a/Sources/Nyathing/ActivityLifecycle.swift b/Sources/Nyathing/ActivityLifecycle.swift index 83f84e7..5bb249e 100644 --- a/Sources/Nyathing/ActivityLifecycle.swift +++ b/Sources/Nyathing/ActivityLifecycle.swift @@ -77,11 +77,6 @@ struct ActivityLifecycle { return true } - mutating func resetDisconnectedCount() { - disconnectedCount = 0 - timedOutActivities.removeAll() - } - mutating func reset() { activities.removeAll() descriptions.removeAll() diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 482f4b1..724981d 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -89,17 +89,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem( withTitle: "View Errors", action: #selector(viewErrors), keyEquivalent: "") } - menu.addItem( - withTitle: "Reset Disconnected Count", action: #selector(resetDisconnectedCount), - keyEquivalent: "") menu.addItem( withTitle: "Reload Configuration and Animations", action: #selector(reloadFromMenu), keyEquivalent: "") menu.addItem( withTitle: "Open Configuration", action: #selector(openConfiguration), keyEquivalent: "") menu.addItem(.separator()) - menu.addItem(withTitle: "About Nyathing", action: #selector(showAbout), keyEquivalent: "") - menu.addItem(withTitle: "Quit Nyathing", action: #selector(quit), keyEquivalent: "q") + menu.addItem(withTitle: "About", action: #selector(showAbout), keyEquivalent: "") + menu.addItem(.separator()) + menu.addItem(withTitle: "Quit", action: #selector(quit), keyEquivalent: "q") for menuItem in menu.items { menuItem.target = self } item.menu = menu } @@ -111,8 +109,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let font = NSFont.menuFont(ofSize: 0) let widestActionTitle = [ - "View Errors", "Reset Disconnected Count", "Reload Configuration and Animations", - "Open Configuration", "About Nyathing", "Quit Nyathing", + "View Errors", "Reload Configuration and Animations", + "Open Configuration", "About", "Quit", ].map { ($0 as NSString).size(withAttributes: [.font: font]).width }.max() ?? 0 let iconColumnWidth: CGFloat = 16 let horizontalMenuPadding: CGFloat = 16 @@ -280,13 +278,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } } - @objc private func resetDisconnectedCount() { - lifecycle.resetDisconnectedCount() - updateMainStatusItemVisibility() - updateMainStatusItem() - refreshErrorsWindow() - } - @objc private func reloadFromMenu() { reloadConfigurationAndAnimations() } diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 842b2ae..9d7d3f7 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -372,18 +372,6 @@ final class ActivityLifecycleTests: XCTestCase { XCTAssertEqual(lifecycle.disconnectedCount, 0) } - func testResetDisconnectedCountClearsOutstandingTimeouts() { - var lifecycle = ActivityLifecycle() - let id = lifecycle.start(animation: "nyathing_36x36.png", deadline: 10) - _ = lifecycle.expire(id, deadline: 10) - XCTAssertEqual(lifecycle.timedOutActivities.count, 1) - - lifecycle.resetDisconnectedCount() - - XCTAssertEqual(lifecycle.disconnectedCount, 0) - XCTAssertTrue(lifecycle.timedOutActivities.isEmpty) - } - func testResetClearsActivitiesDeadlinesAndDisconnectCount() throws { var lifecycle = ActivityLifecycle() let id = lifecycle.start(animation: "nyathing_36x36.png", deadline: 10) diff --git a/assets/nyathing-cli.png b/assets/nyathing-cli.png new file mode 100644 index 0000000000000000000000000000000000000000..c769a16ed8fbc39620a0c9ac67108536fa92645a GIT binary patch literal 43675 zcmb@rWmFyAvNpQ##lqd)ec|rz?(XjH?(Xic0RjX`aCdjN0Kp*yO>W-3&v*8@XMFeH z?H+ShbyYnjJ*#DO$EqkvBZ2Ti0000=0DL(B0FFyRx2nKjMTDh}td*i7 zfc`HJ1i(O`1EBtL5Px?71U}#&Z+|&}90b9C^J);Z|78OS07TmYp#RH8?=SsllleRT z!Tg&-l|cN*V+rJcTaTAO{fGYtW@D<7^_RfA$mqHQ006`z`f)PKSM9to1$czC$*v9Nf1doz2pGdsIk zv#|2=^0I*0SlHN@{#r1(`#O1;`Y<`UQ~cY>|M4SX>2B_3>*8VS>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Xk_RxMR4qo>##*uu`;tm$i8K0ck!OF zcT)VwFLN1M<>J^QFMo;=Im13>$wB7P3=6-CLN8)v-@Uhw9Sf40mgJRr*g4rz8Isuz zUly8v9xQq(4g>eNB*!m~Y!{$KYXc2w(!Bd5kj>~ta7K3IA!D=B#dy;yiw3W98`dln zw1jQ!3`(2@sWb!KNBhz#aovXkbK=R-g;iwz^Duf449EV;77G0mjZG;asqkYs;P&GG z;?C7C{k`Ft*H(s$XDBxxf^i1aJUr|qzUzJM>`(t1=J;7C@<7MluCkyps*=oxPU4V@ zDHhjT@BQ!l(NnVS?pB~f>wZ7HdDuMmA4Dg3tB-z)g^6VsRkpFm2^!6tSx9p79$dY;f~dA4{k zJg~B~^)SY`HJtwBiQ(Gu?cpUpUHM1pE}TJi%h&&3H(#NYWM;>E#~06b!JuBn@+hU59@h)ldvq%43UH}Nqn>xx<-!X1|OEG%B0^+ z*HOta!3~7uSk~+^yRdz*b1iXJrr~v-{wDOXyWCr$R8TuLtDU1adEJUco;rxHh%#F@ zbWJ9^Ws@*bGeet>y;MtV|Jcji;lc%bs>UO+KPDFo{`vjKA3wKp(;gtb1Ina+*rK=I zxD_f#p4|!-EfQC-mWY`YyOs41)qo`Z_WNJ{pD_3LUES(qFTV!ApQIAIQbDC?W!*we zgt?M#q-P~TUArM^7Zpf#f+hXEcw-9i{qOXlRTSoJAc$cotqUXSf3SV^g9NDVCU?T_R z<*JRz*5%<__apalh25`0-Cx(KE4vt~oXxjQwio~L-ECZ&Ol;~v$!b@-N{etG{#5A4 z^7?g7!g=&C^PlKZ?ZQ}eTH_wk1*#;f3I;QP!u`Q2(|wBfXQBHVd3K&*-sHEL^iyRg zci`N*Q%r6xbMss++9(=+)*N%@6v Date: Fri, 20 Nov 2026 09:57:41 +0400 Subject: [PATCH 19/43] Scale animation frames to 22 pt tall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preserve each frame's aspect ratio while reducing its displayed height to 22 pt. This makes 36×36 frames display at 22×22 pt and 54×36 frames at 33×22 pt. Tests pass. --- Sources/Nyathing/CLI.swift | 10 ++--- Sources/Nyathing/LocalAPIServer.swift | 8 ++-- Sources/Nyathing/main.swift | 17 +++++++-- .../ConfigurationAndAPITests.swift | 37 +++++++------------ 4 files changed, 37 insertions(+), 35 deletions(-) diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 48aea58..573b7a6 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -173,7 +173,6 @@ enum NyathingCLI { let animationsDirectory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) let animation = try resolveAnimation(cli.animation, in: animationsDirectory) - let keepaliveInterval = keepaliveInterval(for: configuration) let client = try LocalAPIClient.connectOrStartServer() let activity = try client.command([ "command": "start", @@ -182,7 +181,10 @@ enum NyathingCLI { "keepalive_interval_seconds": NSNumber(value: configuration.keepaliveInterval), "activity_timeout_seconds": NSNumber(value: configuration.activityTimeout), ]) - guard let activityID = activity["activity_id"] as? String else { + guard let activityID = activity["activity_id"] as? String, + let keepaliveInterval = activity["keepalive_interval_seconds"] as? Double, + keepaliveInterval.isFinite, keepaliveInterval > 0 + else { throw CLIError.api("The server returned an invalid activity response.") } defer { _ = try? client.command(["command": "stop", "activity_id": activityID]) } @@ -291,10 +293,6 @@ enum NyathingCLI { ([command] + arguments).joined(separator: " ") } - static func keepaliveInterval(for configuration: AppConfiguration) -> TimeInterval { - min(configuration.keepaliveInterval, configuration.activityTimeout / 2) - } - static func resolveExecutable(_ command: String, searchPath: String? = nil) throws -> String { if command.contains("/") { let path = URL( diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index c93ea67..a7dc219 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -6,7 +6,7 @@ final class LocalAPIServer { private let defaultAnimation: String private let defaultKeepaliveInterval: TimeInterval private let defaultActivityTimeout: TimeInterval - private let onStart: (String, String?, TimeInterval, TimeInterval) throws -> String + private let onStart: (String, String?, TimeInterval) throws -> String private let onKeepalive: (String) throws -> Void private let onStop: (String) throws -> Void private let socketPath: String @@ -20,7 +20,7 @@ final class LocalAPIServer { defaultAnimation: String = "nyathing_36x36.png", defaultKeepaliveInterval: TimeInterval = 5, defaultActivityTimeout: TimeInterval = 5, - onStart: @escaping (String, String?, TimeInterval, TimeInterval) throws -> String, + onStart: @escaping (String, String?, TimeInterval) throws -> String, onKeepalive: @escaping (String) throws -> Void, onStop: @escaping (String) throws -> Void ) { @@ -226,10 +226,12 @@ final class LocalAPIServer { request["keepalive_interval_seconds"], default: defaultKeepaliveInterval) let activityTimeout = try seconds( request["activity_timeout_seconds"], default: defaultActivityTimeout) + let effectiveKeepaliveInterval = min(keepaliveInterval, activityTimeout / 2) return [ "ok": true, "activity_id": try onStart( - animation, request["description"] as? String, keepaliveInterval, activityTimeout), + animation, request["description"] as? String, activityTimeout), + "keepalive_interval_seconds": effectiveKeepaliveInterval, ] case "keepalive": guard let activityID = request["activity_id"] as? String, !activityID.isEmpty else { diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 724981d..e9ac64f 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -337,7 +337,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { defaultAnimation: defaultAnimation, defaultKeepaliveInterval: keepaliveInterval, defaultActivityTimeout: activityTimeout, - onStart: { [weak self] filename, description, _, timeout in + onStart: { [weak self] filename, description, timeout in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } return self.startActivity( @@ -410,10 +410,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } let frames: [NSImage] + let sourceFrames: [NSImage] switch AnimationResolution.resolve(resolvedFilename, available: animations) { - case .asset(let animation): frames = animation.frames - case .builtInGhost: frames = Self.builtInGhostFrames() + case .asset(let animation): sourceFrames = animation.frames + case .builtInGhost: sourceFrames = Self.builtInGhostFrames() } + frames = Self.scaledAnimationFrames(sourceFrames, height: 22) let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) configureMenu(for: statusItem) let active = ActiveAnimation( @@ -455,6 +457,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate { refreshErrorsWindow() } + private static func scaledAnimationFrames(_ frames: [NSImage], height: CGFloat) -> [NSImage] { + frames.map { frame in + let scaled = (frame.copy() as? NSImage) ?? frame + let scale = height / frame.size.height + scaled.size = NSSize(width: frame.size.width * scale, height: height) + return scaled + } + } + private func updateActivityStatus(_ active: ActiveAnimation) { guard let button = active.statusItem.button, !active.frames.isEmpty else { return } let frame = active.frames[active.frameIndex] diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 9d7d3f7..af0189b 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -103,18 +103,6 @@ final class CLITests: XCTestCase { XCTAssertEqual(NyathingCLI.activityDescription(command: "sleep", arguments: []), "sleep") } - func testKeepaliveIntervalPrecedesConfiguredActivityTimeout() { - let configuration = AppConfiguration( - keepaliveInterval: 5, activityTimeout: 0.8, autoStart: false, - defaultAnimation: "nyathing_36x36.png") - XCTAssertEqual(NyathingCLI.keepaliveInterval(for: configuration), 0.4, accuracy: 0.0001) - - let shorterConfiguredInterval = AppConfiguration( - keepaliveInterval: 0.2, activityTimeout: 3, autoStart: false, - defaultAnimation: "nyathing_36x36.png") - XCTAssertEqual(NyathingCLI.keepaliveInterval(for: shorterConfiguredInterval), 0.2) - } - func testZshCompletionTracksCLICommandsAndDynamicAnimations() throws { let script = try XCTUnwrap(ShellCompletion.script(for: "zsh")) @@ -399,15 +387,17 @@ final class LocalAPIServerTests: XCTestCase { let lock = NSLock() var startedAnimations: [String] = [] var startedDescriptions: [String?] = [] + var startedTimeouts: [Double] = [] var stoppedIDs: [String] = [] let server = LocalAPIServer( socketPath: socketPath, defaultAnimation: "nyan_54x36.png", - onStart: { animation, description, _, _ in + onStart: { animation, description, timeout in lock.lock() defer { lock.unlock() } startedAnimations.append(animation) startedDescriptions.append(description) + startedTimeouts.append(timeout) return "activity-\(startedAnimations.count)" }, onKeepalive: { _ in }, onStop: { id in @@ -419,11 +409,12 @@ final class LocalAPIServerTests: XCTestCase { defer { server.stop() } let first = try UnixJSONClient(path: socketPath) - XCTAssertEqual( - try first.command([ - "command": "start", "animation": "same_36x36.png", "description": "first client", - ])["activity_id"] as? String, - "activity-1") + let firstStart = try first.command([ + "command": "start", "animation": "same_36x36.png", "description": "first client", + "keepalive_interval_seconds": 8, "activity_timeout_seconds": 10, + ]) + XCTAssertEqual(firstStart["activity_id"] as? String, "activity-1") + XCTAssertEqual(firstStart["keepalive_interval_seconds"] as? Double, 5) XCTAssertEqual( try first.command(["command": "keepalive", "activity_id": "activity-1"])["ok"] as? Bool, true) @@ -431,10 +422,9 @@ final class LocalAPIServerTests: XCTestCase { try first.command(["command": "stop", "activity_id": "activity-1"])["ok"] as? Bool, true) let second = try UnixJSONClient(path: socketPath) - XCTAssertEqual( - try second.command(["command": "start", "animation": "same_36x36.png"])["activity_id"] - as? String, - "activity-2") + let secondStart = try second.command(["command": "start", "animation": "same_36x36.png"]) + XCTAssertEqual(secondStart["activity_id"] as? String, "activity-2") + XCTAssertEqual(secondStart["keepalive_interval_seconds"] as? Double, 2.5) XCTAssertEqual( try second.command(["command": "start"])["activity_id"] as? String, "activity-3") @@ -443,6 +433,7 @@ final class LocalAPIServerTests: XCTestCase { startedAnimations, ["same_36x36.png", "same_36x36.png", "nyan_54x36.png"]) XCTAssertEqual(stoppedIDs, ["activity-1"]) XCTAssertEqual(startedDescriptions, ["first client", nil, nil]) + XCTAssertEqual(startedTimeouts, [10, 5, 5]) lock.unlock() let responseLock = NSLock() @@ -491,7 +482,7 @@ private final class UnixJSONClient { deinit { Darwin.close(descriptor) } - func command(_ request: [String: String]) throws -> [String: Any] { + func command(_ request: [String: Any]) throws -> [String: Any] { var data = try JSONSerialization.data(withJSONObject: request) data.append(0x0A) let written = data.withUnsafeBytes { Darwin.write(descriptor, $0.baseAddress!, $0.count) } From 05d5e6e68c1f2e9a78dfb35218d3e96c46ba02ae Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 18:46:36 +0400 Subject: [PATCH 20/43] Make activity timeout server-controlled Set the default activity timeout to 30 seconds and remove per-activity timeout overrides from the API. Require clients to provide a valid keepalive interval shorter than the server timeout, with clear errors for missing or invalid values. Update the CLI, test script, README, and API tests to match the revised protocol. --- README.md | 30 +++++++------ Scripts/run-test-animation.py | 12 +++-- Sources/Nyathing/CLI.swift | 9 ++-- Sources/Nyathing/Configuration.swift | 4 +- Sources/Nyathing/LocalAPIServer.swift | 41 +++++++++++------ Sources/Nyathing/main.swift | 5 +-- .../ConfigurationAndAPITests.swift | 45 +++++++++++++++---- 7 files changed, 94 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index ef9c7c1..9063f99 100644 --- a/README.md +++ b/README.md @@ -166,10 +166,10 @@ your files. The complete initial configuration is: ```toml -# Seconds between client keepalive messages; must be greater than zero. +# Default interval at which clients send keepalives; must be less than the server timeout. keepalive_interval_seconds = 5 -# Seconds without a keepalive before an activity expires; must be greater than zero. -activity_timeout_seconds = 5 +# Server-side seconds without a keepalive before an activity expires. +activity_timeout_seconds = 30 # Whether to launch Nyathing automatically when you log in. auto_start = false # Animation filename used when a client omits the animation field. @@ -178,9 +178,11 @@ default_animation = "nyathing_36x36.png" Keep all four settings in your `config.toml`; Nyathing does not fill in omitted settings. Set `auto_start` to `true` or `false`; both durations must be positive -numbers. Set `default_animation` to the filename of a valid animation in the -`animations/` directory. Requests with an explicit animation use it; missing or -unavailable requested animations fall back to the built-in ghost. +numbers, and `keepalive_interval_seconds` must be less than +`activity_timeout_seconds`. Set `default_animation` to the filename of a valid +animation in the `animations/` directory. Requests with an explicit animation +use it; missing or unavailable requested animations fall back to the built-in +ghost. Use **Reload Configuration and Animations** in the menu after changing configuration or animation files. Reload clears active client activities and the disconnected-client count. @@ -220,17 +222,16 @@ messages are supported: | `command` | string | Yes | Must be `start`. | | `animation` | string | No | Animation filename. Defaults to the server's configured animation; unavailable or invalid names use the built-in ghost. | | `description` | string | No | Description shown for the activity. If omitted or not a string, the server uses its default description. | -| `keepalive_interval_seconds` | number | No | Positive, finite keepalive interval in seconds. Defaults to the server configuration. | -| `activity_timeout_seconds` | number | No | Positive, finite inactivity timeout in seconds. Defaults to the server configuration. | +| `keepalive_interval_seconds` | number | Yes | Positive, finite interval in seconds at which the client sends keepalives. Must be less than the server's configured `activity_timeout_seconds`. | Examples: ```json -{"command":"start","animation":"nyan_54x36.png"} +{"command":"start","animation":"nyan_54x36.png","keepalive_interval_seconds":5} ``` or ```json -{"command":"start","animation":"nyan_54x36.png","description":"make test","keepalive_interval_seconds":5,"activity_timeout_seconds":15} +{"command":"start","animation":"nyan_54x36.png","description":"make test","keepalive_interval_seconds":5} ``` #### `keepalive` request @@ -285,9 +286,10 @@ A failed request returns an error response: ``` Errors include malformed requests, unknown commands or activity identifiers, -invalid timeout values, and request lines over the size limit. An activity -expires if the server does not receive a keepalive within its configured -timeout. Expiration increments the disconnected-client count; an explicit +missing or invalid keepalive intervals, intervals not shorter than the server +timeout, per-activity timeout overrides, and oversized request lines. An +activity expires if the server does not receive a keepalive within its +configured timeout. Expiration increments the disconnected-client count; an explicit `stop` does not. ## ✦ Minimal Python client example @@ -308,7 +310,7 @@ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client: stream.write(json.dumps(value).encode() + b"\n") stream.flush() return json.loads(stream.readline()) - activity = command({"command": "start", "animation": "nyan_54x36.png"})["activity_id"] + activity = command({"command": "start", "animation": "nyan_54x36.png", "keepalive_interval_seconds": 5})["activity_id"] command({"command": "keepalive", "activity_id": activity}) command({"command": "stop", "activity_id": activity}) ``` diff --git a/Scripts/run-test-animation.py b/Scripts/run-test-animation.py index 0cc2ae0..f8fdc67 100644 --- a/Scripts/run-test-animation.py +++ b/Scripts/run-test-animation.py @@ -71,6 +71,8 @@ def configured_seconds(text, key, default): time.sleep(0.2) settings = config_path.read_text(encoding="utf-8") if config_path.exists() else "" + interval = configured_seconds(settings, "keepalive_interval_seconds", 5.0) + timeout = configured_seconds(settings, "activity_timeout_seconds", 30.0) animations = os.environ.get("ANIMATIONS", "").replace(",", " ").split() if not animations: animation = os.environ.get("ANIMATION") or configured_value( @@ -78,13 +80,15 @@ def configured_seconds(text, key, default): ) animations = [animation] for animation in animations: - activity_id = request({"command": "start", "animation": animation})["activity_id"] + activity_id = request({ + "command": "start", + "animation": animation, + "keepalive_interval_seconds": interval, + })["activity_id"] activity_ids.append(activity_id) print(f"Started {animation} ({activity_id})") - interval = configured_seconds(settings, "keepalive_interval_seconds", 5.0) - timeout = configured_seconds(settings, "activity_timeout_seconds", 5.0) - keepalive_delay = min(interval, timeout) / 2 + keepalive_delay = interval run_deadline = time.monotonic() + 5 while time.monotonic() < run_deadline: time.sleep(min(keepalive_delay, run_deadline - time.monotonic())) diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 573b7a6..aa8e717 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -173,18 +173,15 @@ enum NyathingCLI { let animationsDirectory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) let animation = try resolveAnimation(cli.animation, in: animationsDirectory) + let keepaliveInterval = configuration.keepaliveInterval let client = try LocalAPIClient.connectOrStartServer() let activity = try client.command([ "command": "start", "animation": animation, "description": activityDescription(command: cli.command, arguments: cli.arguments), - "keepalive_interval_seconds": NSNumber(value: configuration.keepaliveInterval), - "activity_timeout_seconds": NSNumber(value: configuration.activityTimeout), + "keepalive_interval_seconds": NSNumber(value: keepaliveInterval), ]) - guard let activityID = activity["activity_id"] as? String, - let keepaliveInterval = activity["keepalive_interval_seconds"] as? Double, - keepaliveInterval.isFinite, keepaliveInterval > 0 - else { + guard let activityID = activity["activity_id"] as? String else { throw CLIError.api("The server returned an invalid activity response.") } defer { _ = try? client.command(["command": "stop", "activity_id": activityID]) } diff --git a/Sources/Nyathing/Configuration.swift b/Sources/Nyathing/Configuration.swift index e3fef04..5836016 100644 --- a/Sources/Nyathing/Configuration.swift +++ b/Sources/Nyathing/Configuration.swift @@ -11,8 +11,8 @@ struct AppConfiguration { static let template = """ # Seconds between client keepalive messages; must be greater than zero. keepalive_interval_seconds = 5 - # Seconds without a keepalive before an activity expires; must be greater than zero. - activity_timeout_seconds = 5 + # Server-side seconds without a keepalive before an activity expires. + activity_timeout_seconds = 30 # Whether Nyathing should launch automatically when you log in. auto_start = false # Animation filename used when a client omits the animation field. diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index a7dc219..0297895 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -4,7 +4,6 @@ import Foundation /// Serves the local JSON Lines API over a current-user Unix domain socket. final class LocalAPIServer { private let defaultAnimation: String - private let defaultKeepaliveInterval: TimeInterval private let defaultActivityTimeout: TimeInterval private let onStart: (String, String?, TimeInterval) throws -> String private let onKeepalive: (String) throws -> Void @@ -18,14 +17,12 @@ final class LocalAPIServer { init( socketPath: String = LocalAPIServer.socketPath, defaultAnimation: String = "nyathing_36x36.png", - defaultKeepaliveInterval: TimeInterval = 5, - defaultActivityTimeout: TimeInterval = 5, + defaultActivityTimeout: TimeInterval = 30, onStart: @escaping (String, String?, TimeInterval) throws -> String, onKeepalive: @escaping (String) throws -> Void, onStop: @escaping (String) throws -> Void ) { self.defaultAnimation = defaultAnimation - self.defaultKeepaliveInterval = defaultKeepaliveInterval self.defaultActivityTimeout = defaultActivityTimeout self.onStart = onStart self.onKeepalive = onKeepalive @@ -222,16 +219,21 @@ final class LocalAPIServer { case "start": let animation = request["animation"] as? String ?? defaultAnimation guard !animation.isEmpty else { throw LocalAPIError.invalidRequest } - let keepaliveInterval = try seconds( - request["keepalive_interval_seconds"], default: defaultKeepaliveInterval) - let activityTimeout = try seconds( - request["activity_timeout_seconds"], default: defaultActivityTimeout) - let effectiveKeepaliveInterval = min(keepaliveInterval, activityTimeout / 2) + guard request["activity_timeout_seconds"] == nil else { + throw LocalAPIError.serverManagedActivityTimeout + } + guard let rawKeepaliveInterval = request["keepalive_interval_seconds"] else { + throw LocalAPIError.missingKeepaliveInterval + } + let keepaliveInterval = try positiveSeconds(rawKeepaliveInterval) + let activityTimeout = defaultActivityTimeout + guard keepaliveInterval < activityTimeout else { + throw LocalAPIError.keepaliveIntervalTooLong(keepaliveInterval, activityTimeout) + } return [ "ok": true, "activity_id": try onStart( animation, request["description"] as? String, activityTimeout), - "keepalive_interval_seconds": effectiveKeepaliveInterval, ] case "keepalive": guard let activityID = request["activity_id"] as? String, !activityID.isEmpty else { @@ -272,11 +274,10 @@ final class LocalAPIServer { } } - private func seconds(_ value: Any?, default fallback: TimeInterval) throws -> TimeInterval { - guard let value else { return fallback } + private func positiveSeconds(_ value: Any) throws -> TimeInterval { guard let number = value as? NSNumber, number.doubleValue.isFinite, number.doubleValue > 0 else { - throw LocalAPIError.invalidRequest + throw LocalAPIError.invalidKeepaliveInterval } return number.doubleValue } @@ -315,6 +316,10 @@ final class LocalAPIServer { enum LocalAPIError: LocalizedError { case unavailable case invalidRequest + case missingKeepaliveInterval + case invalidKeepaliveInterval + case keepaliveIntervalTooLong(TimeInterval, TimeInterval) + case serverManagedActivityTimeout case unknownCommand(String) case unknownActivity case socketPathTooLong @@ -325,6 +330,16 @@ enum LocalAPIError: LocalizedError { switch self { case .unavailable: return "The local API is unavailable." case .invalidRequest: return "Invalid JSON Lines request." + case .missingKeepaliveInterval: + return "Missing required field 'keepalive_interval_seconds'." + case .invalidKeepaliveInterval: + return "'keepalive_interval_seconds' must be a positive finite number of seconds." + case .keepaliveIntervalTooLong(let interval, let timeout): + return + "'keepalive_interval_seconds' (\(interval)) must be less than the server activity timeout (\(timeout) seconds)." + case .serverManagedActivityTimeout: + return + "'activity_timeout_seconds' is controlled by the server and cannot be set per activity." case .unknownCommand(let command): return "Unknown command: \(command)." case .unknownActivity: return "Unknown activity ID." case .socketPathTooLong: return "The local API socket path is too long." diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index e9ac64f..1474c00 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -44,8 +44,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { }() private var activeAnimations: [String: ActiveAnimation] = [:] private var lifecycle = ActivityLifecycle() - private var activityTimeout: TimeInterval = 5 - private var keepaliveInterval: TimeInterval = 5 + private var activityTimeout: TimeInterval = 30 private var activityTimeouts: [UUID: TimeInterval] = [:] private var activityStartOrder: [UUID: UInt64] = [:] private var nextActivityStartOrder: UInt64 = 0 @@ -312,7 +311,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { NyathingLog.report(error, context: "Unable to configure login launch") } activityTimeout = configuration.activityTimeout - keepaliveInterval = configuration.keepaliveInterval defaultAnimation = configuration.defaultAnimation try startAPIServer() } catch { @@ -335,7 +333,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let generation = apiGeneration apiServer = LocalAPIServer( defaultAnimation: defaultAnimation, - defaultKeepaliveInterval: keepaliveInterval, defaultActivityTimeout: activityTimeout, onStart: { [weak self] filename, description, timeout in try DispatchQueue.main.sync { diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index af0189b..71878a9 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -196,6 +196,7 @@ final class ConfigurationTests: XCTestCase { func testFirstLaunchSeedsConfigurationAndSampleAnimation() throws { let configuration = try AppConfiguration.load(in: temporaryDirectory) XCTAssertEqual(configuration.keepaliveInterval, 5) + XCTAssertEqual(configuration.activityTimeout, 30) XCTAssertEqual(configuration.defaultAnimation, "nyathing_36x36.png") XCTAssertTrue( FileManager.default.fileExists( @@ -236,7 +237,7 @@ final class ConfigurationTests: XCTestCase { let configuration = try AppConfiguration.load(in: temporaryDirectory) XCTAssertEqual(configuration.keepaliveInterval, 5) - XCTAssertEqual(configuration.activityTimeout, 5) + XCTAssertEqual(configuration.activityTimeout, 30) XCTAssertFalse(configuration.autoStart) let savedConfig = try String( contentsOf: temporaryDirectory.appendingPathComponent("config.toml"), encoding: .utf8) @@ -268,7 +269,7 @@ final class ConfigurationTests: XCTestCase { try writeConfiguration( AppConfiguration.template.replacingOccurrences( - of: "activity_timeout_seconds = 5", with: "activity_timeout_seconds = 0")) + of: "activity_timeout_seconds = 30", with: "activity_timeout_seconds = 0")) XCTAssertThrowsError(try AppConfiguration.load(in: temporaryDirectory)) } @@ -409,12 +410,32 @@ final class LocalAPIServerTests: XCTestCase { defer { server.stop() } let first = try UnixJSONClient(path: socketPath) + let missingInterval = try first.command(["command": "start"]) + XCTAssertEqual(missingInterval["ok"] as? Bool, false) + XCTAssertTrue((missingInterval["error"] as? String)?.contains("required") == true) + let nonPositiveInterval = try first.command([ + "command": "start", "keepalive_interval_seconds": 0, + ]) + XCTAssertEqual(nonPositiveInterval["ok"] as? Bool, false) + XCTAssertTrue( + (nonPositiveInterval["error"] as? String)?.contains("positive finite number") == true) + let invalidInterval = try first.command([ + "command": "start", "keepalive_interval_seconds": 30, + ]) + XCTAssertEqual(invalidInterval["ok"] as? Bool, false) + XCTAssertTrue((invalidInterval["error"] as? String)?.contains("must be less") == true) + let clientTimeoutOverride = try first.command([ + "command": "start", "keepalive_interval_seconds": 5, "activity_timeout_seconds": 10, + ]) + XCTAssertEqual(clientTimeoutOverride["ok"] as? Bool, false) + XCTAssertTrue( + (clientTimeoutOverride["error"] as? String)?.contains("controlled by the server") == true) let firstStart = try first.command([ "command": "start", "animation": "same_36x36.png", "description": "first client", - "keepalive_interval_seconds": 8, "activity_timeout_seconds": 10, + "keepalive_interval_seconds": 8, ]) XCTAssertEqual(firstStart["activity_id"] as? String, "activity-1") - XCTAssertEqual(firstStart["keepalive_interval_seconds"] as? Double, 5) + XCTAssertNil(firstStart["keepalive_interval_seconds"]) XCTAssertEqual( try first.command(["command": "keepalive", "activity_id": "activity-1"])["ok"] as? Bool, true) @@ -422,18 +443,21 @@ final class LocalAPIServerTests: XCTestCase { try first.command(["command": "stop", "activity_id": "activity-1"])["ok"] as? Bool, true) let second = try UnixJSONClient(path: socketPath) - let secondStart = try second.command(["command": "start", "animation": "same_36x36.png"]) + let secondStart = try second.command([ + "command": "start", "animation": "same_36x36.png", "keepalive_interval_seconds": 5, + ]) XCTAssertEqual(secondStart["activity_id"] as? String, "activity-2") - XCTAssertEqual(secondStart["keepalive_interval_seconds"] as? Double, 2.5) + XCTAssertNil(secondStart["keepalive_interval_seconds"]) XCTAssertEqual( - try second.command(["command": "start"])["activity_id"] as? String, + try second.command(["command": "start", "keepalive_interval_seconds": 1])["activity_id"] + as? String, "activity-3") lock.lock() XCTAssertEqual( startedAnimations, ["same_36x36.png", "same_36x36.png", "nyan_54x36.png"]) XCTAssertEqual(stoppedIDs, ["activity-1"]) XCTAssertEqual(startedDescriptions, ["first client", nil, nil]) - XCTAssertEqual(startedTimeouts, [10, 5, 5]) + XCTAssertEqual(startedTimeouts, [30, 30, 30]) lock.unlock() let responseLock = NSLock() @@ -441,7 +465,10 @@ final class LocalAPIServerTests: XCTestCase { DispatchQueue.concurrentPerform(iterations: 4) { _ in let result = (try? UnixJSONClient(path: socketPath) - .command(["command": "start", "animation": "other_36x36.png"])["ok"] as? Bool) ?? false + .command([ + "command": "start", "animation": "other_36x36.png", + "keepalive_interval_seconds": 5, + ])["ok"] as? Bool) ?? false responseLock.lock() concurrentResults.append(result) responseLock.unlock() From 02c955d4f2f4784f545a5916f60134098afad22a Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 19:22:36 +0400 Subject: [PATCH 21/43] Add a visual configuration editor Replace manual configuration reload with a form for editing settings. Save changes to config.toml and reload settings and animations on accept. Allow random as the configured default animation and update the README. --- README.md | 35 ++-- Sources/Nyathing/Configuration.swift | 16 +- Sources/Nyathing/main.swift | 188 ++++++++++++++++-- .../ConfigurationAndAPITests.swift | 11 + 4 files changed, 210 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 9063f99..7851bce 100644 --- a/README.md +++ b/README.md @@ -172,20 +172,22 @@ keepalive_interval_seconds = 5 activity_timeout_seconds = 30 # Whether to launch Nyathing automatically when you log in. auto_start = false -# Animation filename used when a client omits the animation field. +# Animation filename (or "random") used when a client omits the animation field. default_animation = "nyathing_36x36.png" ``` Keep all four settings in your `config.toml`; Nyathing does not fill in omitted settings. Set `auto_start` to `true` or `false`; both durations must be positive numbers, and `keepalive_interval_seconds` must be less than -`activity_timeout_seconds`. Set `default_animation` to the filename of a valid -animation in the `animations/` directory. Requests with an explicit animation -use it; missing or unavailable requested animations fall back to the built-in -ghost. -Use **Reload Configuration and Animations** in the menu after changing -configuration or animation files. Reload clears active client activities and -the disconnected-client count. +`activity_timeout_seconds`. Set `default_animation` to a valid filename in +`animations/` or to `random` to select a random valid animation per activity. +Requests with an explicit animation use it; missing or unavailable requested +animations fall back to the built-in ghost. +Choose **Edit Configuration** from the menu to change these settings with +visual controls. **Accept** saves the configuration and reloads settings and +animations; this also clears active activities and the disconnected-client +count. **Cancel** closes the editor without applying changes. Accepting the +current settings also reloads animation files changed outside the editor. ## {} Server communication protocol @@ -317,14 +319,15 @@ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client: ## Launch at login -Set `auto_start = true` in `config.toml`, then choose **Reload Configuration and -Animations** from Nyathing's menu. Nyathing installs its own LaunchAgent in +In the **Edit Configuration** window, enable **Launch Nyathing at login** and +click **Accept**. Nyathing installs its own LaunchAgent in `~/Library/LaunchAgents`; it will start automatically at your next login. No manual `launchctl` commands are needed. -Set `auto_start = false` and reload to remove the LaunchAgent. If you move -`Nyathing.app`, enable auto-start again and reload so the LaunchAgent records -the app's new location. +Disable **Launch Nyathing at login** in **Edit Configuration** and click +**Accept** to remove the LaunchAgent. If you move +`Nyathing.app`, enable auto-start again and click **Accept** so the LaunchAgent +records the app's new location. ## ⚡︎ Troubleshooting @@ -332,10 +335,10 @@ Startup and runtime diagnostics are written to `$XDG_STATE_HOME/nyathing/nyathing.log`, or `~/.local/state/nyathing/nyathing.log` when `XDG_STATE_HOME` is unset. Startup errors show an alert with an **Open Log** button. Configuration errors also -offer **Open Configuration**; animation errors offer **Open Animations Folder**. +offer **Open Configuration**. Invalid animation files are logged and ignored. If the socket path is already in use, quit the existing instance before -launching another. Invalid animation files are reported in the log; correct -them and reload. +launching another. After correcting animation files, click **Accept** in the +**Edit Configuration** window to reload them. ## ⚒ Build from source diff --git a/Sources/Nyathing/Configuration.swift b/Sources/Nyathing/Configuration.swift index 5836016..87415ef 100644 --- a/Sources/Nyathing/Configuration.swift +++ b/Sources/Nyathing/Configuration.swift @@ -15,7 +15,7 @@ struct AppConfiguration { activity_timeout_seconds = 30 # Whether Nyathing should launch automatically when you log in. auto_start = false - # Animation filename used when a client omits the animation field. + # Animation filename (or "random") used when a client omits the animation field. default_animation = "nyathing_36x36.png" """ @@ -152,12 +152,14 @@ struct AppConfiguration { throw ConfigError.invalidValue("default_animation") } let defaultAnimation = String(rawAnimation.dropFirst().dropLast()) - guard !defaultAnimation.contains("/"), !defaultAnimation.contains("\\"), - (try? SpriteAnimation.load( - from: animationsDirectory.appendingPathComponent( - defaultAnimation))) != nil - else { - throw ConfigError.invalidValue("default_animation") + if defaultAnimation != "random" { + guard !defaultAnimation.contains("/"), !defaultAnimation.contains("\\"), + (try? SpriteAnimation.load( + from: animationsDirectory.appendingPathComponent( + defaultAnimation))) != nil + else { + throw ConfigError.invalidValue("default_animation") + } } return AppConfiguration( keepaliveInterval: try number("keepalive_interval_seconds"), diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 1474c00..6d864c9 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -25,7 +25,7 @@ private func runNyathingApplication(serverMode: Bool) { application.run() } -final class AppDelegate: NSObject, NSApplicationDelegate { +final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private let serverMode: Bool init(serverMode: Bool = false) { @@ -53,6 +53,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate { private var apiGeneration = 0 private var errorsWindow: NSWindow? private var errorsStackView: NSStackView? + private var configurationWindow: NSWindow? + private var keepaliveIntervalField: NSTextField? + private var activityTimeoutField: NSTextField? + private var autoStartCheckbox: NSButton? + private var defaultAnimationPicker: NSPopUpButton? func applicationDidFinishLaunching(_ notification: Notification) { let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) @@ -89,10 +94,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { withTitle: "View Errors", action: #selector(viewErrors), keyEquivalent: "") } menu.addItem( - withTitle: "Reload Configuration and Animations", action: #selector(reloadFromMenu), - keyEquivalent: "") - menu.addItem( - withTitle: "Open Configuration", action: #selector(openConfiguration), keyEquivalent: "") + withTitle: "Edit Configuration", action: #selector(editConfiguration), keyEquivalent: "") menu.addItem(.separator()) menu.addItem(withTitle: "About", action: #selector(showAbout), keyEquivalent: "") menu.addItem(.separator()) @@ -108,8 +110,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let font = NSFont.menuFont(ofSize: 0) let widestActionTitle = [ - "View Errors", "Reload Configuration and Animations", - "Open Configuration", "About", "Quit", + "View Errors", "Edit Configuration", "About", "Quit", ].map { ($0 as NSString).size(withAttributes: [.font: font]).width }.max() ?? 0 let iconColumnWidth: CGFloat = 16 let horizontalMenuPadding: CGFloat = 16 @@ -277,20 +278,173 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } } - @objc private func reloadFromMenu() { - reloadConfigurationAndAnimations() + @objc private func editConfiguration() { + if let configurationWindow { + configurationWindow.makeKeyAndOrderFront(nil) + NSApp.activate(ignoringOtherApps: true) + return + } + + let configuration: AppConfiguration + do { + configuration = try AppConfiguration.load() + } catch { + showConfigurationEditorError(error.localizedDescription) + return + } + + let animationDirectory = AppConfiguration.configurationDirectory + .appendingPathComponent("animations", isDirectory: true) + let animationNames = ["random"] + SpriteAnimation.loadAll(in: animationDirectory).keys.sorted() + guard !animationNames.isEmpty else { + showConfigurationEditorError("No valid animations are available.") + return + } + + let intervalField = NSTextField(string: String(configuration.keepaliveInterval)) + let timeoutField = NSTextField(string: String(configuration.activityTimeout)) + intervalField.placeholderString = "Seconds" + timeoutField.placeholderString = "Seconds" + intervalField.alignment = .right + timeoutField.alignment = .right + intervalField.widthAnchor.constraint(equalToConstant: 130).isActive = true + timeoutField.widthAnchor.constraint(equalToConstant: 130).isActive = true + + let animationPicker = NSPopUpButton() + animationPicker.addItems(withTitles: animationNames) + animationPicker.selectItem(withTitle: configuration.defaultAnimation) + + let autoStart = NSButton( + checkboxWithTitle: "Launch Nyathing at login", target: self, action: nil) + autoStart.state = configuration.autoStart ? .on : .off + + func row(_ title: String, control: NSView) -> NSStackView { + let label = NSTextField(labelWithString: title) + label.widthAnchor.constraint(equalToConstant: 190).isActive = true + let row = NSStackView(views: [label, control]) + row.orientation = .horizontal + row.alignment = .centerY + row.spacing = 12 + return row + } + + let fields = NSStackView(views: [ + row("Keepalive interval (seconds)", control: intervalField), + row("Activity timeout (seconds)", control: timeoutField), + row("Default animation", control: animationPicker), + autoStart, + ]) + fields.orientation = .vertical + fields.alignment = .leading + fields.spacing = 14 + fields.translatesAutoresizingMaskIntoConstraints = false + + let cancelButton = NSButton( + title: "Cancel", target: self, action: #selector(cancelConfigurationEdit)) + let acceptButton = NSButton( + title: "Accept", target: self, action: #selector(acceptConfigurationEdit)) + acceptButton.keyEquivalent = "\\r" + let buttons = NSStackView(views: [cancelButton, acceptButton]) + buttons.orientation = .horizontal + buttons.alignment = .centerY + buttons.spacing = 8 + buttons.translatesAutoresizingMaskIntoConstraints = false + + let content = NSView() + content.addSubview(fields) + content.addSubview(buttons) + NSLayoutConstraint.activate([ + fields.leadingAnchor.constraint(equalTo: content.leadingAnchor, constant: 20), + fields.trailingAnchor.constraint(lessThanOrEqualTo: content.trailingAnchor, constant: -20), + fields.topAnchor.constraint(equalTo: content.topAnchor, constant: 20), + buttons.trailingAnchor.constraint(equalTo: content.trailingAnchor, constant: -20), + buttons.bottomAnchor.constraint(equalTo: content.bottomAnchor, constant: -16), + fields.bottomAnchor.constraint(lessThanOrEqualTo: buttons.topAnchor, constant: -18), + ]) + + let window = NSWindow( + contentRect: NSRect(x: 0, y: 0, width: 430, height: 230), + styleMask: [.titled, .closable], backing: .buffered, defer: false) + window.title = "Edit Configuration" + window.isReleasedWhenClosed = false + window.delegate = self + window.contentView = content + configurationWindow = window + keepaliveIntervalField = intervalField + activityTimeoutField = timeoutField + autoStartCheckbox = autoStart + defaultAnimationPicker = animationPicker + window.center() + window.makeKeyAndOrderFront(nil) + NSApp.activate(ignoringOtherApps: true) } - @objc private func openConfiguration() { - let url = AppConfiguration.configurationDirectory.appendingPathComponent("config.toml") - guard NSWorkspace.shared.open(url) else { - NyathingLog.report( - NSError( - domain: "Nyathing", code: 1, - userInfo: [NSLocalizedDescriptionKey: "Unable to open configuration at \(url.path)"]), - context: "Unable to open configuration") + @objc private func cancelConfigurationEdit() { + configurationWindow?.close() + } + + @objc private func acceptConfigurationEdit() { + guard let intervalField = keepaliveIntervalField, + let timeoutField = activityTimeoutField, + let autoStartCheckbox, + let defaultAnimationPicker, + let animation = defaultAnimationPicker.titleOfSelectedItem + else { return } + + guard let interval = Double(intervalField.stringValue), interval.isFinite, interval > 0 else { + showConfigurationEditorError("Keepalive interval must be a positive finite number.") + return + } + guard let timeout = Double(timeoutField.stringValue), timeout.isFinite, timeout > 0 else { + showConfigurationEditorError("Activity timeout must be a positive finite number.") + return + } + guard interval < timeout else { + showConfigurationEditorError( + "Keepalive interval must be less than the activity timeout.") return } + + let configurationText = """ + # Seconds between client keepalive messages; must be less than the server timeout. + keepalive_interval_seconds = \(interval) + # Server-side seconds without a keepalive before an activity expires. + activity_timeout_seconds = \(timeout) + # Whether Nyathing should launch automatically when you log in. + auto_start = \(autoStartCheckbox.state == .on ? "true" : "false") + # Animation filename used when a client omits the animation field. + default_animation = "\(animation)" + """ + + let configurationURL = AppConfiguration.configurationDirectory + .appendingPathComponent("config.toml") + do { + try configurationText.write(to: configurationURL, atomically: true, encoding: .utf8) + } catch { + showConfigurationEditorError(error.localizedDescription) + return + } + + configurationWindow?.close() + reloadConfigurationAndAnimations() + } + + private func showConfigurationEditorError(_ message: String) { + let alert = NSAlert() + alert.alertStyle = .warning + alert.messageText = "Unable to Apply Configuration" + alert.informativeText = message + alert.addButton(withTitle: "OK") + alert.runModal() + } + + func windowWillClose(_ notification: Notification) { + guard (notification.object as? NSWindow) === configurationWindow else { return } + configurationWindow = nil + keepaliveIntervalField = nil + activityTimeoutField = nil + autoStartCheckbox = nil + defaultAnimationPicker = nil } private func reloadConfigurationAndAnimations() { diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 71878a9..bbfd6f7 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -224,6 +224,17 @@ final class ConfigurationTests: XCTestCase { XCTAssertEqual(matrix.frames.count, 16) } + func testRandomIsAcceptedAsDefaultAnimation() throws { + let configurationText = AppConfiguration.template.replacingOccurrences( + of: "default_animation = \"nyathing_36x36.png\"", + with: "default_animation = \"random\"") + try writeConfiguration(configurationText) + + let configuration = try AppConfiguration.load(in: temporaryDirectory) + + XCTAssertEqual(configuration.defaultAnimation, "random") + } + func testRemovesObsoleteIconSettingAndKeepsDefaultAnimation() throws { let oldTemplate = AppConfiguration.template .replacingOccurrences( From e3a2a5e6b5e7176969ebde4bfc5ab5c6c72aeeff Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 19:35:03 +0400 Subject: [PATCH 22/43] Generalize animation sprite frame dimensions Derive frame sizes from filename suffixes instead of a fixed size list. Bound frame dimensions, aspect ratio, frame count, and sprite sheet pixels before decoding, and document the expanded format. --- README.md | 13 ++-- Sources/Nyathing/Configuration.swift | 62 ++++++++++++++----- .../ConfigurationAndAPITests.swift | 42 +++++++++++++ 3 files changed, 97 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 7851bce..35da1db 100644 --- a/README.md +++ b/README.md @@ -141,11 +141,14 @@ completing an animation argument, so the suggestions reflect installed files. ## Animation file format -Animation files are single horizontal PNG sprite sheets. Supported frame sizes -are 36x36 and 54x36 pixels; image height must equal the frame height and image -width must be a positive multiple of it. Name files with the frame size suffix, -for example `nyan_54x36.png`. The app validates assets on startup and reload; -invalid assets are ignored and logged. Playback runs at 10 frames per second. +Animation files are horizontal PNG sprite sheets. The filename suffix declares +the dimensions of each frame, for example `nyan_64x48.png`. Each dimension must +be between 16 and 256 pixels, with an aspect ratio no greater than 3:1. The +image height must match the declared frame height, and its width must be a +positive multiple of the declared frame width. Sheets may contain at most 120 +frames and 4 million pixels total. Frames are scaled to fit the menu bar. The +app validates assets on startup and when settings are accepted; invalid assets +are ignored and logged. Playback runs at 10 frames per second. ## ⚙ Configuration diff --git a/Sources/Nyathing/Configuration.swift b/Sources/Nyathing/Configuration.swift index 87415ef..7a99032 100644 --- a/Sources/Nyathing/Configuration.swift +++ b/Sources/Nyathing/Configuration.swift @@ -204,40 +204,61 @@ struct SpriteAnimation { let frameSize: NSSize let frames: [NSImage] + static let minimumFrameDimension = 16 + static let maximumFrameDimension = 256 + static let maximumFrameAspectRatio = 3.0 + static let maximumFrameCount = 120 + static let maximumSpriteSheetPixels = 4_000_000 + static func load(from url: URL) throws -> SpriteAnimation { let filename = url.lastPathComponent - let pattern = #"^(.+)_((?:36x36)|(?:54x36))\.png$"# + let pattern = #"^(.+)_([0-9]+)x([0-9]+)\.png$"# guard let regex = try? NSRegularExpression(pattern: pattern, options: [.caseInsensitive]), let match = regex.firstMatch( in: filename, range: NSRange(filename.startIndex..., in: filename)), - let sizeRange = Range(match.range(at: 2), in: filename) + let widthRange = Range(match.range(at: 2), in: filename), + let heightRange = Range(match.range(at: 3), in: filename), + let frameWidth = Int(filename[widthRange]), + let frameHeight = Int(filename[heightRange]) else { throw AnimationError.invalidFilename(filename) } - let sizeName = filename[sizeRange].lowercased() - let size: NSSize = - sizeName == "36x36" ? NSSize(width: 36, height: 36) : NSSize(width: 54, height: 36) + let frameSize = NSSize(width: frameWidth, height: frameHeight) + let dimensionsAreInRange = + (Self.minimumFrameDimension...Self.maximumFrameDimension).contains(frameWidth) + && (Self.minimumFrameDimension...Self.maximumFrameDimension).contains(frameHeight) + let aspectRatio = Double(max(frameWidth, frameHeight)) / Double(min(frameWidth, frameHeight)) + guard dimensionsAreInRange, aspectRatio <= Self.maximumFrameAspectRatio else { + throw AnimationError.unsupportedFrameSize(filename, frameWidth, frameHeight) + } guard let source = CGImageSourceCreateWithURL(url as CFURL, nil), - let image = CGImageSourceCreateImageAtIndex(source, 0, nil) + let properties = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [CFString: Any], + let width = (properties[kCGImagePropertyPixelWidth] as? NSNumber)?.intValue, + let height = (properties[kCGImagePropertyPixelHeight] as? NSNumber)?.intValue else { throw AnimationError.invalidPNG(filename) } - let width = image.width - let height = image.height - let frameWidth = Int(size.width) - let frameHeight = Int(size.height) guard height == frameHeight, width > 0, width % frameWidth == 0 else { throw AnimationError.invalidDimensions(filename, width, height) } - let sheet = NSImage(cgImage: image, size: NSSize(width: width, height: height)) + let frameCount = width / frameWidth + guard frameCount <= Self.maximumFrameCount else { + throw AnimationError.tooManyFrames(filename, frameCount, Self.maximumFrameCount) + } + guard width <= Self.maximumSpriteSheetPixels / height else { + throw AnimationError.spriteSheetTooLarge( + filename, width, height, Self.maximumSpriteSheetPixels) + } + guard let image = CGImageSourceCreateImageAtIndex(source, 0, nil) else { + throw AnimationError.invalidPNG(filename) + } var frames: [NSImage] = [] - for index in 0..<(width / frameWidth) { + for index in 0.. [String: SpriteAnimation] { @@ -272,13 +293,24 @@ enum AnimationResolution { enum AnimationError: LocalizedError { case invalidFilename(String) case invalidPNG(String) + case unsupportedFrameSize(String, Int, Int) case invalidDimensions(String, Int, Int) + case tooManyFrames(String, Int, Int) + case spriteSheetTooLarge(String, Int, Int, Int) var errorDescription: String? { switch self { case .invalidFilename(let name): return "Unrecognized animation filename: \(name)" case .invalidPNG(let name): return "Unable to decode PNG animation: \(name)" + case .unsupportedFrameSize(let name, let width, let height): + return + "Unsupported frame size for \(name): \(width)x\(height). Dimensions must be between 16 and 256 pixels with an aspect ratio no greater than 3:1." case .invalidDimensions(let name, let width, let height): return "Invalid sprite dimensions for \(name): \(width)x\(height)" + case .tooManyFrames(let name, let count, let maximum): + return "Too many frames in \(name): \(count); maximum is \(maximum)." + case .spriteSheetTooLarge(let name, let width, let height, let maximumPixels): + return + "Sprite sheet \(name) is too large (\(width)x\(height)); maximum is \(maximumPixels) pixels." } } } diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index bbfd6f7..ea2a8bd 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -1,3 +1,4 @@ +import AppKit import Darwin import Foundation import XCTest @@ -235,6 +236,34 @@ final class ConfigurationTests: XCTestCase { XCTAssertEqual(configuration.defaultAnimation, "random") } + func testLoadsAnimationWithFrameDimensionsFromFilename() throws { + let url = temporaryDirectory.appendingPathComponent("wide_64x48.png") + try writePNG(width: 128, height: 48, to: url) + + let animation = try SpriteAnimation.load(from: url) + + XCTAssertEqual(animation.frameSize, NSSize(width: 64, height: 48)) + XCTAssertEqual(animation.frames.count, 2) + } + + func testRejectsFrameDimensionsOutsideSupportedBounds() { + for filename in ["small_15x36.png", "large_257x36.png", "wide_256x16.png"] { + XCTAssertThrowsError( + try SpriteAnimation.load(from: URL(fileURLWithPath: "/tmp/\(filename)")), + filename) + } + } + + func testRejectsOversizedSpriteSheetsAndExcessiveFrameCounts() throws { + let oversized = temporaryDirectory.appendingPathComponent("large_256x256.png") + try writePNG(width: 256 * 62, height: 256, to: oversized) + XCTAssertThrowsError(try SpriteAnimation.load(from: oversized)) + + let tooManyFrames = temporaryDirectory.appendingPathComponent("many_16x16.png") + try writePNG(width: 16 * 121, height: 16, to: tooManyFrames) + XCTAssertThrowsError(try SpriteAnimation.load(from: tooManyFrames)) + } + func testRemovesObsoleteIconSettingAndKeepsDefaultAnimation() throws { let oldTemplate = AppConfiguration.template .replacingOccurrences( @@ -284,6 +313,19 @@ final class ConfigurationTests: XCTestCase { XCTAssertThrowsError(try AppConfiguration.load(in: temporaryDirectory)) } + private func writePNG(width: Int, height: Int, to url: URL) throws { + guard + let bitmap = NSBitmapImageRep( + bitmapDataPlanes: nil, pixelsWide: width, pixelsHigh: height, bitsPerSample: 8, + samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, + bytesPerRow: 0, bitsPerPixel: 0), + let data = bitmap.representation(using: .png, properties: [:]) + else { + throw NSError(domain: "ConfigurationTests", code: 1) + } + try data.write(to: url) + } + private func writeConfiguration(_ contents: String) throws { try FileManager.default.createDirectory( at: temporaryDirectory.appendingPathComponent("animations"), From 7546780a15e02eac9b3da2f4fac73d5031960e70 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 20:02:21 +0400 Subject: [PATCH 23/43] Resolve animation names and file paths Look up short animation names in the configured animations folder, selecting the largest valid matching frame. Treat other animation values as file paths and load sprite sheets outside that folder. Update API defaults, examples, and the test-animation script for path handling, and cover short-name and external-file resolution. --- README.md | 38 +++++---- Scripts/run-test-animation.py | 8 +- Sources/Nyathing/CLI.swift | 83 ++++++++++++++----- Sources/Nyathing/main.swift | 42 ++++++---- .../ConfigurationAndAPITests.swift | 35 ++++++-- 5 files changed, 147 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 35da1db..0ee2b0e 100644 --- a/README.md +++ b/README.md @@ -81,20 +81,20 @@ custom animation: nyathing --animation nyan sleep 5 ``` -`--animation` (or `-a`) selects an animation from Nyathing's user animation -directory. You can use the short name before the frame-size suffix and `.png` -(for example, `nyan` instead of `nyan_54x36.png`). If both `nyan_36x36.png` -and `nyan_54x36.png` exist, Nyathing chooses the larger `54x36` animation. -Without `--animation`, the CLI uses `nyathing_36x36.png`, regardless of the -configured server default. +`--animation` (or `-a`) selects an animation. A short name without the frame +size suffix or `.png` (for example, `nyan`) is looked up in Nyathing's user +animation directory. If multiple valid files share that name, Nyathing chooses +the frame with the largest pixel area. Any other value is treated as a path to +an animation file; relative paths are resolved from the current directory. +Without `--animation`, the CLI uses the short name `nyathing`, regardless of +the configured server default. Set `--animation` to `random` to choose a random valid animation from the user animations directory for that run. -If a valid `random_36x36.png` or `random_54x36.png` exists, Nyathing plays that -named animation, preferring `54x36` when both are available. Otherwise, it -chooses randomly from the valid user animations. If none are available, Nyathing -uses its built-in ghost animation: +If valid files named `random_x.png` exist, Nyathing plays the +largest matching animation. Otherwise, it chooses randomly from valid user +animations. If none are available, Nyathing uses its built-in ghost animation: ```sh nyathing --animation random sleep 5 @@ -225,18 +225,24 @@ messages are supported: | Field | Type | Required | Description | | --- | --- | --- | --- | | `command` | string | Yes | Must be `start`. | -| `animation` | string | No | Animation filename. Defaults to the server's configured animation; unavailable or invalid names use the built-in ghost. | +| `animation` | string | No | Short name searched in the server's animation directory, or a path to a PNG sprite sheet. Defaults to the server's configured animation. Invalid explicit values return an error. | | `description` | string | No | Description shown for the activity. If omitted or not a string, the server uses its default description. | | `keepalive_interval_seconds` | number | Yes | Positive, finite interval in seconds at which the client sends keepalives. Must be less than the server's configured `activity_timeout_seconds`. | +A short name without a frame-size suffix or `.png` is resolved in the server's +animation directory. Other values are treated as file paths; relative paths +are resolved from the server process's current working directory. `random` +selects a random valid animation, falling back to the built-in ghost if none +are available. + Examples: ```json -{"command":"start","animation":"nyan_54x36.png","keepalive_interval_seconds":5} +{"command":"start","animation":"nyan","keepalive_interval_seconds":5} ``` or ```json -{"command":"start","animation":"nyan_54x36.png","description":"make test","keepalive_interval_seconds":5} +{"command":"start","animation":"nyan","description":"make test","keepalive_interval_seconds":5} ``` #### `keepalive` request @@ -315,7 +321,11 @@ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client: stream.write(json.dumps(value).encode() + b"\n") stream.flush() return json.loads(stream.readline()) - activity = command({"command": "start", "animation": "nyan_54x36.png", "keepalive_interval_seconds": 5})["activity_id"] + activity = command({ + "command": "start", + "animation": "nyan", + "keepalive_interval_seconds": 5, + })["activity_id"] command({"command": "keepalive", "activity_id": activity}) command({"command": "stop", "activity_id": activity}) ``` diff --git a/Scripts/run-test-animation.py b/Scripts/run-test-animation.py index f8fdc67..d5a8cb9 100644 --- a/Scripts/run-test-animation.py +++ b/Scripts/run-test-animation.py @@ -75,9 +75,11 @@ def configured_seconds(text, key, default): timeout = configured_seconds(settings, "activity_timeout_seconds", 30.0) animations = os.environ.get("ANIMATIONS", "").replace(",", " ").split() if not animations: - animation = os.environ.get("ANIMATION") or configured_value( - settings, "default_animation", "nyathing_36x36.png" - ) + animation = os.environ.get("ANIMATION") + if animation is None: + animation = configured_value(settings, "default_animation", "nyathing_36x36.png") + if animation != "random": + animation = str(config_path.parent / "animations" / animation) animations = [animation] for animation in animations: activity_id = request({ diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index aa8e717..1347971 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -49,7 +49,7 @@ struct CLIArguments { \(version) Usage: - nyathing [--animation FILE | -a FILE] COMMAND [ARGUMENT ...] + nyathing [--animation NAME | -a NAME] COMMAND [ARGUMENT ...] nyathing uninstall nyathing server start|stop|status nyathing list @@ -65,19 +65,19 @@ struct CLIArguments { completion SHELL Print shell completion code for zsh or bash. Options: - -a, --animation FILE Select an animation from the user animations folder. + -a, --animation NAME Select a short animation name or path to a PNG. --help Show this help. --version Show the app version. Examples: nyathing sleep 5 - nyathing --animation nyan_54x36.png make test + nyathing --animation nyan make test """ } static func parse(_ arguments: [String]) throws -> CLIArguments { var values = arguments - var animation = "nyathing_36x36.png" + var animation = "nyathing" if values.first == "--animation" || values.first == "-a" { guard values.count >= 3, !values[1].isEmpty else { throw CLIError.usage } animation = values[1] @@ -241,23 +241,38 @@ enum NyathingCLI { } static func resolveAnimation(_ name: String, in directory: URL) throws -> String { - guard !name.contains("/"), !name.contains("\\") else { - throw CLIError.animationUnavailable( - name, "must be a filename, not a path. Use 'nyathing list' to see available animations.") - } if name == "random" { if let namedAnimation = try? resolveNamedAnimation(name, in: directory) { return namedAnimation } let available = SpriteAnimation.loadAll(in: directory) - return available.keys.sorted().randomElement() ?? builtInGhostAnimation + return available.keys.sorted().randomElement().map { + directory.appendingPathComponent($0).standardizedFileURL.path + } ?? builtInGhostAnimation + } + if isShortAnimationName(name) { + return try resolveNamedAnimation(name, in: directory) } - return try resolveNamedAnimation(name, in: directory) + let path = URL( + fileURLWithPath: (name as NSString).expandingTildeInPath, + relativeTo: URL(fileURLWithPath: FileManager.default.currentDirectoryPath) + ).standardizedFileURL + do { + _ = try SpriteAnimation.load(from: path) + return path.path + } catch { + throw CLIError.animationUnavailable( + name, "could not load animation file: \(error.localizedDescription).") + } + } + + private static func isShortAnimationName(_ name: String) -> Bool { + !name.contains("/") && !name.contains("\\") + && URL(fileURLWithPath: name).pathExtension.isEmpty + && name.range(of: #"_[0-9]+x[0-9]+$"#, options: .regularExpression) == nil } private static func resolveNamedAnimation(_ name: String, in directory: URL) throws -> String { - let stem = name.replacingOccurrences( - of: #"_(?:36x36|54x36)\.png$"#, with: "", options: [.caseInsensitive, .regularExpression]) guard let files = try? FileManager.default.contentsOfDirectory( at: directory, includingPropertiesForKeys: nil) @@ -267,22 +282,48 @@ enum NyathingCLI { "could not be checked because the animations directory is unavailable at \(directory.path)." ) } - for size in ["54x36", "36x36"] { - let expected = "\(stem)_\(size).png" + + let pattern = + "^\(NSRegularExpression.escapedPattern(for: name))_([0-9]+)x([0-9]+)\\.png$" + guard + let regex = try? NSRegularExpression(pattern: pattern, options: [.caseInsensitive]) + else { + throw CLIError.animationUnavailable(name, "could not be resolved to a filename.") + } + let candidates = files.compactMap { file -> (url: URL, width: Int, height: Int)? in + let filename = file.lastPathComponent guard - let file = files.first(where: { - $0.lastPathComponent.caseInsensitiveCompare(expected) == .orderedSame - }) - else { continue } + let match = regex.firstMatch( + in: filename, range: NSRange(filename.startIndex..., in: filename)), + let widthRange = Range(match.range(at: 1), in: filename), + let heightRange = Range(match.range(at: 2), in: filename), + let width = Int(filename[widthRange]), let height = Int(filename[heightRange]) + else { return nil } + return (file, width, height) + }.sorted { + let leftArea = Double($0.width) * Double($0.height) + let rightArea = Double($1.width) * Double($1.height) + if leftArea != rightArea { return leftArea > rightArea } + if $0.width != $1.width { return $0.width > $1.width } + return $0.url.lastPathComponent < $1.url.lastPathComponent + } + + var invalidAssetError: Error? + for candidate in candidates { do { - return try SpriteAnimation.load(from: file).filename + _ = try SpriteAnimation.load(from: candidate.url) + return candidate.url.standardizedFileURL.path } catch { - throw CLIError.animationUnavailable(name, "is invalid: \(error.localizedDescription).") + invalidAssetError = invalidAssetError ?? error } } + if let invalidAssetError { + throw CLIError.animationUnavailable( + name, "has no valid matching animation: \(invalidAssetError.localizedDescription).") + } throw CLIError.animationUnavailable( name, - "was not found in \(directory.path). Expected a valid '*_36x36.png' or '*_54x36.png' file. Use 'nyathing list' to see available animations." + "was not found in \(directory.path). Use 'nyathing list' to see available animations." ) } diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 6d864c9..51e0693 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -485,13 +485,19 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private func startAPIServer() throws { let generation = apiGeneration + let animationsDirectory = AppConfiguration.configurationDirectory + .appendingPathComponent("animations", isDirectory: true) + let serverDefaultAnimation = + defaultAnimation == "random" + ? defaultAnimation + : animationsDirectory.appendingPathComponent(defaultAnimation).standardizedFileURL.path apiServer = LocalAPIServer( - defaultAnimation: defaultAnimation, + defaultAnimation: serverDefaultAnimation, defaultActivityTimeout: activityTimeout, onStart: { [weak self] filename, description, timeout in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } - return self.startActivity( + return try self.startActivity( animation: filename, description: description, activityTimeout: timeout ).uuidString } @@ -534,14 +540,24 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { func startActivity( animation filename: String, description: String? = nil, activityTimeout timeout: TimeInterval? = nil - ) -> UUID { + ) throws -> UUID { let directory = AppConfiguration.configurationDirectory.appendingPathComponent( "animations", isDirectory: true) - let animations = SpriteAnimation.loadAll(in: directory) - let resolvedFilename = - filename == "random" - ? (try? NyathingCLI.resolveAnimation(filename, in: directory)) ?? filename - : filename + let resolvedFilename = try NyathingCLI.resolveAnimation(filename, in: directory) + let existingAnimation = activeAnimations[resolvedFilename] + let frames: [NSImage]? + if existingAnimation == nil { + let sourceFrames: [NSImage] + if resolvedFilename == NyathingCLI.builtInGhostAnimation { + sourceFrames = Self.builtInGhostFrames() + } else { + sourceFrames = try SpriteAnimation.load(from: URL(fileURLWithPath: resolvedFilename)).frames + } + frames = Self.scaledAnimationFrames(sourceFrames, height: 22) + } else { + frames = nil + } + let timeout = timeout ?? activityTimeout let deadline = DispatchTime.now() + timeout let deadlineUptime = deadline.uptimeNanoseconds @@ -551,7 +567,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { nextActivityStartOrder &+= 1 activityTimeouts[id] = timeout scheduleActivityExpiration(id, deadlineUptime: deadlineUptime) - if let active = activeAnimations[resolvedFilename] { + if let active = existingAnimation { active.activityIDs.insert(id) updateActivityStatus(active) updateMainStatusItemVisibility() @@ -560,13 +576,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { return id } - let frames: [NSImage] - let sourceFrames: [NSImage] - switch AnimationResolution.resolve(resolvedFilename, available: animations) { - case .asset(let animation): sourceFrames = animation.frames - case .builtInGhost: sourceFrames = Self.builtInGhostFrames() - } - frames = Self.scaledAnimationFrames(sourceFrames, height: 22) + guard let frames else { preconditionFailure("New animations must have decoded frames.") } let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) configureMenu(for: statusItem) let active = ActiveAnimation( diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index ea2a8bd..8d30e5a 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -46,11 +46,21 @@ final class CLITests: XCTestCase { _ = try AppConfiguration.load(in: directory) let animationsDirectory = directory.appendingPathComponent("animations", isDirectory: true) - XCTAssertNoThrow(try NyathingCLI.validateAnimation("nyan_54x36.png", in: animationsDirectory)) + XCTAssertNoThrow(try NyathingCLI.validateAnimation("nyan", in: animationsDirectory)) XCTAssertThrowsError( - try NyathingCLI.validateAnimation("missing_36x36.png", in: animationsDirectory)) + try NyathingCLI.validateAnimation("missing", in: animationsDirectory)) + + let externalDirectory = directory.appendingPathComponent("external") + try FileManager.default.createDirectory( + at: externalDirectory, withIntermediateDirectories: true) + let externalAnimation = externalDirectory.appendingPathComponent("outside_54x36.png") + try FileManager.default.copyItem( + at: animationsDirectory.appendingPathComponent("nyan_54x36.png"), to: externalAnimation) + XCTAssertNoThrow( + try NyathingCLI.validateAnimation(externalAnimation.path, in: animationsDirectory)) XCTAssertThrowsError( - try NyathingCLI.validateAnimation("../nyan_54x36.png", in: animationsDirectory)) + try NyathingCLI.validateAnimation( + externalAnimation.lastPathComponent, in: animationsDirectory)) } func testRandomAnimationSelectsFromAvailableAnimations() throws { @@ -64,7 +74,7 @@ final class CLITests: XCTestCase { let selected = try NyathingCLI.resolveAnimation("random", in: animationsDirectory) XCTAssertFalse(listedAnimations.isEmpty) - XCTAssertTrue(listedAnimations.contains(selected)) + XCTAssertTrue(listedAnimations.contains(URL(fileURLWithPath: selected).lastPathComponent)) } func testNamedRandomAnimationTakesPrecedence() throws { @@ -78,7 +88,8 @@ final class CLITests: XCTestCase { at: animationsDirectory.appendingPathComponent("nyathing_36x36.png"), to: randomAnimation) XCTAssertEqual( - try NyathingCLI.resolveAnimation("random", in: animationsDirectory), "random_36x36.png") + try NyathingCLI.resolveAnimation("random", in: animationsDirectory), + randomAnimation.standardizedFileURL.path) } func testRandomAnimationFallsBackToBuiltInGhostWhenPoolIsEmpty() throws { @@ -246,6 +257,20 @@ final class ConfigurationTests: XCTestCase { XCTAssertEqual(animation.frames.count, 2) } + func testShortAnimationNameResolvesLargestValidFrame() throws { + _ = try AppConfiguration.load(in: temporaryDirectory) + let animationsDirectory = temporaryDirectory.appendingPathComponent("animations") + let largerAnimation = animationsDirectory.appendingPathComponent("nyathing_64x48.png") + try writePNG(width: 128, height: 48, to: largerAnimation) + + XCTAssertEqual( + try NyathingCLI.resolveAnimation("nyathing", in: animationsDirectory), + largerAnimation.standardizedFileURL.path) + XCTAssertEqual( + try NyathingCLI.resolveAnimation("nyathing", in: animationsDirectory), + try NyathingCLI.resolveAnimation(largerAnimation.path, in: animationsDirectory)) + } + func testRejectsFrameDimensionsOutsideSupportedBounds() { for filename in ["small_15x36.png", "large_257x36.png", "wide_256x16.png"] { XCTAssertThrowsError( From f3e6f7197a18f0d9f0d5e65797d0a85ef715b0ba Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 20:47:42 +0400 Subject: [PATCH 24/43] List animations by short name --- README.md | 2 +- Sources/Nyathing/CLI.swift | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0ee2b0e..af712b8 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ animations. If none are available, Nyathing uses its built-in ghost animation: Quote paths containing spaces as usual in your shell. Relative command paths are resolved from the current working directory. -List valid installed animations with: +List valid installed animations by short name with: ```sh nyathing list diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 1347971..d639065 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -154,8 +154,13 @@ enum NyathingCLI { _ = try AppConfiguration.load() let directory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) - for filename in SpriteAnimation.loadAll(in: directory).keys.sorted() { - print(filename) + let names = SpriteAnimation.loadAll(in: directory).keys.compactMap { filename -> String? in + guard let separator = filename.range(of: #"_[0-9]+x[0-9]+\.png$"#, options: .regularExpression) + else { return nil } + return String(filename[.. Date: Fri, 20 Nov 2026 21:16:30 +0400 Subject: [PATCH 25/43] Revise activity keepalive timeout behavior --- README.md | 34 +++++------ Scripts/run-test-animation.py | 7 +-- Sources/Nyathing/CLI.swift | 8 ++- Sources/Nyathing/Configuration.swift | 35 +++++++---- Sources/Nyathing/LocalAPIServer.swift | 27 +++----- Sources/Nyathing/main.swift | 59 +++++++----------- .../ConfigurationAndAPITests.swift | 61 ++++++++++++------- 7 files changed, 115 insertions(+), 116 deletions(-) diff --git a/README.md b/README.md index af712b8..7849957 100644 --- a/README.md +++ b/README.md @@ -169,21 +169,20 @@ your files. The complete initial configuration is: ```toml -# Default interval at which clients send keepalives; must be less than the server timeout. -keepalive_interval_seconds = 5 -# Server-side seconds without a keepalive before an activity expires. -activity_timeout_seconds = 30 +# Maximum seconds to wait since the last client keepalive. +max_wait_time = 60 # Whether to launch Nyathing automatically when you log in. auto_start = false # Animation filename (or "random") used when a client omits the animation field. default_animation = "nyathing_36x36.png" ``` -Keep all four settings in your `config.toml`; Nyathing does not fill in omitted -settings. Set `auto_start` to `true` or `false`; both durations must be positive -numbers, and `keepalive_interval_seconds` must be less than -`activity_timeout_seconds`. Set `default_animation` to a valid filename in -`animations/` or to `random` to select a random valid animation per activity. +Keep all three settings in your `config.toml`; Nyathing does not fill in omitted +settings. Set `max_wait_time` to a positive number of seconds and `auto_start` +to `true` or `false`. Clients use a default keepalive interval of 5 seconds, +which they can override per activity. Activities expire after the smaller of +twice that interval and `max_wait_time`. Set `default_animation` to a valid +filename in `animations/` or to `random` to select a random animation per activity. Requests with an explicit animation use it; missing or unavailable requested animations fall back to the built-in ghost. Choose **Edit Configuration** from the menu to change these settings with @@ -227,7 +226,7 @@ messages are supported: | `command` | string | Yes | Must be `start`. | | `animation` | string | No | Short name searched in the server's animation directory, or a path to a PNG sprite sheet. Defaults to the server's configured animation. Invalid explicit values return an error. | | `description` | string | No | Description shown for the activity. If omitted or not a string, the server uses its default description. | -| `keepalive_interval_seconds` | number | Yes | Positive, finite interval in seconds at which the client sends keepalives. Must be less than the server's configured `activity_timeout_seconds`. | +| `keepalive_interval_seconds` | number | No | Positive, finite interval in seconds at which the client promises to send keepalives. Defaults to 5 seconds. The activity expires after the smaller of twice this interval and the server's configured `max_wait_time`. | A short name without a frame-size suffix or `.png` is resolved in the server's animation directory. Other values are treated as file paths; relative paths @@ -258,9 +257,9 @@ Example: {"command":"keepalive","activity_id":""} ``` -Send keepalives periodically, typically at the interval specified in the -`start` request. If the server does not receive one within the configured -`activity_timeout_seconds`, the activity expires and increments the +Send keepalives periodically at the interval specified in the `start` request. +If the server does not receive one within the smaller of twice that interval +and `max_wait_time`, the activity expires and increments the disconnected-client count. #### `stop` request @@ -297,11 +296,10 @@ A failed request returns an error response: ``` Errors include malformed requests, unknown commands or activity identifiers, -missing or invalid keepalive intervals, intervals not shorter than the server -timeout, per-activity timeout overrides, and oversized request lines. An -activity expires if the server does not receive a keepalive within its -configured timeout. Expiration increments the disconnected-client count; an explicit -`stop` does not. +invalid keepalive intervals, per-activity timeout overrides, and oversized +request lines. An activity expires after the smaller of twice its keepalive +interval and the configured `max_wait_time`. Expiration increments the +disconnected-client count; an explicit `stop` does not. ## ✦ Minimal Python client example diff --git a/Scripts/run-test-animation.py b/Scripts/run-test-animation.py index d5a8cb9..a276dda 100644 --- a/Scripts/run-test-animation.py +++ b/Scripts/run-test-animation.py @@ -48,10 +48,6 @@ def configured_value(text, key, default): return match.group(2) if match else default -def configured_seconds(text, key, default): - match = re.search(rf"^\s*{re.escape(key)}\s*=\s*([0-9.]+)", text, re.M) - return float(match.group(1)) if match else default - app = None started_here = False @@ -71,8 +67,7 @@ def configured_seconds(text, key, default): time.sleep(0.2) settings = config_path.read_text(encoding="utf-8") if config_path.exists() else "" - interval = configured_seconds(settings, "keepalive_interval_seconds", 5.0) - timeout = configured_seconds(settings, "activity_timeout_seconds", 30.0) + interval = 5.0 animations = os.environ.get("ANIMATIONS", "").replace(",", " ").split() if not animations: animation = os.environ.get("ANIMATION") diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index d639065..d2f2f66 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -155,7 +155,9 @@ enum NyathingCLI { let directory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) let names = SpriteAnimation.loadAll(in: directory).keys.compactMap { filename -> String? in - guard let separator = filename.range(of: #"_[0-9]+x[0-9]+\.png$"#, options: .regularExpression) + guard + let separator = filename.range( + of: #"_[0-9]+x[0-9]+\.png$"#, options: .regularExpression) else { return nil } return String(filename[.. Int32 { let executable = try resolveExecutable(cli.command) - let configuration = try AppConfiguration.load() + _ = try AppConfiguration.load() let animationsDirectory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) let animation = try resolveAnimation(cli.animation, in: animationsDirectory) - let keepaliveInterval = configuration.keepaliveInterval + let keepaliveInterval = LocalAPIServer.defaultKeepaliveInterval let client = try LocalAPIClient.connectOrStartServer() let activity = try client.command([ "command": "start", diff --git a/Sources/Nyathing/Configuration.swift b/Sources/Nyathing/Configuration.swift index 7a99032..878351e 100644 --- a/Sources/Nyathing/Configuration.swift +++ b/Sources/Nyathing/Configuration.swift @@ -3,16 +3,13 @@ import Foundation import ImageIO struct AppConfiguration { - let keepaliveInterval: TimeInterval - let activityTimeout: TimeInterval + let maxWaitTime: TimeInterval let autoStart: Bool let defaultAnimation: String static let template = """ - # Seconds between client keepalive messages; must be greater than zero. - keepalive_interval_seconds = 5 - # Server-side seconds without a keepalive before an activity expires. - activity_timeout_seconds = 30 + # Maximum seconds to wait since the last client keepalive. + max_wait_time = 60 # Whether Nyathing should launch automatically when you log in. auto_start = false # Animation filename (or "random") used when a client omits the animation field. @@ -81,6 +78,7 @@ struct AppConfiguration { } var text = try String(contentsOf: configURL, encoding: .utf8) var removedObsoleteSettings = false + var legacyMaxWaitTime: String? let obsoleteComments = [ "# Animate the app's icon instead of showing the static project logo.", "# Animate the app's main icon instead of showing the static logo.", @@ -95,6 +93,16 @@ struct AppConfiguration { let line = stripComment(from: rawLine).trimmingCharacters(in: .whitespaces) guard let equal = line.firstIndex(of: "=") else { return original } let key = line[.. String private let onKeepalive: (String) throws -> Void private let onStop: (String) throws -> Void @@ -17,13 +18,13 @@ final class LocalAPIServer { init( socketPath: String = LocalAPIServer.socketPath, defaultAnimation: String = "nyathing_36x36.png", - defaultActivityTimeout: TimeInterval = 30, + maxWaitTime: TimeInterval = 60, onStart: @escaping (String, String?, TimeInterval) throws -> String, onKeepalive: @escaping (String) throws -> Void, onStop: @escaping (String) throws -> Void ) { self.defaultAnimation = defaultAnimation - self.defaultActivityTimeout = defaultActivityTimeout + self.maxWaitTime = maxWaitTime self.onStart = onStart self.onKeepalive = onKeepalive self.onStop = onStop @@ -222,14 +223,13 @@ final class LocalAPIServer { guard request["activity_timeout_seconds"] == nil else { throw LocalAPIError.serverManagedActivityTimeout } - guard let rawKeepaliveInterval = request["keepalive_interval_seconds"] else { - throw LocalAPIError.missingKeepaliveInterval - } - let keepaliveInterval = try positiveSeconds(rawKeepaliveInterval) - let activityTimeout = defaultActivityTimeout - guard keepaliveInterval < activityTimeout else { - throw LocalAPIError.keepaliveIntervalTooLong(keepaliveInterval, activityTimeout) + let keepaliveInterval: TimeInterval + if let rawKeepaliveInterval = request["keepalive_interval_seconds"] { + keepaliveInterval = try positiveSeconds(rawKeepaliveInterval) + } else { + keepaliveInterval = Self.defaultKeepaliveInterval } + let activityTimeout = min(keepaliveInterval * 2, maxWaitTime) return [ "ok": true, "activity_id": try onStart( @@ -316,9 +316,7 @@ final class LocalAPIServer { enum LocalAPIError: LocalizedError { case unavailable case invalidRequest - case missingKeepaliveInterval case invalidKeepaliveInterval - case keepaliveIntervalTooLong(TimeInterval, TimeInterval) case serverManagedActivityTimeout case unknownCommand(String) case unknownActivity @@ -330,13 +328,8 @@ enum LocalAPIError: LocalizedError { switch self { case .unavailable: return "The local API is unavailable." case .invalidRequest: return "Invalid JSON Lines request." - case .missingKeepaliveInterval: - return "Missing required field 'keepalive_interval_seconds'." case .invalidKeepaliveInterval: return "'keepalive_interval_seconds' must be a positive finite number of seconds." - case .keepaliveIntervalTooLong(let interval, let timeout): - return - "'keepalive_interval_seconds' (\(interval)) must be less than the server activity timeout (\(timeout) seconds)." case .serverManagedActivityTimeout: return "'activity_timeout_seconds' is controlled by the server and cannot be set per activity." diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 51e0693..eea2518 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -44,7 +44,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { }() private var activeAnimations: [String: ActiveAnimation] = [:] private var lifecycle = ActivityLifecycle() - private var activityTimeout: TimeInterval = 30 + private var maxWaitTime: TimeInterval = 60 private var activityTimeouts: [UUID: TimeInterval] = [:] private var activityStartOrder: [UUID: UInt64] = [:] private var nextActivityStartOrder: UInt64 = 0 @@ -54,8 +54,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private var errorsWindow: NSWindow? private var errorsStackView: NSStackView? private var configurationWindow: NSWindow? - private var keepaliveIntervalField: NSTextField? - private var activityTimeoutField: NSTextField? + private var maxWaitTimeField: NSTextField? private var autoStartCheckbox: NSButton? private var defaultAnimationPicker: NSPopUpButton? @@ -301,14 +300,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { return } - let intervalField = NSTextField(string: String(configuration.keepaliveInterval)) - let timeoutField = NSTextField(string: String(configuration.activityTimeout)) - intervalField.placeholderString = "Seconds" - timeoutField.placeholderString = "Seconds" - intervalField.alignment = .right - timeoutField.alignment = .right - intervalField.widthAnchor.constraint(equalToConstant: 130).isActive = true - timeoutField.widthAnchor.constraint(equalToConstant: 130).isActive = true + let maxWaitTimeField = NSTextField(string: String(configuration.maxWaitTime)) + maxWaitTimeField.placeholderString = "Seconds" + maxWaitTimeField.alignment = .right + maxWaitTimeField.widthAnchor.constraint(equalToConstant: 130).isActive = true let animationPicker = NSPopUpButton() animationPicker.addItems(withTitles: animationNames) @@ -329,8 +324,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } let fields = NSStackView(views: [ - row("Keepalive interval (seconds)", control: intervalField), - row("Activity timeout (seconds)", control: timeoutField), + row("Maximum wait time (seconds)", control: maxWaitTimeField), row("Default animation", control: animationPicker), autoStart, ]) @@ -370,8 +364,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { window.delegate = self window.contentView = content configurationWindow = window - keepaliveIntervalField = intervalField - activityTimeoutField = timeoutField + self.maxWaitTimeField = maxWaitTimeField autoStartCheckbox = autoStart defaultAnimationPicker = animationPicker window.center() @@ -384,32 +377,22 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } @objc private func acceptConfigurationEdit() { - guard let intervalField = keepaliveIntervalField, - let timeoutField = activityTimeoutField, + guard let maxWaitTimeField, let autoStartCheckbox, let defaultAnimationPicker, let animation = defaultAnimationPicker.titleOfSelectedItem else { return } - guard let interval = Double(intervalField.stringValue), interval.isFinite, interval > 0 else { - showConfigurationEditorError("Keepalive interval must be a positive finite number.") - return - } - guard let timeout = Double(timeoutField.stringValue), timeout.isFinite, timeout > 0 else { - showConfigurationEditorError("Activity timeout must be a positive finite number.") - return - } - guard interval < timeout else { - showConfigurationEditorError( - "Keepalive interval must be less than the activity timeout.") + guard let maxWaitTime = Double(maxWaitTimeField.stringValue), + maxWaitTime.isFinite, maxWaitTime > 0 + else { + showConfigurationEditorError("Maximum wait time must be a positive finite number.") return } let configurationText = """ - # Seconds between client keepalive messages; must be less than the server timeout. - keepalive_interval_seconds = \(interval) - # Server-side seconds without a keepalive before an activity expires. - activity_timeout_seconds = \(timeout) + # Maximum seconds to wait since the last client keepalive. + max_wait_time = \(maxWaitTime) # Whether Nyathing should launch automatically when you log in. auto_start = \(autoStartCheckbox.state == .on ? "true" : "false") # Animation filename used when a client omits the animation field. @@ -441,8 +424,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { func windowWillClose(_ notification: Notification) { guard (notification.object as? NSWindow) === configurationWindow else { return } configurationWindow = nil - keepaliveIntervalField = nil - activityTimeoutField = nil + maxWaitTimeField = nil autoStartCheckbox = nil defaultAnimationPicker = nil } @@ -464,7 +446,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } catch { NyathingLog.report(error, context: "Unable to configure login launch") } - activityTimeout = configuration.activityTimeout + maxWaitTime = configuration.maxWaitTime defaultAnimation = configuration.defaultAnimation try startAPIServer() } catch { @@ -493,7 +475,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { : animationsDirectory.appendingPathComponent(defaultAnimation).standardizedFileURL.path apiServer = LocalAPIServer( defaultAnimation: serverDefaultAnimation, - defaultActivityTimeout: activityTimeout, + maxWaitTime: maxWaitTime, onStart: { [weak self] filename, description, timeout in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } @@ -558,7 +540,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { frames = nil } - let timeout = timeout ?? activityTimeout + let timeout = timeout ?? min(LocalAPIServer.defaultKeepaliveInterval * 2, maxWaitTime) let deadline = DispatchTime.now() + timeout let deadlineUptime = deadline.uptimeNanoseconds let id = lifecycle.start( @@ -671,7 +653,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } private func keepaliveActivity(_ id: UUID) -> Bool { - let deadline = DispatchTime.now() + (activityTimeouts[id] ?? activityTimeout) + let fallbackTimeout = min(LocalAPIServer.defaultKeepaliveInterval * 2, maxWaitTime) + let deadline = DispatchTime.now() + (activityTimeouts[id] ?? fallbackTimeout) let deadlineUptime = deadline.uptimeNanoseconds guard lifecycle.keepalive(id, deadline: deadlineUptime) else { return false } scheduleActivityExpiration(id, deadlineUptime: deadlineUptime) diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 8d30e5a..6c631d1 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -207,8 +207,7 @@ final class ConfigurationTests: XCTestCase { func testFirstLaunchSeedsConfigurationAndSampleAnimation() throws { let configuration = try AppConfiguration.load(in: temporaryDirectory) - XCTAssertEqual(configuration.keepaliveInterval, 5) - XCTAssertEqual(configuration.activityTimeout, 30) + XCTAssertEqual(configuration.maxWaitTime, 60) XCTAssertEqual(configuration.defaultAnimation, "nyathing_36x36.png") XCTAssertTrue( FileManager.default.fileExists( @@ -236,6 +235,22 @@ final class ConfigurationTests: XCTestCase { XCTAssertEqual(matrix.frames.count, 16) } + func testMigratesLegacyKeepaliveConfiguration() throws { + let legacy = AppConfiguration.template.replacingOccurrences( + of: "max_wait_time = 60", + with: "keepalive_interval_seconds = 7\nactivity_timeout_seconds = 24") + try writeConfiguration(legacy) + + let configuration = try AppConfiguration.load(in: temporaryDirectory) + + XCTAssertEqual(configuration.maxWaitTime, 24) + let saved = try String( + contentsOf: temporaryDirectory.appendingPathComponent("config.toml"), encoding: .utf8) + XCTAssertFalse(saved.contains("keepalive_interval_seconds")) + XCTAssertFalse(saved.contains("activity_timeout_seconds")) + XCTAssertTrue(saved.contains("max_wait_time = 24")) + } + func testRandomIsAcceptedAsDefaultAnimation() throws { let configurationText = AppConfiguration.template.replacingOccurrences( of: "default_animation = \"nyathing_36x36.png\"", @@ -301,8 +316,7 @@ final class ConfigurationTests: XCTestCase { let configuration = try AppConfiguration.load(in: temporaryDirectory) - XCTAssertEqual(configuration.keepaliveInterval, 5) - XCTAssertEqual(configuration.activityTimeout, 30) + XCTAssertEqual(configuration.maxWaitTime, 60) XCTAssertFalse(configuration.autoStart) let savedConfig = try String( contentsOf: temporaryDirectory.appendingPathComponent("config.toml"), encoding: .utf8) @@ -329,12 +343,12 @@ final class ConfigurationTests: XCTestCase { func testRejectsMissingAndNonPositiveSettings() throws { try writeConfiguration( - "keepalive_interval_seconds = 5\nactivity_timeout_seconds = 5\nauto_start = false\n") + "max_wait_time = 0\nauto_start = false\n") XCTAssertThrowsError(try AppConfiguration.load(in: temporaryDirectory)) try writeConfiguration( AppConfiguration.template.replacingOccurrences( - of: "activity_timeout_seconds = 30", with: "activity_timeout_seconds = 0")) + of: "max_wait_time = 60", with: "max_wait_time = 0")) XCTAssertThrowsError(try AppConfiguration.load(in: temporaryDirectory)) } @@ -471,6 +485,7 @@ final class LocalAPIServerTests: XCTestCase { let server = LocalAPIServer( socketPath: socketPath, defaultAnimation: "nyan_54x36.png", + maxWaitTime: 30, onStart: { animation, description, timeout in lock.lock() defer { lock.unlock() } @@ -488,20 +503,19 @@ final class LocalAPIServerTests: XCTestCase { defer { server.stop() } let first = try UnixJSONClient(path: socketPath) - let missingInterval = try first.command(["command": "start"]) - XCTAssertEqual(missingInterval["ok"] as? Bool, false) - XCTAssertTrue((missingInterval["error"] as? String)?.contains("required") == true) + let defaultIntervalStart = try first.command(["command": "start"]) + XCTAssertEqual(defaultIntervalStart["activity_id"] as? String, "activity-1") let nonPositiveInterval = try first.command([ "command": "start", "keepalive_interval_seconds": 0, ]) XCTAssertEqual(nonPositiveInterval["ok"] as? Bool, false) XCTAssertTrue( (nonPositiveInterval["error"] as? String)?.contains("positive finite number") == true) - let invalidInterval = try first.command([ + let largeInterval = try first.command([ "command": "start", "keepalive_interval_seconds": 30, ]) - XCTAssertEqual(invalidInterval["ok"] as? Bool, false) - XCTAssertTrue((invalidInterval["error"] as? String)?.contains("must be less") == true) + XCTAssertEqual(largeInterval["activity_id"] as? String, "activity-2") + XCTAssertEqual(startedTimeouts[1], 30) let clientTimeoutOverride = try first.command([ "command": "start", "keepalive_interval_seconds": 5, "activity_timeout_seconds": 10, ]) @@ -512,30 +526,31 @@ final class LocalAPIServerTests: XCTestCase { "command": "start", "animation": "same_36x36.png", "description": "first client", "keepalive_interval_seconds": 8, ]) - XCTAssertEqual(firstStart["activity_id"] as? String, "activity-1") - XCTAssertNil(firstStart["keepalive_interval_seconds"]) + XCTAssertEqual(firstStart["activity_id"] as? String, "activity-3") + XCTAssertEqual(startedTimeouts[2], 16) XCTAssertEqual( - try first.command(["command": "keepalive", "activity_id": "activity-1"])["ok"] as? Bool, + try first.command(["command": "keepalive", "activity_id": "activity-3"])["ok"] as? Bool, true) XCTAssertEqual( - try first.command(["command": "stop", "activity_id": "activity-1"])["ok"] as? Bool, true) + try first.command(["command": "stop", "activity_id": "activity-3"])["ok"] as? Bool, true) let second = try UnixJSONClient(path: socketPath) let secondStart = try second.command([ "command": "start", "animation": "same_36x36.png", "keepalive_interval_seconds": 5, ]) - XCTAssertEqual(secondStart["activity_id"] as? String, "activity-2") - XCTAssertNil(secondStart["keepalive_interval_seconds"]) + XCTAssertEqual(secondStart["activity_id"] as? String, "activity-4") + XCTAssertEqual(startedTimeouts[3], 10) XCTAssertEqual( try second.command(["command": "start", "keepalive_interval_seconds": 1])["activity_id"] as? String, - "activity-3") + "activity-5") lock.lock() XCTAssertEqual( - startedAnimations, ["same_36x36.png", "same_36x36.png", "nyan_54x36.png"]) - XCTAssertEqual(stoppedIDs, ["activity-1"]) - XCTAssertEqual(startedDescriptions, ["first client", nil, nil]) - XCTAssertEqual(startedTimeouts, [30, 30, 30]) + startedAnimations, + ["nyan_54x36.png", "nyan_54x36.png", "same_36x36.png", "same_36x36.png", "nyan_54x36.png"]) + XCTAssertEqual(stoppedIDs, ["activity-3"]) + XCTAssertEqual(startedDescriptions, [nil, nil, "first client", nil, nil]) + XCTAssertEqual(startedTimeouts, [10, 30, 16, 10, 2]) lock.unlock() let responseLock = NSLock() From 9e887738d7c1b3d9c3317f23ee3ca1831ae108aa Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 21:27:33 +0400 Subject: [PATCH 26/43] Add client commands for activity control --- README.md | 16 ++++ Sources/Nyathing/CLI.swift | 81 ++++++++++++++++++- .../ConfigurationAndAPITests.swift | 2 + 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7849957..5de9d46 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,22 @@ List valid installed animations by short name with: nyathing list ``` +### Manage activities directly + +Use `client` commands to control an activity without wrapping a process: + +```sh +nyathing client start --animation nyan --description "Test" +nyathing client keepalive ACTIVITY_ID +nyathing client stop ACTIVITY_ID +``` + +`start` prints the activity ID. Send `keepalive` at least once per requested +interval (5 seconds by default), and use `stop` when done. +The server starts automatically if it is not already running; abandoned +activities expire according to `max_wait_time`. `start` also accepts +`--keepalive-interval SECONDS` to override the default for that activity. + To view available options or check the installed version: ```sh diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index d2f2f66..8d4b6bc 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -52,6 +52,7 @@ struct CLIArguments { nyathing [--animation NAME | -a NAME] COMMAND [ARGUMENT ...] nyathing uninstall nyathing server start|stop|status + nyathing client start|keepalive|stop nyathing list nyathing completion zsh|bash nyathing --help @@ -61,6 +62,7 @@ struct CLIArguments { COMMAND [ARGUMENT ...] Run a command while showing an activity animation. uninstall Remove the installed app and CLI command. server Manage the background server (start, stop, status). + client Start, refresh, or stop an activity. list List available valid animations. completion SHELL Print shell completion code for zsh or bash. @@ -69,6 +71,12 @@ struct CLIArguments { --help Show this help. --version Show the app version. + Client usage: + nyathing client start [--animation NAME] [--description TEXT] + [--keepalive-interval SECONDS] + nyathing client keepalive ACTIVITY_ID + nyathing client stop ACTIVITY_ID + Examples: nyathing sleep 5 nyathing --animation nyan make test @@ -131,6 +139,9 @@ enum NyathingCLI { return 0 } do { + if arguments.first == "client" { + return try executeClient(Array(arguments.dropFirst())) + } if arguments.count == 2, arguments[0] == "server" { let configurationDirectory = AppConfiguration.configurationDirectory switch arguments[1] { @@ -174,6 +185,66 @@ enum NyathingCLI { } } + private static func executeClient(_ arguments: [String]) throws -> Int32 { + guard let subcommand = arguments.first else { throw CLIError.usage } + switch subcommand { + case "start": + var animation: String? + var description: String? + var interval: Double? + var index = 1 + while index < arguments.count { + let option = arguments[index] + guard index + 1 < arguments.count else { throw CLIError.usage } + let value = arguments[index + 1] + guard !value.isEmpty else { throw CLIError.usage } + switch option { + case "--animation", "-a": + guard animation == nil else { throw CLIError.usage } + if value == "random" || isShortAnimationName(value) { + animation = value + } else { + let directory = AppConfiguration.configurationDirectory + .appendingPathComponent("animations", isDirectory: true) + animation = try resolveAnimation(value, in: directory) + } + case "--description": + guard description == nil else { throw CLIError.usage } + description = value + case "--keepalive-interval": + guard interval == nil, let parsed = Double(value), parsed.isFinite, parsed > 0 + else { throw CLIError.usage } + interval = parsed + default: + throw CLIError.usage + } + index += 2 + } + var request: [String: Any] = ["command": "start"] + if let animation { request["animation"] = animation } + if let description { request["description"] = description } + if let interval { request["keepalive_interval_seconds"] = NSNumber(value: interval) } + let client = try LocalAPIClient.connectOrStartServer() + guard let activityID = try client.command(request)["activity_id"] as? String else { + throw CLIError.api("The server returned an invalid activity response.") + } + print(activityID) + return 0 + case "keepalive", "stop": + guard arguments.count == 2, !arguments[1].isEmpty else { throw CLIError.usage } + let client = try LocalAPIClient.connectOrStartServer() + let response = try client.command([ + "command": subcommand, "activity_id": arguments[1], + ]) + guard response["ok"] as? Bool == true else { + throw CLIError.api(response["error"] as? String ?? "The server rejected the request.") + } + return 0 + default: + throw CLIError.usage + } + } + private static func execute(_ cli: CLIArguments) throws -> Int32 { let executable = try resolveExecutable(cli.command) _ = try AppConfiguration.load() @@ -372,7 +443,7 @@ enum NyathingCLI { } enum ShellCompletion { - static let supportedCommands = ["server", "list", "uninstall", "completion"] + static let supportedCommands = ["server", "client", "list", "uninstall", "completion"] static func script(for shell: String) -> String? { let commands = supportedCommands.joined(separator: " ") @@ -395,6 +466,10 @@ enum ShellCompletion { compadd -- start stop status return ;; + client) + compadd -- start keepalive stop + return + ;; completion) compadd -- zsh bash return @@ -426,6 +501,10 @@ enum ShellCompletion { COMPREPLY=( $(compgen -W "start stop status" -- "$cur") ) return ;; + client) + COMPREPLY=( $(compgen -W "start keepalive stop" -- "$cur") ) + return + ;; completion) COMPREPLY=( $(compgen -W "zsh bash" -- "$cur") ) return diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 6c631d1..e707b86 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -123,6 +123,7 @@ final class CLITests: XCTestCase { } XCTAssertTrue(script.contains("nyathing list")) XCTAssertTrue(script.contains("start stop status")) + XCTAssertTrue(script.contains("start keepalive stop")) XCTAssertTrue(script.contains("compadd -- zsh bash")) } @@ -134,6 +135,7 @@ final class CLITests: XCTestCase { } XCTAssertTrue(script.contains("nyathing list")) XCTAssertTrue(script.contains("start stop status")) + XCTAssertTrue(script.contains("start keepalive stop")) XCTAssertTrue(script.contains("zsh bash")) } From 651251c89614617524780d459c9eb6317c330a57 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Fri, 20 Nov 2026 22:06:51 +0400 Subject: [PATCH 27/43] Improve timeout errors and animation picker . --- Makefile | 4 +- Sources/Nyathing/CLI.swift | 1 - Sources/Nyathing/LocalAPIServer.swift | 8 +- Sources/Nyathing/main.swift | 193 +++++++++++++++--- .../ConfigurationAndAPITests.swift | 8 +- 5 files changed, 179 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 872e0e9..3e64098 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash .DEFAULT_GOAL := help -.PHONY: help format lint test package run install-app install-cli-link install uninstall +.PHONY: help format lint test package run install-app install-cli-link install uninstall reinstall help: @printf '%s\n' \ @@ -39,6 +39,8 @@ install: install-app install-cli-link uninstall: bash Scripts/force-uninstall.sh +reinstall: uninstall install + run: swift build ANIMATION='$(ANIMATION)' ANIMATIONS='$(ANIMATIONS)' python3 Scripts/run-test-animation.py diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 8d4b6bc..6c14738 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -257,7 +257,6 @@ enum NyathingCLI { "command": "start", "animation": animation, "description": activityDescription(command: cli.command, arguments: cli.arguments), - "keepalive_interval_seconds": NSNumber(value: keepaliveInterval), ]) guard let activityID = activity["activity_id"] as? String else { throw CLIError.api("The server returned an invalid activity response.") diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index 0ab30c3..511b6b4 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -6,7 +6,7 @@ final class LocalAPIServer { static let defaultKeepaliveInterval: TimeInterval = 5 private let defaultAnimation: String private let maxWaitTime: TimeInterval - private let onStart: (String, String?, TimeInterval) throws -> String + private let onStart: (String, String?, TimeInterval, Bool, TimeInterval) throws -> String private let onKeepalive: (String) throws -> Void private let onStop: (String) throws -> Void private let socketPath: String @@ -19,7 +19,7 @@ final class LocalAPIServer { socketPath: String = LocalAPIServer.socketPath, defaultAnimation: String = "nyathing_36x36.png", maxWaitTime: TimeInterval = 60, - onStart: @escaping (String, String?, TimeInterval) throws -> String, + onStart: @escaping (String, String?, TimeInterval, Bool, TimeInterval) throws -> String, onKeepalive: @escaping (String) throws -> Void, onStop: @escaping (String) throws -> Void ) { @@ -223,6 +223,7 @@ final class LocalAPIServer { guard request["activity_timeout_seconds"] == nil else { throw LocalAPIError.serverManagedActivityTimeout } + let keepaliveIntervalWasProvided = request["keepalive_interval_seconds"] != nil let keepaliveInterval: TimeInterval if let rawKeepaliveInterval = request["keepalive_interval_seconds"] { keepaliveInterval = try positiveSeconds(rawKeepaliveInterval) @@ -233,7 +234,8 @@ final class LocalAPIServer { return [ "ok": true, "activity_id": try onStart( - animation, request["description"] as? String, activityTimeout), + animation, request["description"] as? String, keepaliveInterval, + keepaliveIntervalWasProvided, activityTimeout), ] case "keepalive": guard let activityID = request["activity_id"] as? String, !activityID.isEmpty else { diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index eea2518..9faa1d9 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -46,6 +46,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private var lifecycle = ActivityLifecycle() private var maxWaitTime: TimeInterval = 60 private var activityTimeouts: [UUID: TimeInterval] = [:] + private var activityKeepaliveIntervals: [UUID: TimeInterval] = [:] + private var activityKeepaliveIntervalSources: [UUID: String] = [:] + private var timedOutActivityDetails: [UUID: ActivityTimeoutDetails] = [:] private var activityStartOrder: [UUID: UInt64] = [:] private var nextActivityStartOrder: UInt64 = 0 private var defaultAnimation = "nyathing_36x36.png" @@ -200,19 +203,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { stack.orientation = .vertical stack.alignment = .leading stack.spacing = 10 + stack.edgeInsets = NSEdgeInsets(top: 16, left: 20, bottom: 20, right: 20) stack.setContentHuggingPriority(.required, for: .vertical) stack.setContentCompressionResistancePriority(.required, for: .vertical) stack.translatesAutoresizingMaskIntoConstraints = false scrollView.documentView = stack window.contentView = scrollView NSLayoutConstraint.activate([ - stack.leadingAnchor.constraint(equalTo: scrollView.contentView.leadingAnchor, constant: 12), - stack.trailingAnchor.constraint( - equalTo: scrollView.contentView.trailingAnchor, constant: -12), - stack.topAnchor.constraint(equalTo: scrollView.contentView.topAnchor, constant: 12), - stack.widthAnchor.constraint(equalTo: scrollView.contentView.widthAnchor, constant: -24), - stack.heightAnchor.constraint( - greaterThanOrEqualTo: scrollView.contentView.heightAnchor, constant: -24), + stack.leadingAnchor.constraint(equalTo: scrollView.contentView.leadingAnchor), + stack.topAnchor.constraint(equalTo: scrollView.contentView.topAnchor), + stack.widthAnchor.constraint(equalTo: scrollView.contentView.widthAnchor), + stack.heightAnchor.constraint(greaterThanOrEqualTo: scrollView.contentView.heightAnchor), ]) errorsWindow = window errorsStackView = stack @@ -223,12 +224,25 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { NSApp.activate(ignoringOtherApps: true) } + private func sectionLabel(_ text: String) -> NSTextField { + let label = NSTextField(labelWithString: text) + label.font = .systemFont(ofSize: 11, weight: .semibold) + label.textColor = .secondaryLabelColor + return label + } + + private static func seconds(_ value: TimeInterval) -> String { + "\(value.formatted()) seconds" + } + @objc private func acknowledgeError(_ sender: NSButton) { guard let id = UUID(uuidString: sender.identifier?.rawValue ?? ""), lifecycle.acknowledgeTimeout(id) else { return } + timedOutActivityDetails.removeValue(forKey: id) updateMainStatusItemVisibility() updateMainStatusItem() + refreshStatusItemMenus() refreshErrorsWindow() if lifecycle.timedOutActivities.isEmpty { errorsWindow?.close() @@ -256,25 +270,84 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { stack.addArrangedSubview(separator) separator.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true } - let row = NSStackView() - row.orientation = .horizontal - row.alignment = .centerY - row.spacing = 12 - row.distribution = .fill - let leadingInset = NSView() - leadingInset.setContentHuggingPriority(.required, for: .horizontal) - leadingInset.widthAnchor.constraint(equalToConstant: 8).isActive = true + let details = timedOutActivityDetails[error.id] + let block = NSStackView() + block.orientation = .vertical + block.alignment = .leading + block.spacing = 5 + block.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + block.addArrangedSubview(sectionLabel("Activity ID")) + let idLabel = NSTextField(labelWithString: error.id.uuidString) + idLabel.font = .monospacedSystemFont(ofSize: 12, weight: .medium) + block.addArrangedSubview(idLabel) + block.addArrangedSubview(sectionLabel("Client description")) let descriptionLabel = NSTextField(wrappingLabelWithString: error.description) descriptionLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + block.addArrangedSubview(descriptionLabel) + block.addArrangedSubview(sectionLabel("Reason")) + let reasonLabel = NSTextField( + wrappingLabelWithString: "No keepalive was received before the activity timed out.") + reasonLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + block.addArrangedSubview(reasonLabel) + if let details { + let intervalLabel = NSTextField( + wrappingLabelWithString: + "Keepalive interval: \(Self.seconds(details.keepaliveInterval)) " + + "(\(details.intervalSource)).") + intervalLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + block.addArrangedSubview(intervalLabel) + let waitExplanation = + details.timeout < details.keepaliveInterval * 2 + ? "capped by max_wait_time" + : "2 × keepalive interval" + let timeoutLabel = NSTextField( + wrappingLabelWithString: + "Expiration threshold: \(Self.seconds(details.timeout)) " + + "(\(waitExplanation); max_wait_time is " + + "\(Self.seconds(details.maxWaitTime))).") + timeoutLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + block.addArrangedSubview(timeoutLabel) + } + let buttonRow = NSStackView() + buttonRow.orientation = .horizontal + buttonRow.alignment = .centerY + buttonRow.distribution = .fill + let buttonSpacer = NSView() + buttonSpacer.setContentHuggingPriority(.defaultLow, for: .horizontal) let acknowledgeButton = NSButton( title: "Acknowledge", target: self, action: #selector(acknowledgeError(_:))) acknowledgeButton.identifier = NSUserInterfaceItemIdentifier(error.id.uuidString) - row.addArrangedSubview(leadingInset) - row.addArrangedSubview(descriptionLabel) - row.addArrangedSubview(acknowledgeButton) - stack.addArrangedSubview(row) - row.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true + buttonRow.addArrangedSubview(buttonSpacer) + buttonRow.addArrangedSubview(acknowledgeButton) + block.addArrangedSubview(buttonRow) + buttonRow.widthAnchor.constraint(equalTo: block.widthAnchor).isActive = true + stack.addArrangedSubview(block) + block.widthAnchor.constraint(equalTo: stack.widthAnchor, constant: -40).isActive = true + } + } + + private static func shortAnimationName(_ filename: String) -> String? { + guard + let range = filename.range( + of: #"_[0-9]+x[0-9]+\.png$"#, options: .regularExpression) + else { return nil } + return String(filename[.. NSMenuItem { + let item = NSMenuItem(title: title, action: nil, keyEquivalent: "") + item.representedObject = title + let attributedTitle = NSMutableAttributedString(string: "\u{2002}\(title) ") + if let frame { + let image = (frame.copy() as? NSImage) ?? frame + image.size = NSSize(width: 18, height: 18) + let attachment = NSTextAttachment() + attachment.image = image + attachment.bounds = CGRect(x: 0, y: -4, width: 18, height: 18) + attributedTitle.append(NSAttributedString(attachment: attachment)) } + item.attributedTitle = attributedTitle + return item } @objc private func editConfiguration() { @@ -294,8 +367,19 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { let animationDirectory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) - let animationNames = ["random"] + SpriteAnimation.loadAll(in: animationDirectory).keys.sorted() - guard !animationNames.isEmpty else { + var animationsByName: [String: SpriteAnimation] = [:] + for animation in SpriteAnimation.loadAll(in: animationDirectory).values { + guard let name = Self.shortAnimationName(animation.filename) else { continue } + if let current = animationsByName[name], + current.frameSize.width * current.frameSize.height + >= animation.frameSize.width * animation.frameSize.height + { + continue + } + animationsByName[name] = animation + } + let animationNames = ["random"] + animationsByName.keys.sorted() + guard animationNames.count > 1 else { showConfigurationEditorError("No valid animations are available.") return } @@ -306,8 +390,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { maxWaitTimeField.widthAnchor.constraint(equalToConstant: 130).isActive = true let animationPicker = NSPopUpButton() - animationPicker.addItems(withTitles: animationNames) - animationPicker.selectItem(withTitle: configuration.defaultAnimation) + for name in animationNames { + animationPicker.menu?.addItem( + animationMenuItem(title: name, frame: animationsByName[name]?.frames.first)) + } + let selectedAnimationName = + Self.shortAnimationName(configuration.defaultAnimation) + ?? configuration.defaultAnimation + if let index = animationNames.firstIndex(of: selectedAnimationName) { + animationPicker.selectItem(at: index) + } let autoStart = NSButton( checkboxWithTitle: "Launch Nyathing at login", target: self, action: nil) @@ -380,7 +472,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { guard let maxWaitTimeField, let autoStartCheckbox, let defaultAnimationPicker, - let animation = defaultAnimationPicker.titleOfSelectedItem + let selectedAnimation = defaultAnimationPicker.selectedItem?.representedObject as? String else { return } guard let maxWaitTime = Double(maxWaitTimeField.stringValue), @@ -390,6 +482,21 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { return } + let animation: String + if selectedAnimation == "random" { + animation = selectedAnimation + } else { + let animationDirectory = AppConfiguration.configurationDirectory + .appendingPathComponent("animations", isDirectory: true) + do { + let resolved = try NyathingCLI.resolveAnimation(selectedAnimation, in: animationDirectory) + animation = URL(fileURLWithPath: resolved).lastPathComponent + } catch { + showConfigurationEditorError(error.localizedDescription) + return + } + } + let configurationText = """ # Maximum seconds to wait since the last client keepalive. max_wait_time = \(maxWaitTime) @@ -476,11 +583,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { apiServer = LocalAPIServer( defaultAnimation: serverDefaultAnimation, maxWaitTime: maxWaitTime, - onStart: { [weak self] filename, description, timeout in + onStart: { [weak self] filename, description, interval, intervalWasProvided, timeout in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } return try self.startActivity( - animation: filename, description: description, activityTimeout: timeout + animation: filename, description: description, activityTimeout: timeout, + keepaliveInterval: interval, intervalWasProvided: intervalWasProvided ).uuidString } }, @@ -509,6 +617,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private func clearRuntimeState() { activeAnimations.removeAll() + activityTimeouts.removeAll() + activityKeepaliveIntervals.removeAll() + activityKeepaliveIntervalSources.removeAll() + timedOutActivityDetails.removeAll() activityStartOrder.removeAll() nextActivityStartOrder = 0 lifecycle.reset() @@ -521,7 +633,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { @discardableResult func startActivity( animation filename: String, description: String? = nil, - activityTimeout timeout: TimeInterval? = nil + activityTimeout timeout: TimeInterval? = nil, + keepaliveInterval: TimeInterval = LocalAPIServer.defaultKeepaliveInterval, + intervalWasProvided: Bool = false ) throws -> UUID { let directory = AppConfiguration.configurationDirectory.appendingPathComponent( "animations", isDirectory: true) @@ -548,6 +662,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { activityStartOrder[id] = nextActivityStartOrder nextActivityStartOrder &+= 1 activityTimeouts[id] = timeout + activityKeepaliveIntervals[id] = keepaliveInterval + activityKeepaliveIntervalSources[id] = + intervalWasProvided ? "client-provided" : "built-in default" scheduleActivityExpiration(id, deadlineUptime: deadlineUptime) if let active = existingAnimation { active.activityIDs.insert(id) @@ -575,6 +692,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { func stopActivity(_ id: UUID) { guard let filename = lifecycle.stop(id) else { return } activityTimeouts.removeValue(forKey: id) + activityKeepaliveIntervals.removeValue(forKey: id) + activityKeepaliveIntervalSources.removeValue(forKey: id) activityStartOrder.removeValue(forKey: id) removeActivityFromStatusItem(id, animation: filename) refreshStatusItemMenus() @@ -684,7 +803,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { return } guard let expired = lifecycle.expire(id, deadline: deadlineUptime) else { return } - activityTimeouts.removeValue(forKey: id) + let interval = + activityKeepaliveIntervals.removeValue(forKey: id) + ?? LocalAPIServer.defaultKeepaliveInterval + let intervalSource = + activityKeepaliveIntervalSources.removeValue(forKey: id) + ?? "built-in default" + let timeout = activityTimeouts.removeValue(forKey: id) ?? min(interval * 2, maxWaitTime) + timedOutActivityDetails[id] = ActivityTimeoutDetails( + keepaliveInterval: interval, intervalSource: intervalSource, + timeout: timeout, maxWaitTime: maxWaitTime) activityStartOrder.removeValue(forKey: id) removeActivityFromStatusItem(id, animation: expired.animation) refreshStatusItemMenus() @@ -740,6 +868,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } } +private struct ActivityTimeoutDetails { + let keepaliveInterval: TimeInterval + let intervalSource: String + let timeout: TimeInterval + let maxWaitTime: TimeInterval +} + private final class ActiveAnimation { let filename: String let statusItem: NSStatusItem diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index e707b86..52e13b9 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -483,16 +483,20 @@ final class LocalAPIServerTests: XCTestCase { var startedAnimations: [String] = [] var startedDescriptions: [String?] = [] var startedTimeouts: [Double] = [] + var startedIntervals: [Double] = [] + var startedIntervalsWereProvided: [Bool] = [] var stoppedIDs: [String] = [] let server = LocalAPIServer( socketPath: socketPath, defaultAnimation: "nyan_54x36.png", maxWaitTime: 30, - onStart: { animation, description, timeout in + onStart: { animation, description, interval, intervalWasProvided, timeout in lock.lock() defer { lock.unlock() } startedAnimations.append(animation) startedDescriptions.append(description) + startedIntervals.append(interval) + startedIntervalsWereProvided.append(intervalWasProvided) startedTimeouts.append(timeout) return "activity-\(startedAnimations.count)" }, onKeepalive: { _ in }, @@ -553,6 +557,8 @@ final class LocalAPIServerTests: XCTestCase { XCTAssertEqual(stoppedIDs, ["activity-3"]) XCTAssertEqual(startedDescriptions, [nil, nil, "first client", nil, nil]) XCTAssertEqual(startedTimeouts, [10, 30, 16, 10, 2]) + XCTAssertEqual(startedIntervals, [5, 30, 8, 5, 1]) + XCTAssertEqual(startedIntervalsWereProvided, [false, true, true, true, true]) lock.unlock() let responseLock = NSLock() From a93b87c5d684e9f03fbb1faca1ead8b90184d077 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 09:43:33 +0400 Subject: [PATCH 28/43] Use configured animation as CLI default Use the configured default animation when wrapping commands without an explicit animation option, matching client-start behavior. Add a test for omitted animation arguments. Reorganize README sections around client and CLI usage, document client descriptions, and link to the animation file format. --- README.md | 223 +++++++++--------- Sources/Nyathing/CLI.swift | 9 +- .../ConfigurationAndAPITests.swift | 5 + assets/nyathing-client.png | Bin 0 -> 39532 bytes 4 files changed, 123 insertions(+), 114 deletions(-) create mode 100644 assets/nyathing-client.png diff --git a/README.md b/README.md index 5de9d46..bdccd42 100644 --- a/README.md +++ b/README.md @@ -23,15 +23,6 @@ To remove the installed app and command, run in terminal: nyathing uninstall ``` -Uninstall requests administrator authorization. It asks -`Remove Nyathing configuration and user animations? [y/N]`; the default is no. -Answering no preserves configuration and animations while still removing the -app and CLI symlink. The app is closed as part of removal. - -If the built-in uninstall does not complete, run `make uninstall` from the -repository root. This force-removal fallback requires administrator -authorization and removes the app, CLI command, configuration, and logs. - **👮🏻‍♂️ Note** The app and package are **unsigned** and not notarized, so macOS may block the @@ -49,6 +40,30 @@ to enter your password or confirm with Touch ID. Alternatively, build and run `Nyathing` locally using the instructions in [Build from source](#build-from-source); locally built apps are not quarantined. +## ⚒ Build from source + +Requires macOS 12+ and Swift 5.9 or later. Run the commands below from the +repository root. + +### Install from source + +Install the menu-bar app in `/Applications`: + +```sh +make install-app +``` + +To run Nyathing from a terminal, also create the CLI symlink in +`/usr/local/bin`: + +```sh +make install-cli-link +``` + +The CLI symlink requires the app to be installed first. Each command asks +before replacing an existing app or symlink and requires administrator +authorization to install its files. + ## Nyathing server

nyathing-server

@@ -61,24 +76,47 @@ current user, and the server checks the connecting process's user ID. Exchange UTF-8 JSON Lines: send one JSON object followed by a newline (`\n`); Nyathing returns one JSON object followed by a newline for each request. A connection can carry multiple request/response pairs, and multiple clients may -connect at the same time. Request lines are limited to 1 MiB. +connect at the same time. + +For convenience, Nyathing also implements the client side of the protocol. See +[Nyathing client](#nyathing-client) for details. For the complete message formats, field requirements, and response schemas, see [Server communication protocol](#server-communication-protocol). -## Nyathing CLI +## Nyathing client -

nyathing-cli

+

nyathing-client

-Nyathing provides a command-line utility for wrapping long-running terminal -commands in an animation. +For convenience, Nyathing includes a client for communicating with the server +without having to implement the protocol yourself. -For example, show an animation while waiting five seconds, with or without a -custom animation: +Use `client` commands to control an activity without wrapping a process: ```sh - nyathing sleep 5 - nyathing --animation nyan sleep 5 +nyathing client start +``` + +The server starts automatically if it is not already running. +On `start` nyathing prints the activity ID. + +Send `keepalive` at least once per requested +interval (5 seconds by default) to keep animation, and use `stop` when done. + +```sh +nyathing client keepalive ACTIVITY_ID +nyathing client stop ACTIVITY_ID +``` + +Abandoned activities expire according to `max_wait_time`. `start` also accepts +`--keepalive-interval SECONDS` to override the default for that activity. + +### How to choose an animation + +You can explicitly specify an animation on start: + +```sh +nyathing client start --animation nyan --description "Test" ``` `--animation` (or `-a`) selects an animation. A short name without the frame @@ -86,44 +124,53 @@ size suffix or `.png` (for example, `nyan`) is looked up in Nyathing's user animation directory. If multiple valid files share that name, Nyathing chooses the frame with the largest pixel area. Any other value is treated as a path to an animation file; relative paths are resolved from the current directory. -Without `--animation`, the CLI uses the short name `nyathing`, regardless of -the configured server default. +See [Animation file format](#-animation-file-format) for more details about file format. +Without `--animation`, a configured default animation is used. Set `--animation` to `random` to choose a random valid animation from the user animations directory for that run. -If valid files named `random_x.png` exist, Nyathing plays the -largest matching animation. Otherwise, it chooses randomly from valid user -animations. If none are available, Nyathing uses its built-in ghost animation: - ```sh nyathing --animation random sleep 5 ``` +If valid files named `random_x.png` exist, Nyathing plays the +largest matching animation. Otherwise, it chooses randomly from valid user +animations. If none are available, Nyathing uses its built-in ghost animation. + Quote paths containing spaces as usual in your shell. Relative command paths are resolved from the current working directory. -List valid installed animations by short name with: +### Describe a client + +Active animations appear in the menu with a shortened version of their +descriptions. Add a description when starting a client to make it easier to +identify the activity: ```sh - nyathing list +nyathing client start --description "Running tests" ``` -### Manage activities directly +## Nyathing CLI -Use `client` commands to control an activity without wrapping a process: +

nyathing-cli

+ +Nyathing provides a command-line utility for wrapping long-running terminal +commands in an animation. + +For example, show an animation while waiting five seconds, with or without a +custom animation: ```sh -nyathing client start --animation nyan --description "Test" -nyathing client keepalive ACTIVITY_ID -nyathing client stop ACTIVITY_ID + nyathing sleep 5 + nyathing --animation nyan sleep 5 ``` -`start` prints the activity ID. Send `keepalive` at least once per requested -interval (5 seconds by default), and use `stop` when done. -The server starts automatically if it is not already running; abandoned -activities expire according to `max_wait_time`. `start` also accepts -`--keepalive-interval SECONDS` to override the default for that activity. +List valid installed animations by short name with: + +```sh + nyathing list +``` To view available options or check the installed version: @@ -155,17 +202,6 @@ The completion script offers Nyathing commands and options, including server subcommands. It fetches available animations with `nyathing list` when completing an animation argument, so the suggestions reflect installed files. -## Animation file format - -Animation files are horizontal PNG sprite sheets. The filename suffix declares -the dimensions of each frame, for example `nyan_64x48.png`. Each dimension must -be between 16 and 256 pixels, with an aspect ratio no greater than 3:1. The -image height must match the declared frame height, and its width must be a -positive multiple of the declared frame width. Sheets may contain at most 120 -frames and 4 million pixels total. Frames are scaled to fit the menu bar. The -app validates assets on startup and when settings are accepted; invalid assets -are ignored and logged. Playback runs at 10 frames per second. - ## ⚙ Configuration On first launch, Nyathing creates its configuration directory and adds these @@ -207,6 +243,17 @@ animations; this also clears active activities and the disconnected-client count. **Cancel** closes the editor without applying changes. Accepting the current settings also reloads animation files changed outside the editor. +## 👾 Animation file format + +Animation files are horizontal PNG sprite sheets. The filename suffix declares +the dimensions of each frame, for example `nyan_64x48.png`. Each dimension must +be between 16 and 256 pixels, with an aspect ratio no greater than 3:1. The +image height must match the declared frame height, and its width must be a +positive multiple of the declared frame width. Sheets may contain at most 120 +frames and 4 million pixels total. Frames are scaled to fit the menu bar. The +app validates assets on startup and when settings are accepted; invalid assets +are ignored and logged. Playback runs at 10 frames per second. + ## {} Server communication protocol The server communicates over a Unix domain `SOCK_STREAM` socket using UTF-8 @@ -229,20 +276,20 @@ Every request has this common envelope: The `command` property is required and must be a string. The following command messages are supported: -| Command | Description | -| --- | --- | -| `start` | Starts an activity and returns its identifier. | -| `keepalive` | Refreshes an activity's expiration timer. | -| `stop` | Ends an activity without counting it as a disconnect. | +| Command | Description | +| --- | --- | +| `start` | Starts an activity and returns its identifier. | +| `keepalive` | Refreshes an activity's expiration timer. | +| `stop` | Ends an activity without counting it as a disconnect. | #### `start` request -| Field | Type | Required | Description | -| --- | --- | --- | --- | -| `command` | string | Yes | Must be `start`. | -| `animation` | string | No | Short name searched in the server's animation directory, or a path to a PNG sprite sheet. Defaults to the server's configured animation. Invalid explicit values return an error. | -| `description` | string | No | Description shown for the activity. If omitted or not a string, the server uses its default description. | -| `keepalive_interval_seconds` | number | No | Positive, finite interval in seconds at which the client promises to send keepalives. Defaults to 5 seconds. The activity expires after the smaller of twice this interval and the server's configured `max_wait_time`. | +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `command` | string | Yes | Must be `start`. | +| `animation` | string | No | Short name searched in the server's animation directory, or a path to a PNG sprite sheet. Defaults to the server's configured animation. Invalid explicit values return an error. | +| `description` | string | No | Description shown for the activity. If omitted or not a string, the server uses its default description. | +| `keepalive_interval_seconds` | number | No | Positive, finite interval in seconds at which the client promises to send keepalives. Defaults to 5 seconds. The activity expires after the smaller of twice this interval and the server's configured `max_wait_time`. | A short name without a frame-size suffix or `.png` is resolved in the server's animation directory. Other values are treated as file paths; relative paths @@ -262,10 +309,10 @@ or #### `keepalive` request -| Field | Type | Required | Description | -| --- | --- | --- | --- | -| `command` | string | Yes | Must be `keepalive`. | -| `activity_id` | string (UUID) | Yes | Identifier returned by the corresponding `start` request. | +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `command` | string | Yes | Must be `keepalive`. | +| `activity_id` | string (UUID) | Yes | Identifier returned by the corresponding `start` request. | Example: @@ -280,10 +327,10 @@ disconnected-client count. #### `stop` request -| Field | Type | Required | Description | -| --- | --- | --- | --- | -| `command` | string | Yes | Must be `stop`. | -| `activity_id` | string (UUID) | Yes | Identifier returned by the corresponding `start` request. Stopping an activity does not count as a disconnect. | +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `command` | string | Yes | Must be `stop`. | +| `activity_id` | string (UUID) | Yes | Identifier returned by the corresponding `start` request. Stopping an activity does not count as a disconnect. | Example: @@ -366,47 +413,3 @@ offer **Open Configuration**. Invalid animation files are logged and ignored. If the socket path is already in use, quit the existing instance before launching another. After correcting animation files, click **Accept** in the **Edit Configuration** window to reload them. - -## ⚒ Build from source - -Requires macOS 12+ and Swift 5.9 or later. Run the commands below from the -repository root. - -### Run the server - -Build and launch the menu-bar server in the background: - -```sh -swift build -swift run nyathing server start -swift run nyathing server status -swift run nyathing server stop -``` - - -### Run the CLI - -The CLI runs a command while displaying an activity animation. For example: - -```sh -swift run nyathing sleep 5 -``` - -### Install from source - -Install the menu-bar app in `/Applications`: - -```sh -make install-app -``` - -To run Nyathing from a terminal, also create the CLI symlink in -`/usr/local/bin`: - -```sh -make install-cli-link -``` - -The CLI symlink requires the app to be installed first. Each command asks -before replacing an existing app or symlink and requires administrator -authorization to install its files. diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 6c14738..00d771d 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -34,7 +34,7 @@ private final class KeepaliveFailure { } struct CLIArguments { - let animation: String + let animation: String? let command: String let arguments: [String] @@ -85,7 +85,7 @@ struct CLIArguments { static func parse(_ arguments: [String]) throws -> CLIArguments { var values = arguments - var animation = "nyathing" + var animation: String? if values.first == "--animation" || values.first == "-a" { guard values.count >= 3, !values[1].isEmpty else { throw CLIError.usage } animation = values[1] @@ -247,10 +247,11 @@ enum NyathingCLI { private static func execute(_ cli: CLIArguments) throws -> Int32 { let executable = try resolveExecutable(cli.command) - _ = try AppConfiguration.load() + let configuration = try AppConfiguration.load() let animationsDirectory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) - let animation = try resolveAnimation(cli.animation, in: animationsDirectory) + let animation = try resolveAnimation( + cli.animation ?? configuration.defaultAnimation, in: animationsDirectory) let keepaliveInterval = LocalAPIServer.defaultKeepaliveInterval let client = try LocalAPIClient.connectOrStartServer() let activity = try client.command([ diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 52e13b9..d965e2b 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -24,6 +24,11 @@ final class CLITests: XCTestCase { XCTAssertEqual(dashedCommand.arguments, ["--child-option"]) } + func testUsesConfiguredAnimationWhenNoAnimationIsSpecified() throws { + let parsed = try CLIArguments.parse(["sleep", "5"]) + XCTAssertNil(parsed.animation) + } + func testRejectsMissingCommandOrAnimationValue() { XCTAssertThrowsError(try CLIArguments.parse([])) XCTAssertThrowsError(try CLIArguments.parse(["-a", "animation.png"])) diff --git a/assets/nyathing-client.png b/assets/nyathing-client.png new file mode 100644 index 0000000000000000000000000000000000000000..b8d15f3d5afc4ee9c65ad9f32504c1abaeae03c8 GIT binary patch literal 39532 zcmV)qK$^daP)z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy32;bRa{vGf6951U69E94oEQKA00(qQO+^Rl3l#+s7rotJ!~g&w z07*naRCwC#y=k;%*Hs?+eQWJ=ZdZMy>Z?@hE%&x$xxvOA*e13J229{VNO&2L5!#W4 z7xTu*BTjfEgun;}$Ad8Fo(WDEfdIBK0ULv3jC;#6mepEKsj8&v+k5Xhd#(9?thLvg zYwdkyb>*s(?*Un=y62vD&o$@#<~P3&SiP;@R&T4f)!XWA^|pFjy{+C>Z(rrc)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+9ypVq<(E&`mt{o@vQv!4lS4_gHNZr-Ix!^$z>AyKHG^i<2 zwQU`X31k$fzEAKnpbOVf_s&oA(Rw z`)LOc5p6{eU_dm9b-KD1!Vz4+VV270HG*uI(+z=j`o=w~o-EhD9+8dPCBaL`&ME-r z0Dc0HnL3maFJYJLorpN_QBAZAl4Nt zYY$0qjm5=lE9lze6}@?1taR3P+ABb|lP8lTRgWknG=05xP!Od;peJzp8{jn)xC(Hw z4IrdctROI%C)L@i>c^>o-vII=E)3U7=4+2vbo271^uBu+PhHqLaqpWcauAF+wgY2Z ziemnflbs>}BMecS?Fk^vD9?RkyzGml-0&j;TrWT%Bq+bfj+9QRenT9mgGmwWk`nT{ gYs=@_ Date: Sat, 21 Nov 2026 10:31:50 +0400 Subject: [PATCH 29/43] Package CLI archives for CI and releases . . . --- .github/workflows/ci.yml | 39 ++++++- Makefile | 25 ++-- README.md | 69 ++++++----- Scripts/build-dmg.sh | 74 ------------ Scripts/build-pkg.sh | 91 --------------- Scripts/force-uninstall.sh | 40 ++++--- Scripts/install-app.sh | 53 --------- Scripts/install-cli-link.sh | 25 ---- Scripts/install-cli.sh | 50 ++++++++ Scripts/installer-resources/Distribution.xml | 14 --- Scripts/installer-resources/welcome.html | 23 ---- Scripts/make-app-icon.swift | 66 ----------- Scripts/package-cli.sh | 29 +++++ Scripts/pkg-postinstall | 5 - Scripts/pkg-preinstall | 16 --- Sources/Nyathing/CLI.swift | 7 +- Sources/Nyathing/Uninstall.swift | 113 ------------------- 17 files changed, 181 insertions(+), 558 deletions(-) delete mode 100755 Scripts/build-dmg.sh delete mode 100755 Scripts/build-pkg.sh delete mode 100644 Scripts/install-app.sh delete mode 100644 Scripts/install-cli-link.sh create mode 100644 Scripts/install-cli.sh delete mode 100644 Scripts/installer-resources/Distribution.xml delete mode 100644 Scripts/installer-resources/welcome.html delete mode 100644 Scripts/make-app-icon.swift create mode 100755 Scripts/package-cli.sh delete mode 100755 Scripts/pkg-postinstall delete mode 100755 Scripts/pkg-preinstall delete mode 100644 Sources/Nyathing/Uninstall.swift diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c61011c..64d734c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,10 +2,11 @@ name: CI on: push: - branches: [main] + branches: ["**"] tags: ["v*"] pull_request: branches: [main] + workflow_dispatch: permissions: contents: read @@ -22,6 +23,34 @@ jobs: - name: Run tests run: swift test + build-cli-artifact: + name: Build downloadable CLI archive + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')) + needs: test + runs-on: macos-26 + steps: + - name: Check out selected branch + uses: actions/checkout@v4 + - name: Build CLI archive + run: Scripts/package-cli.sh + - name: Test installed archive + shell: bash + run: | + prefix="$RUNNER_TEMP/nyathing-prefix" + config="$RUNNER_TEMP/nyathing-config" + mkdir -p "$prefix" "$config" + PREFIX="$prefix" bash out/nyathing-macos-arm64/install.sh + XDG_CONFIG_HOME="$config" "$prefix/bin/nyathing" list + test -x "$prefix/libexec/nyathing/nyathing" + test -d "$prefix/libexec/nyathing/Nyathing_Nyathing.bundle" + - name: Upload CLI archive + uses: actions/upload-artifact@v4 + with: + name: nyathing-macos-arm64 + path: out/nyathing-macos-arm64/* + if-no-files-found: error + retention-days: 14 + release: name: Build and publish tagged release if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') @@ -49,10 +78,8 @@ jobs: exit 1 fi echo "value=${tag#v}" >> "$GITHUB_OUTPUT" - - name: Build installer package - env: - VERSION: ${{ steps.version.outputs.value }} - run: Scripts/build-pkg.sh + - name: Build CLI archive + run: Scripts/package-cli.sh - name: Publish GitHub Release uses: softprops/action-gh-release@v2 with: @@ -60,5 +87,5 @@ jobs: target_commitish: ${{ github.sha }} name: Nyathing ${{ steps.version.outputs.value }} generate_release_notes: true - files: out/Nyathing-${{ steps.version.outputs.value }}.pkg + files: out/nyathing-macos-arm64.tar.gz fail_on_unmatched_files: true diff --git a/Makefile b/Makefile index 3e64098..7a3fa60 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash .DEFAULT_GOAL := help -.PHONY: help format lint test package run install-app install-cli-link install uninstall reinstall +.PHONY: help format lint test archive run install uninstall help: @printf '%s\n' \ @@ -9,12 +9,10 @@ help: ' format Format Swift files in Sources/ and Tests/' \ ' lint Check Swift formatting' \ ' test Run the Swift test suite' \ - ' package Build the macOS installer package' \ + ' archive Build a downloadable CLI archive' \ ' run Run animations for five seconds (ANIMATIONS="a b" optional)' \ - ' install Install the app and CLI symlink' \ - ' install-app Build and install Nyathing.app in /Applications' \ - ' install-cli-link Create the /usr/local/bin/nyathing symlink' \ - ' uninstall Force-remove the app, CLI command, and user data' + ' install Build and install the CLI in $(PREFIX)/bin' \ + ' uninstall Remove the CLI and legacy app (keeps user data)' format: @find Sources Tests -type f -name '*.swift' -print0 | xargs -0 swift format format --in-place @@ -25,19 +23,16 @@ lint: test: swift test -package: - Scripts/build-pkg.sh +archive: + bash Scripts/package-cli.sh -install-app: - bash Scripts/install-app.sh +PREFIX ?= /usr/local -install-cli-link: - bash Scripts/install-cli-link.sh - -install: install-app install-cli-link +install: + PREFIX='$(PREFIX)' bash Scripts/install-cli.sh uninstall: - bash Scripts/force-uninstall.sh + PREFIX='$(PREFIX)' bash Scripts/force-uninstall.sh reinstall: uninstall install diff --git a/README.md b/README.md index bdccd42..f10d907 100644 --- a/README.md +++ b/README.md @@ -11,58 +11,50 @@ task is done. ## 🢃 Install -Download the installer package from the repository's **Releases** page. Open -the package and follow the Installer prompts to install `Nyathing.app` in -`/Applications`. The installer also creates the `/usr/local/bin/nyathing` -command symlink and requests administrator authorization to make these -system-wide changes. - -To remove the installed app and command, run in terminal: +Download `nyathing-macos-arm64.tar.gz` from the latest GitHub Release, then +extract and install it: ```sh -nyathing uninstall +mkdir -p "$HOME/.local/share/nyathing-archive" +tar -xzf ~/Downloads/nyathing-macos-arm64.tar.gz \ + -C "$HOME/.local/share/nyathing-archive" +cd "$HOME/.local/share/nyathing-archive" +PREFIX="$HOME/.local" ./install.sh ``` -**👮🏻‍♂️ Note** - -The app and package are **unsigned** and not notarized, so macOS may block the -app because it was downloaded from the internet. If macOS blocks it, try opening -the app once, then allow it in **System Settings → Privacy & Security**: - -1. Open **System Settings** and select **Privacy & Security**. -2. Scroll to the **Security** section. -3. Click **Open Anyway** next to the message about Nyathing being blocked, - then confirm when prompted. - -The **Open Anyway** option appears after you try to open the app. You may need -to enter your password or confirm with Touch ID. - -Alternatively, build and run `Nyathing` locally using the instructions in -[Build from source](#build-from-source); locally built apps are not quarantined. +This installs the command in `~/.local/bin` and the executable and resources +under `~/.local/libexec/nyathing`. Add `~/.local/bin` to your `PATH` if needed. +To uninstall, run `PREFIX="$HOME/.local" ./uninstall.sh` from the extracted +archive. User configuration and animations are kept in `~/.config/nyathing` (or +`$XDG_CONFIG_HOME/nyathing`). ## ⚒ Build from source -Requires macOS 12+ and Swift 5.9 or later. Run the commands below from the -repository root. +Requires macOS 12+ and Swift 5.9 or later. From the repository root, install +the CLI in `/usr/local/bin` with: -### Install from source +```sh +make install +``` -Install the menu-bar app in `/Applications`: +The installer builds Nyathing and asks for administrator authorization to +install the command in `/usr/local/bin` and the executable and resources under +`/usr/local/libexec/nyathing`. To install under +your home directory instead, without administrator authorization, run: ```sh -make install-app +make install PREFIX="$HOME/.local" ``` -To run Nyathing from a terminal, also create the CLI symlink in -`/usr/local/bin`: +This installs the command in `~/.local/bin`; add that directory to your `PATH` +if needed. To uninstall from that prefix, pass it again: ```sh -make install-cli-link +make uninstall PREFIX="$HOME/.local" ``` -The CLI symlink requires the app to be installed first. Each command asks -before replacing an existing app or symlink and requires administrator -authorization to install its files. +Without a custom prefix, use `make uninstall` to remove the default installation +from `/usr/local/bin`. Uninstall keeps user configuration and animations. ## Nyathing server @@ -166,7 +158,12 @@ custom animation: nyathing --animation nyan sleep 5 ``` -List valid installed animations by short name with: +The activity description is the command and its arguments (for example, +`sleep 5`). While the command runs, Nyathing sends a keepalive every 5 seconds +to keep the animation active. It stops when the command exits, or expires if +keepalives stop arriving. + +To get a list of valid installed animations by short name use: ```sh nyathing list diff --git a/Scripts/build-dmg.sh b/Scripts/build-dmg.sh deleted file mode 100755 index 8ce1407..0000000 --- a/Scripts/build-dmg.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -set -euo pipefail - -ROOT="$(cd "$(dirname "$0")/.." && pwd)" -cd "$ROOT" - -if [[ -z "${VERSION:-}" ]]; then - VERSION="$(git describe --tags --exact-match HEAD 2>/dev/null || true)" - VERSION="${VERSION#v}" -fi -if [[ ! "$VERSION" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then - echo "Set VERSION to a SemVer value like 1.2.3, or build from a vX.Y.Z tag." >&2 - exit 1 -fi - -APP_NAME="Nyathing.app" -APP_DIR="$ROOT/.build/dmg/$APP_NAME" -CONTENTS="$APP_DIR/Contents" -RESOURCES="$CONTENTS/Resources" -STAGE="$ROOT/.build/dmg-staging" -DIST="$ROOT/dist" - -swift build -c release -rm -rf "$APP_DIR" "$STAGE" "$DIST" -mkdir -p "$CONTENTS/MacOS" "$RESOURCES" "$STAGE" "$DIST" -cp .build/release/nyathing "$CONTENTS/MacOS/nyathing" -cp -R .build/release/Nyathing_Nyathing.bundle "$RESOURCES/" -ICONSET="$ROOT/.build/dmg/Nyathing.iconset" -swift Scripts/make-app-icon.swift assets/nyathing.png "$ICONSET" -iconutil -c icns "$ICONSET" -o "$RESOURCES/Nyathing.icns" -cat > "$CONTENTS/Info.plist" < - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - nyathing - CFBundleIdentifier - com.nyathing.Nyathing - CFBundleIconFile - Nyathing - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Nyathing - CFBundlePackageType - APPL - CFBundleShortVersionString - $VERSION - CFBundleVersion - $VERSION - LSMinimumSystemVersion - 12.0 - LSUIElement - - - -PLIST - -codesign --force --deep --sign - "$APP_DIR" -codesign --verify --deep --strict --verbose=2 "$APP_DIR" - -cp -R "$APP_DIR" "$STAGE/" -ln -s /Applications "$STAGE/Applications" -hdiutil create \ - -volname "Nyathing" \ - -srcfolder "$STAGE" \ - -ov \ - -format UDZO \ - "$DIST/nyathing-$VERSION.dmg" - -echo "Created $DIST/nyathing-$VERSION.dmg" diff --git a/Scripts/build-pkg.sh b/Scripts/build-pkg.sh deleted file mode 100755 index cc18ce6..0000000 --- a/Scripts/build-pkg.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -set -euo pipefail - -ROOT="$(cd "$(dirname "$0")/.." && pwd)" -cd "$ROOT" - -if [[ -z "${VERSION:-}" ]]; then - VERSION="$(git describe --tags --exact-match HEAD 2>/dev/null || true)" - VERSION="${VERSION#v}" -fi -if [[ ! "$VERSION" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then - echo "Set VERSION to a SemVer value like 1.2.3, or build from a vX.Y.Z tag." >&2 - exit 1 -fi - -BUILD_DIR="$ROOT/.build/pkg" -APP_DIR="$BUILD_DIR/Nyathing.app" -CONTENTS="$APP_DIR/Contents" -RESOURCES="$CONTENTS/Resources" -PAYLOAD="$BUILD_DIR/payload" -PACKAGE_DIR="$BUILD_DIR/package-scripts" -COMPONENT_PLIST="$BUILD_DIR/components.plist" -OUTPUT_DIR="$ROOT/out" -OUTPUT="$OUTPUT_DIR/Nyathing-$VERSION.pkg" -COMPONENT_PACKAGE="$BUILD_DIR/Nyathing-component.pkg" -INSTALLER_RESOURCES="$BUILD_DIR/installer-resources" - -swift build -c release -rm -rf "$BUILD_DIR" "$OUTPUT" -mkdir -p "$CONTENTS/MacOS" "$RESOURCES" "$PAYLOAD/Applications" "$PACKAGE_DIR" \ - "$INSTALLER_RESOURCES" "$OUTPUT_DIR" -cp .build/release/nyathing "$CONTENTS/MacOS/nyathing" -cp -R .build/release/Nyathing_Nyathing.bundle "$RESOURCES/" -ICONSET="$BUILD_DIR/Nyathing.iconset" -swift Scripts/make-app-icon.swift assets/nyathing.png "$ICONSET" -iconutil -c icns "$ICONSET" -o "$RESOURCES/Nyathing.icns" -cat > "$CONTENTS/Info.plist" < - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - nyathing - CFBundleIdentifier - com.nyathing.Nyathing - CFBundleIconFile - Nyathing - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Nyathing - CFBundlePackageType - APPL - CFBundleShortVersionString - $VERSION - CFBundleVersion - $VERSION - LSMinimumSystemVersion - 12.0 - LSUIElement - - - -PLIST - -cp -R "$APP_DIR" "$PAYLOAD/Applications/" -cp Scripts/pkg-preinstall "$PACKAGE_DIR/preinstall" -cp Scripts/pkg-postinstall "$PACKAGE_DIR/postinstall" -chmod 755 "$PACKAGE_DIR/preinstall" "$PACKAGE_DIR/postinstall" -pkgbuild --analyze --root "$PAYLOAD" "$COMPONENT_PLIST" -/usr/libexec/PlistBuddy -c 'Set :0:BundleIsRelocatable false' "$COMPONENT_PLIST" -pkgbuild \ - --root "$PAYLOAD" \ - --component-plist "$COMPONENT_PLIST" \ - --identifier com.nyathing.Nyathing.pkg \ - --version "$VERSION" \ - --install-location / \ - --scripts "$PACKAGE_DIR" \ - "$COMPONENT_PACKAGE" - -cp Scripts/installer-resources/welcome.html "$INSTALLER_RESOURCES/welcome.html" -sips -Z 56 assets/nyathing.png --out "$INSTALLER_RESOURCES/nyathing.png" >/dev/null -productbuild \ - --distribution Scripts/installer-resources/Distribution.xml \ - --resources "$INSTALLER_RESOURCES" \ - --package-path "$BUILD_DIR" \ - "$OUTPUT" - -echo "Created $OUTPUT" diff --git a/Scripts/force-uninstall.sh b/Scripts/force-uninstall.sh index c83cd9e..6ea5186 100644 --- a/Scripts/force-uninstall.sh +++ b/Scripts/force-uninstall.sh @@ -1,15 +1,16 @@ #!/bin/bash set -euo pipefail -app_path="/Applications/Nyathing.app" -cli_path="/usr/local/bin/nyathing" +prefix="${PREFIX:-/usr/local}" +bin_dir="$prefix/bin" +cli_path="$bin_dir/nyathing" +libexec_dir="$prefix/libexec/nyathing" +legacy_app_path="/Applications/Nyathing.app" launch_agent="$HOME/Library/LaunchAgents/com.nyathing.Nyathing.plist" -config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/nyathing" -state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/nyathing" launchctl bootout "gui/$(id -u)" "$launch_agent" 2>/dev/null || true -# Stop Nyathing before removing its app bundle and executable. +# Stop Nyathing before removing its executable and resources. /usr/bin/pkill -TERM -x nyathing 2>/dev/null || true for _ in {1..5}; do if ! /usr/bin/pgrep -x nyathing >/dev/null 2>&1; then break; fi @@ -17,17 +18,26 @@ for _ in {1..5}; do done /usr/bin/pkill -KILL -x nyathing 2>/dev/null || true -sudo /bin/rm -rf -- \ - "$app_path" \ - "$cli_path" \ - "$launch_agent" \ - "$config_dir" \ - "$state_dir" +remove_path() { + local path="$1" parent="$(dirname "$1")" + [[ -e "$path" || -L "$path" ]] || return 0 + while [[ ! -e "$parent" ]]; do parent="$(dirname "$parent")"; done + if [[ -w "$parent" ]]; then + /bin/rm -rf -- "$path" + else + sudo /bin/rm -rf -- "$path" + fi +} -if [[ -e "$app_path" || -L "$app_path" || -e "$cli_path" || -L "$cli_path" \ - || -e "$launch_agent" || -e "$config_dir" || -e "$state_dir" ]]; then - echo "Nyathing uninstall failed: some app files or user data remain." >&2 +remove_path "$cli_path" +remove_path "$libexec_dir" +remove_path "$legacy_app_path" +remove_path "$launch_agent" + +if [[ -e "$cli_path" || -L "$cli_path" || -e "$libexec_dir" \ + || -e "$legacy_app_path" || -e "$launch_agent" ]]; then + echo "Nyathing uninstall failed: some installed files remain." >&2 exit 1 fi -echo "Nyathing and its user data were removed." +echo "Nyathing was removed. User configuration and state were kept." diff --git a/Scripts/install-app.sh b/Scripts/install-app.sh deleted file mode 100644 index 786f6b1..0000000 --- a/Scripts/install-app.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -set -euo pipefail - -ROOT="$(cd "$(dirname "$0")/.." && pwd)" -APP_PATH="/Applications/Nyathing.app" -BUILD_DIR="$ROOT/.build/source-install" -STAGED_APP="$BUILD_DIR/Nyathing.app" - -if [[ -e "$APP_PATH" || -L "$APP_PATH" ]]; then - read -r -p "Replace existing $APP_PATH? [y/N] " answer - case "$answer" in - y|Y|yes|Yes|YES) ;; - *) echo "Installation cancelled."; exit 0 ;; - esac -fi - -cd "$ROOT" -swift build -c release -rm -rf "$BUILD_DIR" -mkdir -p "$STAGED_APP/Contents/MacOS" "$STAGED_APP/Contents/Resources" -cp .build/release/nyathing "$STAGED_APP/Contents/MacOS/nyathing" -cp -R .build/release/Nyathing_Nyathing.bundle "$STAGED_APP/Contents/Resources/" -ICONSET="$BUILD_DIR/Nyathing.iconset" -swift Scripts/make-app-icon.swift assets/nyathing.png "$ICONSET" -iconutil -c icns "$ICONSET" -o "$STAGED_APP/Contents/Resources/Nyathing.icns" -cat > "$STAGED_APP/Contents/Info.plist" <<'PLIST' - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - nyathing - CFBundleIdentifier - com.nyathing.Nyathing - CFBundleIconFile - Nyathing - CFBundleName - Nyathing - CFBundlePackageType - APPL - LSMinimumSystemVersion - 12.0 - LSUIElement - - - -PLIST - -sudo /bin/rm -rf -- "$APP_PATH" -sudo /usr/bin/ditto "$STAGED_APP" "$APP_PATH" -echo "Installed Nyathing.app in /Applications." diff --git a/Scripts/install-cli-link.sh b/Scripts/install-cli-link.sh deleted file mode 100644 index a67a202..0000000 --- a/Scripts/install-cli-link.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -euo pipefail - -APP_EXECUTABLE="/Applications/Nyathing.app/Contents/MacOS/nyathing" -CLI_PATH="/usr/local/bin/nyathing" - -if [[ ! -x "$APP_EXECUTABLE" ]]; then - echo "Install Nyathing.app in /Applications before creating the CLI link." >&2 - exit 1 -fi -if [[ -e "$CLI_PATH" || -L "$CLI_PATH" ]]; then - if [[ -d "$CLI_PATH" && ! -L "$CLI_PATH" ]]; then - echo "Cannot replace $CLI_PATH because it is a directory." >&2 - exit 1 - fi - read -r -p "Replace existing $CLI_PATH? [y/N] " answer - case "$answer" in - y|Y|yes|Yes|YES) sudo /bin/rm -f -- "$CLI_PATH" ;; - *) echo "Installation cancelled."; exit 0 ;; - esac -fi - -sudo /bin/mkdir -p /usr/local/bin -sudo /bin/ln -s "$APP_EXECUTABLE" "$CLI_PATH" -echo "Created CLI link at $CLI_PATH." diff --git a/Scripts/install-cli.sh b/Scripts/install-cli.sh new file mode 100644 index 0000000..2e0d8c7 --- /dev/null +++ b/Scripts/install-cli.sh @@ -0,0 +1,50 @@ +#!/bin/bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" +PREFIX="${PREFIX:-/usr/local}" +SOURCE_DIR="${1:-}" + +if [[ -z "$SOURCE_DIR" ]]; then + swift build -c release + SOURCE_DIR="$ROOT/.build/release" +fi +SOURCE_DIR="$(cd "$SOURCE_DIR" && pwd)" +BIN_DIR="$PREFIX/bin" +LIBEXEC_DIR="$PREFIX/libexec/nyathing" + +permission_check="$PREFIX" +while [[ ! -e "$permission_check" ]]; do + permission_check="$(dirname "$permission_check")" +done +if [[ -w "$permission_check" ]]; then + needs_sudo=false +else + needs_sudo=true +fi + +run_install() { + if [[ "$needs_sudo" == true ]]; then + sudo "$@" + else + "$@" + fi +} + +run_install mkdir -p "$BIN_DIR" "$LIBEXEC_DIR" +run_install install -m 755 "$SOURCE_DIR/nyathing" "$LIBEXEC_DIR/nyathing" +run_install rm -rf "$LIBEXEC_DIR/Nyathing_Nyathing.bundle" +run_install ditto "$SOURCE_DIR/Nyathing_Nyathing.bundle" \ + "$LIBEXEC_DIR/Nyathing_Nyathing.bundle" + +wrapper="$BIN_DIR/nyathing" +wrapper_content='#!/bin/sh +SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" +exec "$SCRIPT_DIR/../libexec/nyathing/nyathing" "$@" +' +wrapper_tmp="$(mktemp)" +trap 'rm -f "$wrapper_tmp"' EXIT +printf '%s' "$wrapper_content" > "$wrapper_tmp" +run_install install -m 755 "$wrapper_tmp" "$wrapper" +echo "Installed nyathing in $BIN_DIR (resources in $LIBEXEC_DIR)." diff --git a/Scripts/installer-resources/Distribution.xml b/Scripts/installer-resources/Distribution.xml deleted file mode 100644 index db7066b..0000000 --- a/Scripts/installer-resources/Distribution.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - Nyathing - - - - - - - - - - Nyathing-component.pkg - diff --git a/Scripts/installer-resources/welcome.html b/Scripts/installer-resources/welcome.html deleted file mode 100644 index c963fee..0000000 --- a/Scripts/installer-resources/welcome.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - -

Install Nyathing

-

👻 Nyathing displays playful animations in the macOS menu bar while commands - run.

-

This installer installs Nyathing.app in - /Applications and creates a symlink at - /usr/local/bin/nyathing so you can launch Nyathing from - Terminal.

-

⚠️ You’ll be asked to enter your administrator password during - installation to authorize these changes.

-
- - diff --git a/Scripts/make-app-icon.swift b/Scripts/make-app-icon.swift deleted file mode 100644 index 57367f2..0000000 --- a/Scripts/make-app-icon.swift +++ /dev/null @@ -1,66 +0,0 @@ -import AppKit -import Foundation - -let inputURL = URL(fileURLWithPath: CommandLine.arguments[1]) -let outputURL = URL(fileURLWithPath: CommandLine.arguments[2], isDirectory: true) -guard let source = NSImage(contentsOf: inputURL), source.size.width > 0, source.size.height > 0 else { - fatalError("Unable to load app icon image at \(inputURL.path)") -} -try FileManager.default.createDirectory(at: outputURL, withIntermediateDirectories: true) - -let iconSizes: [(String, Int)] = [ - ("icon_16x16.png", 16), - ("icon_16x16@2x.png", 32), - ("icon_32x32.png", 32), - ("icon_32x32@2x.png", 64), - ("icon_128x128.png", 128), - ("icon_128x128@2x.png", 256), - ("icon_256x256.png", 256), - ("icon_256x256@2x.png", 512), - ("icon_512x512.png", 512), - ("icon_512x512@2x.png", 1024), -] - -for (filename, pixels) in iconSizes { - guard - let bitmap = NSBitmapImageRep( - bitmapDataPlanes: nil, - pixelsWide: pixels, - pixelsHigh: pixels, - bitsPerSample: 8, - samplesPerPixel: 4, - hasAlpha: true, - isPlanar: false, - colorSpaceName: .deviceRGB, - bytesPerRow: 0, - bitsPerPixel: 0 - ), - let context = NSGraphicsContext(bitmapImageRep: bitmap) - else { - fatalError("Unable to create \(pixels)x\(pixels) icon bitmap") - } - - NSGraphicsContext.saveGraphicsState() - NSGraphicsContext.current = context - context.imageInterpolation = .high - NSColor.clear.setFill() - NSRect(x: 0, y: 0, width: pixels, height: pixels).fill() - - let scale = min(CGFloat(pixels) / source.size.width, CGFloat(pixels) / source.size.height) - let width = source.size.width * scale - let height = source.size.height * scale - source.draw( - in: NSRect(x: (CGFloat(pixels) - width) / 2, y: (CGFloat(pixels) - height) / 2, - width: width, height: height), - from: .zero, - operation: .sourceOver, - fraction: 1 - ) - context.flushGraphics() - NSGraphicsContext.restoreGraphicsState() - - guard let data = bitmap.representation(using: .png, properties: [:]) else { - fatalError("Unable to encode \(pixels)x\(pixels) icon") - } - try data.write(to: outputURL.appendingPathComponent(filename)) -} diff --git a/Scripts/package-cli.sh b/Scripts/package-cli.sh new file mode 100755 index 0000000..8d97c2e --- /dev/null +++ b/Scripts/package-cli.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" + +swift build -c release +STAGING="$ROOT/.build/cli-archive" +OUTPUT_DIR="$ROOT/out/nyathing-macos-arm64" +OUTPUT="$ROOT/out/nyathing-macos-arm64.tar.gz" +rm -rf "$STAGING" +mkdir -p "$STAGING" +cp .build/release/nyathing "$STAGING/nyathing" +cp -R .build/release/Nyathing_Nyathing.bundle "$STAGING/Nyathing_Nyathing.bundle" +cp Scripts/install-cli.sh "$STAGING/install-cli.sh" +cp Scripts/force-uninstall.sh "$STAGING/uninstall.sh" +cat > "$STAGING/install.sh" <<'INSTALLER' +#!/bin/bash +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PREFIX="${PREFIX:-/usr/local}" bash "$SCRIPT_DIR/install-cli.sh" "$SCRIPT_DIR" +INSTALLER +chmod 755 "$STAGING/install.sh" "$STAGING/install-cli.sh" "$STAGING/uninstall.sh" +mkdir -p "$ROOT/out" +rm -rf "$OUTPUT_DIR" +cp -R "$STAGING" "$OUTPUT_DIR" +rm -f "$OUTPUT" +tar -czf "$OUTPUT" -C "$STAGING" . +echo "Created $OUTPUT" diff --git a/Scripts/pkg-postinstall b/Scripts/pkg-postinstall deleted file mode 100755 index 252fd7c..0000000 --- a/Scripts/pkg-postinstall +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -euo pipefail - -mkdir -p /usr/local/bin -ln -s /Applications/Nyathing.app/Contents/MacOS/nyathing /usr/local/bin/nyathing diff --git a/Scripts/pkg-preinstall b/Scripts/pkg-preinstall deleted file mode 100755 index e14de4d..0000000 --- a/Scripts/pkg-preinstall +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -euo pipefail - -CLI_PATH="/usr/local/bin/nyathing" -CLI_TARGET="/Applications/Nyathing.app/Contents/MacOS/nyathing" -if [[ -L "$CLI_PATH" ]]; then - if [[ "$(/usr/bin/readlink "$CLI_PATH")" == "$CLI_TARGET" ]]; then - /bin/rm -f -- "$CLI_PATH" - else - echo "Cannot install Nyathing: $CLI_PATH is an unrelated symlink." >&2 - exit 1 - fi -elif [[ -e "$CLI_PATH" ]]; then - echo "Cannot install Nyathing: $CLI_PATH already exists and is not a symlink." >&2 - exit 1 -fi diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 00d771d..16f10a1 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -50,7 +50,6 @@ struct CLIArguments { Usage: nyathing [--animation NAME | -a NAME] COMMAND [ARGUMENT ...] - nyathing uninstall nyathing server start|stop|status nyathing client start|keepalive|stop nyathing list @@ -60,7 +59,6 @@ struct CLIArguments { Commands: COMMAND [ARGUMENT ...] Run a command while showing an activity animation. - uninstall Remove the installed app and CLI command. server Manage the background server (start, stop, status). client Start, refresh, or stop an activity. list List available valid animations. @@ -117,9 +115,6 @@ enum NyathingCLI { static let builtInGhostAnimation = "__built_in_ghost__" static func run(_ arguments: [String]) -> Int32 { - if arguments == ["uninstall"] { - return NyathingUninstaller.run() - } if arguments.count == 2, arguments[0] == "completion" { guard let script = ShellCompletion.script(for: arguments[1]) else { FileHandle.standardError.write(Data("Supported shells: zsh, bash\n".utf8)) @@ -443,7 +438,7 @@ enum NyathingCLI { } enum ShellCompletion { - static let supportedCommands = ["server", "client", "list", "uninstall", "completion"] + static let supportedCommands = ["server", "client", "list", "completion"] static func script(for shell: String) -> String? { let commands = supportedCommands.joined(separator: " ") diff --git a/Sources/Nyathing/Uninstall.swift b/Sources/Nyathing/Uninstall.swift deleted file mode 100644 index 8f282b2..0000000 --- a/Sources/Nyathing/Uninstall.swift +++ /dev/null @@ -1,113 +0,0 @@ -import Darwin -import Foundation - -/// Coordinates synchronous end-user removal of the app and CLI command. -enum NyathingUninstaller { - static let appPath = "/Applications/Nyathing.app" - static let symlinkPath = "/usr/local/bin/nyathing" - static let prompt = "Remove Nyathing configuration and user animations? [y/N]" - static func run() -> Int32 { - do { - let removeUserData = try confirmUserDataRemoval() - try requestAuthorization(removeUserData: removeUserData) - FileHandle.standardError.write(Data("Nyathing was successfully uninstalled.\n".utf8)) - return 0 - } catch { - FileHandle.standardError.write( - Data("nyathing: Uninstall failed: \(error.localizedDescription)\n".utf8)) - return 1 - } - } - - static func confirmUserDataRemoval() throws -> Bool { - FileHandle.standardOutput.write(Data((prompt + " ").utf8)) - guard let answer = readLine() else { return false } - return try parseConfirmation(answer) - } - - static func parseConfirmation(_ answer: String) throws -> Bool { - switch answer.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() { - case "", "n", "no": return false - case "y", "yes": return true - default: throw UninstallError.invalidConfirmation - } - } - - private static func requestAuthorization(removeUserData: Bool) throws { - let pid = getpid() - let executablePath = appPath + "/Contents/MacOS/nyathing" - let removalCommand = """ - attempts=0 - while :; do - pids=$(/usr/sbin/lsof -t \(shellQuote(executablePath)) 2>/dev/null) - lsof_status=$? - if [ "$lsof_status" -gt 1 ]; then exit 1; fi - other_pids= - for process_pid in $pids; do - if [ "$process_pid" != "\(pid)" ]; then other_pids="$other_pids $process_pid"; fi - done - if [ -z "$other_pids" ]; then break; fi - if [ "$attempts" -lt 1 ]; then signal=TERM; else signal=KILL; fi - for process_pid in $other_pids; do - /bin/kill -"$signal" "$process_pid" 2>/dev/null || true - done - attempts=$((attempts + 1)) - if [ "$attempts" -ge 10 ]; then exit 1; fi - /bin/sleep 1 - done - /bin/rm -f -- \(shellQuote(symlinkPath)) && /bin/rm -rf -- \(shellQuote(appPath)) && - [ ! -e \(shellQuote(symlinkPath)) ] && [ ! -L \(shellQuote(symlinkPath)) ] && - [ ! -e \(shellQuote(appPath)) ] && [ ! -L \(shellQuote(appPath)) ] - """ - var commands = [removalCommand] - if removeUserData { - let configuration = AppConfiguration.configurationDirectory.path - commands.append("/bin/rm -rf -- \(shellQuote(configuration + "/animations"))") - commands.append("/bin/rm -rf -- \(shellQuote(configuration))") - } - let shellCommand = commands.joined(separator: " && ") - let appleScript = - "do shell script \"\(appleScriptQuote(shellCommand))\" with administrator privileges" - let process = Process() - process.executableURL = URL(fileURLWithPath: "/usr/bin/osascript") - process.arguments = ["-e", appleScript] - let errorPipe = Pipe() - process.standardError = errorPipe - do { - try process.run() - } catch { - throw UninstallError.authorization(error.localizedDescription) - } - process.waitUntilExit() - guard process.terminationStatus == 0 else { - let details = String( - data: errorPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)? - .trimmingCharacters(in: .whitespacesAndNewlines) - throw UninstallError.authorization(details?.isEmpty == false ? details! : nil) - } - } - - private static func shellQuote(_ value: String) -> String { - "'" + value.replacingOccurrences(of: "'", with: "'\\''") + "'" - } - - private static func appleScriptQuote(_ value: String) -> String { - value.replacingOccurrences(of: "\\", with: "\\\\") - .replacingOccurrences(of: "\"", with: "\\\"") - } -} - -enum UninstallError: LocalizedError { - case invalidConfirmation - case authorization(String?) - - var errorDescription: String? { - switch self { - case .invalidConfirmation: - return "Please answer yes or no; user data has not been removed." - case .authorization(let details): - return details.map { "Administrator authorization failed: \($0)" } - ?? "Administrator authorization was canceled or failed." - } - } -} From f28c729cfa356f28db0ccc63f5b12da18ad1eb43 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 11:15:32 +0400 Subject: [PATCH 30/43] Refine CLI archive workflow --- .github/workflows/ci.yml | 10 +++++----- Makefile | 5 +++-- README.md | 20 +++++++++++++++++++- Scripts/package-cli.sh | 5 +++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64d734c..d67c889 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: runs-on: macos-26 steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Check formatting run: make lint - name: Run tests @@ -30,7 +30,7 @@ jobs: runs-on: macos-26 steps: - name: Check out selected branch - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Build CLI archive run: Scripts/package-cli.sh - name: Test installed archive @@ -44,7 +44,7 @@ jobs: test -x "$prefix/libexec/nyathing/nyathing" test -d "$prefix/libexec/nyathing/Nyathing_Nyathing.bundle" - name: Upload CLI archive - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: nyathing-macos-arm64 path: out/nyathing-macos-arm64/* @@ -60,7 +60,7 @@ jobs: contents: write steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Validate release tag and target branch @@ -81,7 +81,7 @@ jobs: - name: Build CLI archive run: Scripts/package-cli.sh - name: Publish GitHub Release - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@v3 with: tag_name: ${{ github.ref_name }} target_commitish: ${{ github.sha }} diff --git a/Makefile b/Makefile index 7a3fa60..570ea26 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash .DEFAULT_GOAL := help -.PHONY: help format lint test archive run install uninstall +.PHONY: help format lint test archive run install uninstall reinstall help: @printf '%s\n' \ @@ -12,7 +12,8 @@ help: ' archive Build a downloadable CLI archive' \ ' run Run animations for five seconds (ANIMATIONS="a b" optional)' \ ' install Build and install the CLI in $(PREFIX)/bin' \ - ' uninstall Remove the CLI and legacy app (keeps user data)' + ' uninstall Remove the CLI and legacy app (keeps user data)' \ + ' reinstall Reinstall Nyathing using the selected PREFIX' format: @find Sources Tests -type f -name '*.swift' -print0 | xargs -0 swift format format --in-place diff --git a/README.md b/README.md index f10d907..a0c8959 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Nyathing brings background processes to life with playful animations in the macOS menu bar. Clients start an animation when work begins and stop it when the task is done. -## 🢃 Install +## 🢃 Install from archive Download `nyathing-macos-arm64.tar.gz` from the latest GitHub Release, then extract and install it: @@ -28,6 +28,24 @@ To uninstall, run `PREFIX="$HOME/.local" ./uninstall.sh` from the extracted archive. User configuration and animations are kept in `~/.config/nyathing` (or `$XDG_CONFIG_HOME/nyathing`). +**👮🏻‍♂️ Note** + +Nyathing is **unsigned** and not notarized, so macOS may block it because it +was downloaded from the internet. If macOS blocks Nyathing, try running it once +from Terminal, then allow it in **System Settings → Privacy & Security**: + +1. Open **System Settings** and select **Privacy & Security**. +2. Scroll to the **Security** section. +3. Click **Open Anyway** next to the message about Nyathing being blocked, + then confirm when prompted. This option may only appear for app launches. + +The **Open Anyway** option may appear after you try to open the app; it may +not be available for a CLI binary. You may need to enter your password or +confirm with Touch ID. + +Alternatively, build and run Nyathing locally using the instructions in +[Build from source](#build-from-source); locally built binaries are not quarantined. + ## ⚒ Build from source Requires macOS 12+ and Swift 5.9 or later. From the repository root, install diff --git a/Scripts/package-cli.sh b/Scripts/package-cli.sh index 8d97c2e..b7c679a 100755 --- a/Scripts/package-cli.sh +++ b/Scripts/package-cli.sh @@ -4,6 +4,11 @@ set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" +if [[ "$(uname -m)" != "arm64" ]]; then + echo "The macOS arm64 archive must be built on an arm64 runner." >&2 + exit 1 +fi + swift build -c release STAGING="$ROOT/.build/cli-archive" OUTPUT_DIR="$ROOT/out/nyathing-macos-arm64" From edf94be5bfb0c65524ae606fa30b69c855f51eb9 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 14:55:53 +0400 Subject: [PATCH 31/43] Harden script cleanup paths Validate install prefixes and restrict removals to expected targets. Use isolated temporary directories for packaging and wrapper creation, and clean them up only after checking their paths. . --- Makefile | 6 ++++-- Scripts/force-uninstall.sh | 12 ++++++++++++ Scripts/install-cli.sh | 29 ++++++++++++++++++++++++---- Scripts/package-cli.sh | 36 +++++++++++++++++++++++++++-------- Scripts/run-test-animation.py | 9 ++++++++- 5 files changed, 77 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 570ea26..2757e05 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ help: ' lint Check Swift formatting' \ ' test Run the Swift test suite' \ ' archive Build a downloadable CLI archive' \ - ' run Run animations for five seconds (ANIMATIONS="a b" optional)' \ + ' run Run animations (DURATION=5 seconds; ANIMATIONS="a b" optional)' \ ' install Build and install the CLI in $(PREFIX)/bin' \ ' uninstall Remove the CLI and legacy app (keeps user data)' \ ' reinstall Reinstall Nyathing using the selected PREFIX' @@ -37,6 +37,8 @@ uninstall: reinstall: uninstall install +DURATION ?= 5 + run: swift build - ANIMATION='$(ANIMATION)' ANIMATIONS='$(ANIMATIONS)' python3 Scripts/run-test-animation.py + ANIMATION='$(ANIMATION)' ANIMATIONS='$(ANIMATIONS)' DURATION='$(DURATION)' python3 Scripts/run-test-animation.py diff --git a/Scripts/force-uninstall.sh b/Scripts/force-uninstall.sh index 6ea5186..c9494de 100644 --- a/Scripts/force-uninstall.sh +++ b/Scripts/force-uninstall.sh @@ -2,6 +2,11 @@ set -euo pipefail prefix="${PREFIX:-/usr/local}" +if [[ "$prefix" != /* || "$prefix" == / || "$prefix" == "$HOME" \ + || "$prefix" == "$HOME"/* || "/$prefix/" == */../* ]]; then + echo "Refusing unsafe PREFIX: $prefix" >&2 + exit 1 +fi bin_dir="$prefix/bin" cli_path="$bin_dir/nyathing" libexec_dir="$prefix/libexec/nyathing" @@ -20,6 +25,13 @@ done remove_path() { local path="$1" parent="$(dirname "$1")" + case "$path" in + "$cli_path"|"$libexec_dir"|"$legacy_app_path"|"$launch_agent") ;; + *) echo "Refusing to remove unexpected path: $path" >&2; return 1 ;; + esac + [[ "$path" != / && -n "$path" ]] || { + echo "Refusing unsafe removal path: $path" >&2; return 1; + } [[ -e "$path" || -L "$path" ]] || return 0 while [[ ! -e "$parent" ]]; do parent="$(dirname "$parent")"; done if [[ -w "$parent" ]]; then diff --git a/Scripts/install-cli.sh b/Scripts/install-cli.sh index 2e0d8c7..4722e8f 100644 --- a/Scripts/install-cli.sh +++ b/Scripts/install-cli.sh @@ -4,13 +4,21 @@ set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" PREFIX="${PREFIX:-/usr/local}" +if [[ "$PREFIX" != /* || "$PREFIX" == / || "$PREFIX" == "$HOME" \ + || "$PREFIX" == "$HOME"/* || "/$PREFIX/" == */../* ]]; then + echo "Refusing unsafe PREFIX: $PREFIX" >&2 + exit 1 +fi SOURCE_DIR="${1:-}" if [[ -z "$SOURCE_DIR" ]]; then swift build -c release SOURCE_DIR="$ROOT/.build/release" fi -SOURCE_DIR="$(cd "$SOURCE_DIR" && pwd)" +[[ -d "$SOURCE_DIR" && ! -L "$SOURCE_DIR" ]] || { + echo "Invalid install source directory: $SOURCE_DIR" >&2; exit 1; +} +SOURCE_DIR="$(cd "$SOURCE_DIR" && pwd -P)" BIN_DIR="$PREFIX/bin" LIBEXEC_DIR="$PREFIX/libexec/nyathing" @@ -34,7 +42,13 @@ run_install() { run_install mkdir -p "$BIN_DIR" "$LIBEXEC_DIR" run_install install -m 755 "$SOURCE_DIR/nyathing" "$LIBEXEC_DIR/nyathing" -run_install rm -rf "$LIBEXEC_DIR/Nyathing_Nyathing.bundle" +bundle_path="$LIBEXEC_DIR/Nyathing_Nyathing.bundle" +if [[ -e "$bundle_path" || -L "$bundle_path" ]]; then + [[ ! -L "$bundle_path" && "$bundle_path" == "$PREFIX/libexec/nyathing/Nyathing_Nyathing.bundle" ]] || { + echo "Refusing to remove unexpected bundle path: $bundle_path" >&2; exit 1; + } + run_install rm -rf -- "$bundle_path" +fi run_install ditto "$SOURCE_DIR/Nyathing_Nyathing.bundle" \ "$LIBEXEC_DIR/Nyathing_Nyathing.bundle" @@ -43,8 +57,15 @@ wrapper_content='#!/bin/sh SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" exec "$SCRIPT_DIR/../libexec/nyathing/nyathing" "$@" ' -wrapper_tmp="$(mktemp)" -trap 'rm -f "$wrapper_tmp"' EXIT +wrapper_tmp_dir="$(mktemp -d "${TMPDIR:-/tmp}/nyathing-install.XXXXXX")" +wrapper_tmp="$wrapper_tmp_dir/wrapper" +cleanup() { + case "$wrapper_tmp_dir" in + "${TMPDIR:-/tmp}"/nyathing-install.*) rm -rf -- "$wrapper_tmp_dir" ;; + *) echo "Refusing to remove unexpected temporary path: $wrapper_tmp_dir" >&2; exit 1 ;; + esac +} +trap cleanup EXIT printf '%s' "$wrapper_content" > "$wrapper_tmp" run_install install -m 755 "$wrapper_tmp" "$wrapper" echo "Installed nyathing in $BIN_DIR (resources in $LIBEXEC_DIR)." diff --git a/Scripts/package-cli.sh b/Scripts/package-cli.sh index b7c679a..08ffa4e 100755 --- a/Scripts/package-cli.sh +++ b/Scripts/package-cli.sh @@ -10,11 +10,22 @@ if [[ "$(uname -m)" != "arm64" ]]; then fi swift build -c release -STAGING="$ROOT/.build/cli-archive" -OUTPUT_DIR="$ROOT/out/nyathing-macos-arm64" -OUTPUT="$ROOT/out/nyathing-macos-arm64.tar.gz" -rm -rf "$STAGING" -mkdir -p "$STAGING" +BUILD_DIR="$ROOT/.build" +OUT_DIR="$ROOT/out" +mkdir -p "$BUILD_DIR" "$OUT_DIR" +BUILD_DIR="$(cd "$BUILD_DIR" && pwd -P)" +OUT_DIR="$(cd "$OUT_DIR" && pwd -P)" +STAGING="$(mktemp -d "$BUILD_DIR/nyathing-cli.XXXXXX")" +OUTPUT_DIR="$OUT_DIR/nyathing-macos-arm64" +OUTPUT="$OUT_DIR/nyathing-macos-arm64.tar.gz" +cleanup() { + trap - EXIT + case "$STAGING" in + "$BUILD_DIR"/nyathing-cli.*) rm -rf -- "$STAGING" ;; + *) echo "Refusing to remove unexpected staging path: $STAGING" >&2; exit 1 ;; + esac +} +trap cleanup EXIT cp .build/release/nyathing "$STAGING/nyathing" cp -R .build/release/Nyathing_Nyathing.bundle "$STAGING/Nyathing_Nyathing.bundle" cp Scripts/install-cli.sh "$STAGING/install-cli.sh" @@ -26,9 +37,18 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PREFIX="${PREFIX:-/usr/local}" bash "$SCRIPT_DIR/install-cli.sh" "$SCRIPT_DIR" INSTALLER chmod 755 "$STAGING/install.sh" "$STAGING/install-cli.sh" "$STAGING/uninstall.sh" -mkdir -p "$ROOT/out" -rm -rf "$OUTPUT_DIR" +if [[ -e "$OUTPUT_DIR" || -L "$OUTPUT_DIR" ]]; then + [[ ! -L "$OUTPUT_DIR" && "$OUTPUT_DIR" == "$OUT_DIR/nyathing-macos-arm64" ]] || { + echo "Refusing to replace unexpected output path: $OUTPUT_DIR" >&2; exit 1; + } + rm -rf -- "$OUTPUT_DIR" +fi cp -R "$STAGING" "$OUTPUT_DIR" -rm -f "$OUTPUT" +if [[ -e "$OUTPUT" || -L "$OUTPUT" ]]; then + [[ ! -d "$OUTPUT" && "$OUTPUT" == "$OUT_DIR/nyathing-macos-arm64.tar.gz" ]] || { + echo "Refusing to replace unexpected archive path: $OUTPUT" >&2; exit 1; + } + rm -f -- "$OUTPUT" +fi tar -czf "$OUTPUT" -C "$STAGING" . echo "Created $OUTPUT" diff --git a/Scripts/run-test-animation.py b/Scripts/run-test-animation.py index a276dda..b5d8ac8 100644 --- a/Scripts/run-test-animation.py +++ b/Scripts/run-test-animation.py @@ -68,6 +68,13 @@ def configured_value(text, key, default): settings = config_path.read_text(encoding="utf-8") if config_path.exists() else "" interval = 5.0 + try: + duration = float(os.environ.get("DURATION", "5")) + except ValueError as error: + raise ValueError("DURATION must be a positive number of seconds") from error + if not 0 < duration < float("inf"): + raise ValueError("DURATION must be a positive finite number of seconds") + animations = os.environ.get("ANIMATIONS", "").replace(",", " ").split() if not animations: animation = os.environ.get("ANIMATION") @@ -86,7 +93,7 @@ def configured_value(text, key, default): print(f"Started {animation} ({activity_id})") keepalive_delay = interval - run_deadline = time.monotonic() + 5 + run_deadline = time.monotonic() + duration while time.monotonic() < run_deadline: time.sleep(min(keepalive_delay, run_deadline - time.monotonic())) for activity_id in activity_ids: From 80b1bb7a693f81e833000ab10bed7533e7997dde Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 15:35:15 +0400 Subject: [PATCH 32/43] Support caller-provided activity IDs Allow clients to choose activity IDs and reject IDs that are already active. Increase the default activity timeout to three minutes and document the client option and configuration. Add API coverage for custom IDs and duplicate-ID errors. --- README.md | 25 +++++++++---- Sources/Nyathing/CLI.swift | 7 +++- Sources/Nyathing/Configuration.swift | 4 +- Sources/Nyathing/LocalAPIServer.swift | 15 ++++++-- Sources/Nyathing/main.swift | 23 +++++++++--- .../ConfigurationAndAPITests.swift | 37 +++++++++++++------ 6 files changed, 78 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index a0c8959..63457fa 100644 --- a/README.md +++ b/README.md @@ -104,22 +104,30 @@ without having to implement the protocol yourself. Use `client` commands to control an activity without wrapping a process: ```sh -nyathing client start +nyathing client start ``` The server starts automatically if it is not already running. -On `start` nyathing prints the activity ID. +On `start` Nyathing prints the activity ID. -Send `keepalive` at least once per requested -interval (5 seconds by default) to keep animation, and use `stop` when done. +You can provide an ID with `--activity-id`; starting an already active ID fails +with an error: + +```sh +nyathing client start --activity-id "$(uuidgen)" +``` + +Send `keepalive` at least once per requested interval (5 seconds by default) to +keep animation, and use `stop` when done. ```sh nyathing client keepalive ACTIVITY_ID nyathing client stop ACTIVITY_ID ``` -Abandoned activities expire according to `max_wait_time`. `start` also accepts -`--keepalive-interval SECONDS` to override the default for that activity. +Abandoned activities expire according to `max_wait_time` (see [Configuration](#-configuration)). +The command `start` also accepts `--keepalive-interval SECONDS` to override the +default for that activity. ### How to choose an animation @@ -237,7 +245,7 @@ The complete initial configuration is: ```toml # Maximum seconds to wait since the last client keepalive. -max_wait_time = 60 +max_wait_time = 180 # Whether to launch Nyathing automatically when you log in. auto_start = false # Animation filename (or "random") used when a client omits the animation field. @@ -305,6 +313,7 @@ messages are supported: | `animation` | string | No | Short name searched in the server's animation directory, or a path to a PNG sprite sheet. Defaults to the server's configured animation. Invalid explicit values return an error. | | `description` | string | No | Description shown for the activity. If omitted or not a string, the server uses its default description. | | `keepalive_interval_seconds` | number | No | Positive, finite interval in seconds at which the client promises to send keepalives. Defaults to 5 seconds. The activity expires after the smaller of twice this interval and the server's configured `max_wait_time`. | +| `activity_id` | string | No | Caller-provided activity ID. Must not match an active activity; otherwise the request fails and names the ID. If omitted, the server generates a UUID. | A short name without a frame-size suffix or `.png` is resolved in the server's animation directory. Other values are treated as file paths; relative paths @@ -327,7 +336,7 @@ or | Field | Type | Required | Description | | --- | --- | --- | --- | | `command` | string | Yes | Must be `keepalive`. | -| `activity_id` | string (UUID) | Yes | Identifier returned by the corresponding `start` request. | +| `activity_id` | string | Yes | ID supplied to or returned by the corresponding `start` request. | Example: diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 16f10a1..6f3111d 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -71,7 +71,7 @@ struct CLIArguments { Client usage: nyathing client start [--animation NAME] [--description TEXT] - [--keepalive-interval SECONDS] + [--activity-id ID] [--keepalive-interval SECONDS] nyathing client keepalive ACTIVITY_ID nyathing client stop ACTIVITY_ID @@ -186,6 +186,7 @@ enum NyathingCLI { case "start": var animation: String? var description: String? + var activityID: String? var interval: Double? var index = 1 while index < arguments.count { @@ -206,6 +207,9 @@ enum NyathingCLI { case "--description": guard description == nil else { throw CLIError.usage } description = value + case "--activity-id": + guard activityID == nil else { throw CLIError.usage } + activityID = value case "--keepalive-interval": guard interval == nil, let parsed = Double(value), parsed.isFinite, parsed > 0 else { throw CLIError.usage } @@ -218,6 +222,7 @@ enum NyathingCLI { var request: [String: Any] = ["command": "start"] if let animation { request["animation"] = animation } if let description { request["description"] = description } + if let activityID { request["activity_id"] = activityID } if let interval { request["keepalive_interval_seconds"] = NSNumber(value: interval) } let client = try LocalAPIClient.connectOrStartServer() guard let activityID = try client.command(request)["activity_id"] as? String else { diff --git a/Sources/Nyathing/Configuration.swift b/Sources/Nyathing/Configuration.swift index 878351e..fb805de 100644 --- a/Sources/Nyathing/Configuration.swift +++ b/Sources/Nyathing/Configuration.swift @@ -9,7 +9,7 @@ struct AppConfiguration { static let template = """ # Maximum seconds to wait since the last client keepalive. - max_wait_time = 60 + max_wait_time = 180 # Whether Nyathing should launch automatically when you log in. auto_start = false # Animation filename (or "random") used when a client omits the animation field. @@ -95,7 +95,7 @@ struct AppConfiguration { let key = line[.. String + private let onStart: (String, String?, String?, TimeInterval, Bool, TimeInterval) throws -> String private let onKeepalive: (String) throws -> Void private let onStop: (String) throws -> Void private let socketPath: String @@ -18,8 +18,9 @@ final class LocalAPIServer { init( socketPath: String = LocalAPIServer.socketPath, defaultAnimation: String = "nyathing_36x36.png", - maxWaitTime: TimeInterval = 60, - onStart: @escaping (String, String?, TimeInterval, Bool, TimeInterval) throws -> String, + maxWaitTime: TimeInterval = 180, + onStart: + @escaping (String, String?, String?, TimeInterval, Bool, TimeInterval) throws -> String, onKeepalive: @escaping (String) throws -> Void, onStop: @escaping (String) throws -> Void ) { @@ -220,6 +221,10 @@ final class LocalAPIServer { case "start": let animation = request["animation"] as? String ?? defaultAnimation guard !animation.isEmpty else { throw LocalAPIError.invalidRequest } + let requestedActivityID = request["activity_id"] as? String + if request["activity_id"] != nil && (requestedActivityID?.isEmpty ?? true) { + throw LocalAPIError.invalidRequest + } guard request["activity_timeout_seconds"] == nil else { throw LocalAPIError.serverManagedActivityTimeout } @@ -234,7 +239,7 @@ final class LocalAPIServer { return [ "ok": true, "activity_id": try onStart( - animation, request["description"] as? String, keepaliveInterval, + animation, request["description"] as? String, requestedActivityID, keepaliveInterval, keepaliveIntervalWasProvided, activityTimeout), ] case "keepalive": @@ -322,6 +327,7 @@ enum LocalAPIError: LocalizedError { case serverManagedActivityTimeout case unknownCommand(String) case unknownActivity + case activityIDInUse(String) case socketPathTooLong case alreadyRunning(String) case unsafeSocketPath(String) @@ -337,6 +343,7 @@ enum LocalAPIError: LocalizedError { "'activity_timeout_seconds' is controlled by the server and cannot be set per activity." case .unknownCommand(let command): return "Unknown command: \(command)." case .unknownActivity: return "Unknown activity ID." + case .activityIDInUse(let id): return "Activity ID \"\(id)\" is already in use." case .socketPathTooLong: return "The local API socket path is too long." case .alreadyRunning(let path): return "Another Nyathing instance is listening at \(path)." case .unsafeSocketPath(let path): diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 9faa1d9..d04001b 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -44,8 +44,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { }() private var activeAnimations: [String: ActiveAnimation] = [:] private var lifecycle = ActivityLifecycle() - private var maxWaitTime: TimeInterval = 60 + private var maxWaitTime: TimeInterval = 180 private var activityTimeouts: [UUID: TimeInterval] = [:] + private var externalActivityIDs: [String: UUID] = [:] private var activityKeepaliveIntervals: [UUID: TimeInterval] = [:] private var activityKeepaliveIntervalSources: [UUID: String] = [:] private var timedOutActivityDetails: [UUID: ActivityTimeoutDetails] = [:] @@ -583,19 +584,26 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { apiServer = LocalAPIServer( defaultAnimation: serverDefaultAnimation, maxWaitTime: maxWaitTime, - onStart: { [weak self] filename, description, interval, intervalWasProvided, timeout in + onStart: { + [weak self] filename, description, requestedID, interval, intervalWasProvided, timeout in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } - return try self.startActivity( + if let requestedID, self.externalActivityIDs[requestedID] != nil { + throw LocalAPIError.activityIDInUse(requestedID) + } + let id = try self.startActivity( animation: filename, description: description, activityTimeout: timeout, keepaliveInterval: interval, intervalWasProvided: intervalWasProvided - ).uuidString + ) + let externalID = requestedID ?? id.uuidString + self.externalActivityIDs[externalID] = id + return externalID } }, onKeepalive: { [weak self] activityID in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation, - let id = UUID(uuidString: activityID), self.keepaliveActivity(id) + let id = self.externalActivityIDs[activityID], self.keepaliveActivity(id) else { throw LocalAPIError.unknownActivity } @@ -604,11 +612,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { onStop: { [weak self] activityID in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation, - let id = UUID(uuidString: activityID), self.lifecycle.animation(for: id) != nil + let id = self.externalActivityIDs[activityID], self.lifecycle.animation(for: id) != nil else { throw LocalAPIError.unknownActivity } self.stopActivity(id) + self.externalActivityIDs.removeValue(forKey: activityID) } } ) @@ -618,6 +627,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private func clearRuntimeState() { activeAnimations.removeAll() activityTimeouts.removeAll() + externalActivityIDs.removeAll() activityKeepaliveIntervals.removeAll() activityKeepaliveIntervalSources.removeAll() timedOutActivityDetails.removeAll() @@ -810,6 +820,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { activityKeepaliveIntervalSources.removeValue(forKey: id) ?? "built-in default" let timeout = activityTimeouts.removeValue(forKey: id) ?? min(interval * 2, maxWaitTime) + externalActivityIDs = externalActivityIDs.filter { $0.value != id } timedOutActivityDetails[id] = ActivityTimeoutDetails( keepaliveInterval: interval, intervalSource: intervalSource, timeout: timeout, maxWaitTime: maxWaitTime) diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index d965e2b..c638fad 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -214,7 +214,7 @@ final class ConfigurationTests: XCTestCase { func testFirstLaunchSeedsConfigurationAndSampleAnimation() throws { let configuration = try AppConfiguration.load(in: temporaryDirectory) - XCTAssertEqual(configuration.maxWaitTime, 60) + XCTAssertEqual(configuration.maxWaitTime, 180) XCTAssertEqual(configuration.defaultAnimation, "nyathing_36x36.png") XCTAssertTrue( FileManager.default.fileExists( @@ -244,7 +244,7 @@ final class ConfigurationTests: XCTestCase { func testMigratesLegacyKeepaliveConfiguration() throws { let legacy = AppConfiguration.template.replacingOccurrences( - of: "max_wait_time = 60", + of: "max_wait_time = 180", with: "keepalive_interval_seconds = 7\nactivity_timeout_seconds = 24") try writeConfiguration(legacy) @@ -323,7 +323,7 @@ final class ConfigurationTests: XCTestCase { let configuration = try AppConfiguration.load(in: temporaryDirectory) - XCTAssertEqual(configuration.maxWaitTime, 60) + XCTAssertEqual(configuration.maxWaitTime, 180) XCTAssertFalse(configuration.autoStart) let savedConfig = try String( contentsOf: temporaryDirectory.appendingPathComponent("config.toml"), encoding: .utf8) @@ -355,7 +355,7 @@ final class ConfigurationTests: XCTestCase { try writeConfiguration( AppConfiguration.template.replacingOccurrences( - of: "max_wait_time = 60", with: "max_wait_time = 0")) + of: "max_wait_time = 180", with: "max_wait_time = 0")) XCTAssertThrowsError(try AppConfiguration.load(in: temporaryDirectory)) } @@ -486,6 +486,7 @@ final class LocalAPIServerTests: XCTestCase { let socketPath = directory.appendingPathComponent("api.sock").path let lock = NSLock() var startedAnimations: [String] = [] + var requestedActivityIDs: [String?] = [] var startedDescriptions: [String?] = [] var startedTimeouts: [Double] = [] var startedIntervals: [Double] = [] @@ -495,15 +496,19 @@ final class LocalAPIServerTests: XCTestCase { socketPath: socketPath, defaultAnimation: "nyan_54x36.png", maxWaitTime: 30, - onStart: { animation, description, interval, intervalWasProvided, timeout in + onStart: { animation, description, requestedID, interval, intervalWasProvided, timeout in lock.lock() defer { lock.unlock() } + if let requestedID, requestedActivityIDs.contains(requestedID) { + throw LocalAPIError.activityIDInUse(requestedID) + } startedAnimations.append(animation) + requestedActivityIDs.append(requestedID) startedDescriptions.append(description) startedIntervals.append(interval) startedIntervalsWereProvided.append(intervalWasProvided) startedTimeouts.append(timeout) - return "activity-\(startedAnimations.count)" + return requestedID ?? "activity-\(startedAnimations.count)" }, onKeepalive: { _ in }, onStop: { id in lock.lock() @@ -534,16 +539,23 @@ final class LocalAPIServerTests: XCTestCase { XCTAssertTrue( (clientTimeoutOverride["error"] as? String)?.contains("controlled by the server") == true) let firstStart = try first.command([ - "command": "start", "animation": "same_36x36.png", "description": "first client", - "keepalive_interval_seconds": 8, + "command": "start", "activity_id": "turn-123", "animation": "same_36x36.png", + "description": "first client", "keepalive_interval_seconds": 8, + ]) + XCTAssertEqual(firstStart["activity_id"] as? String, "turn-123") + let duplicateStart = try first.command([ + "command": "start", "activity_id": "turn-123", ]) - XCTAssertEqual(firstStart["activity_id"] as? String, "activity-3") + XCTAssertEqual(duplicateStart["ok"] as? Bool, false) + XCTAssertEqual( + duplicateStart["error"] as? String, + "Activity ID \"turn-123\" is already in use.") XCTAssertEqual(startedTimeouts[2], 16) XCTAssertEqual( - try first.command(["command": "keepalive", "activity_id": "activity-3"])["ok"] as? Bool, + try first.command(["command": "keepalive", "activity_id": "turn-123"])["ok"] as? Bool, true) XCTAssertEqual( - try first.command(["command": "stop", "activity_id": "activity-3"])["ok"] as? Bool, true) + try first.command(["command": "stop", "activity_id": "turn-123"])["ok"] as? Bool, true) let second = try UnixJSONClient(path: socketPath) let secondStart = try second.command([ @@ -559,7 +571,8 @@ final class LocalAPIServerTests: XCTestCase { XCTAssertEqual( startedAnimations, ["nyan_54x36.png", "nyan_54x36.png", "same_36x36.png", "same_36x36.png", "nyan_54x36.png"]) - XCTAssertEqual(stoppedIDs, ["activity-3"]) + XCTAssertEqual(stoppedIDs, ["turn-123"]) + XCTAssertEqual(requestedActivityIDs, [nil, nil, "turn-123", nil, nil]) XCTAssertEqual(startedDescriptions, [nil, nil, "first client", nil, nil]) XCTAssertEqual(startedTimeouts, [10, 30, 16, 10, 2]) XCTAssertEqual(startedIntervals, [5, 30, 8, 5, 1]) From 9cf7e33af19dfa44721b14401a32ded6b43c9792 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 17:26:33 +0400 Subject: [PATCH 33/43] Document coding-agent integrations Add Codex and Claude Code hook examples using jq and custom activity IDs. Add a contents section and update section headings with matching monochrome symbols. Include the referenced Codex and Claude Code icons. --- README.md | 196 ++++++++++++++++++++++++++++++++---- assets/claude-code-icon.png | Bin 0 -> 2666 bytes assets/codex_icon.png | Bin 0 -> 4941 bytes 3 files changed, 179 insertions(+), 17 deletions(-) create mode 100644 assets/claude-code-icon.png create mode 100644 assets/codex_icon.png diff --git a/README.md b/README.md index 63457fa..d63304a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,28 @@ Nyathing brings background processes to life with playful animations in the macOS menu bar. Clients start an animation when work begins and stop it when the task is done. -## 🢃 Install from archive +## Contents + +- [↓ Install from archive](#-install-from-archive) +- [⚒︎ Build from source](#-build-from-source) +- [▤ Nyathing server](#-nyathing-server) + - [Launch at login](#launch-at-login) +- [⌘ Nyathing client](#-nyathing-client) + - [How to choose an animation](#how-to-choose-an-animation) + - [Describe a client](#describe-a-client) +- [>_ Nyathing CLI](#-nyathing-cli) +- [❯ Shell completion](#-shell-completion) +- [⚙ Configuration](#-configuration) +- [▦ Animation file format](#-animation-file-format) +- [⇄ Server communication protocol](#-server-communication-protocol) +- [✦ Examples](#-examples) + - [Minimal Python client example](#-minimal-python-client-example) + - [Coding-agent integrations](#-coding-agent-integrations) + - [Codex](#-codex) + - [Claude Code](#-claude-code) +- [⚡︎ Troubleshooting](#-troubleshooting) + +## ↓ Install from archive Download `nyathing-macos-arm64.tar.gz` from the latest GitHub Release, then extract and install it: @@ -46,7 +67,7 @@ confirm with Touch ID. Alternatively, build and run Nyathing locally using the instructions in [Build from source](#build-from-source); locally built binaries are not quarantined. -## ⚒ Build from source +## ⚒︎ Build from source Requires macOS 12+ and Swift 5.9 or later. From the repository root, install the CLI in `/usr/local/bin` with: @@ -74,7 +95,7 @@ make uninstall PREFIX="$HOME/.local" Without a custom prefix, use `make uninstall` to remove the default installation from `/usr/local/bin`. Uninstall keeps user configuration and animations. -## Nyathing server +## ▤ Nyathing server

nyathing-server

@@ -94,7 +115,19 @@ For convenience, Nyathing also implements the client side of the protocol. See For the complete message formats, field requirements, and response schemas, see [Server communication protocol](#server-communication-protocol). -## Nyathing client +### Launch at login + +In the **Edit Configuration** window, enable **Launch Nyathing at login** and +click **Accept**. Nyathing installs its own LaunchAgent in +`~/Library/LaunchAgents`; it will start automatically at your next login. No +manual `launchctl` commands are needed. + +Disable **Launch Nyathing at login** in **Edit Configuration** and click +**Accept** to remove the LaunchAgent. If you move +`Nyathing.app`, enable auto-start again and click **Accept** so the LaunchAgent +records the app's new location. + +## ⌘ Nyathing client

nyathing-client

@@ -169,7 +202,7 @@ identify the activity: nyathing client start --description "Running tests" ``` -## Nyathing CLI +## >_ Nyathing CLI

nyathing-cli

@@ -266,7 +299,7 @@ animations; this also clears active activities and the disconnected-client count. **Cancel** closes the editor without applying changes. Accepting the current settings also reloads animation files changed outside the editor. -## 👾 Animation file format +## ▦ Animation file format Animation files are horizontal PNG sprite sheets. The filename suffix declares the dimensions of each frame, for example `nyan_64x48.png`. Each dimension must @@ -277,7 +310,7 @@ frames and 4 million pixels total. Frames are scaled to fit the menu bar. The app validates assets on startup and when settings are accepted; invalid assets are ignored and logged. Playback runs at 10 frames per second. -## {} Server communication protocol +## ⇄ Server communication protocol The server communicates over a Unix domain `SOCK_STREAM` socket using UTF-8 JSON Lines. Each message is a JSON object followed by `\n`; each request @@ -388,7 +421,9 @@ request lines. An activity expires after the smaller of twice its keepalive interval and the configured `max_wait_time`. Expiration increments the disconnected-client count; an explicit `stop` does not. -## ✦ Minimal Python client example +## ✦ Examples + +### 🐍 Minimal Python client example ```python import json @@ -415,17 +450,144 @@ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client: command({"command": "stop", "activity_id": activity}) ``` -## Launch at login +### 🤖 Coding-agent integrations -In the **Edit Configuration** window, enable **Launch Nyathing at login** and -click **Accept**. Nyathing installs its own LaunchAgent in -`~/Library/LaunchAgents`; it will start automatically at your next login. No -manual `launchctl` commands are needed. +Nyathing's CLI can be called directly from command hooks. The examples below +use `jq` to extract the activity ID from hook JSON on stdin; no helper script +is needed. Install `jq` and make sure it is on `PATH`. Replace `nyathing` with +its absolute path if the hook environment does not include it in `PATH`. -Disable **Launch Nyathing at login** in **Edit Configuration** and click -**Accept** to remove the LaunchAgent. If you move -`Nyathing.app`, enable auto-start again and click **Accept** so the LaunchAgent -records the app's new location. +#### Codex + +See the [Codex hooks documentation](https://developers.openai.com/codex/hooks). +Add these hooks to `~/.codex/hooks.json`: + +```json +{ + "hooks": { + "UserPromptSubmit": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .turn_id) && nyathing client start --activity-id \"$id\" --keepalive-interval 90 >/dev/null" + }] + }], + "PostModelRequest": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .turn_id) && nyathing client keepalive \"$id\"" + }] + }], + "PreToolUse": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .turn_id) && nyathing client keepalive \"$id\"" + }] + }], + "PostToolUse": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .turn_id) && nyathing client keepalive \"$id\"" + }] + }], + "Stop": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .turn_id) && nyathing client stop \"$id\"" + }] + }], + "Interrupt": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .turn_id) && nyathing client stop \"$id\"", + "timeout": 3 + }] + }] + } +} +``` + +`UserPromptSubmit` starts one activity per turn. Model responses and tool +calls refresh its keepalive; `Stop` and `Interrupt` stop it. The 90-second +keepalive interval gives the activity up to 180 seconds between refreshes, +subject to `max_wait_time`. A single long model request or tool call can still +outlast that timeout. Review and trust the hooks in Codex before using them. + +#### Claude Code + +See the [Claude Code hooks documentation](https://code.claude.com/docs/en/hooks). +Add these hooks to `~/.claude/settings.json`: + +```json +{ + "hooks": { + "UserPromptSubmit": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .session_id) && (nyathing client keepalive \"$id\" 2>/dev/null || nyathing client start --activity-id \"$id\" --keepalive-interval 90 >/dev/null)" + }] + }], + "PreToolUse": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .session_id) && nyathing client keepalive \"$id\"" + }] + }], + "PostToolUse": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .session_id) && nyathing client keepalive \"$id\"" + }] + }], + "Stop": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .session_id) && nyathing client stop \"$id\" || true" + }] + }], + "StopFailure": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .session_id) && nyathing client stop \"$id\" || true" + }] + }], + "SessionEnd": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .session_id) && nyathing client stop \"$id\" || true" + }] + }] + } +} +``` + +Claude Code's `session_id` stays the same across turns, so the prompt hook +first refreshes an existing activity and starts it only if it is missing. +Tool hooks refresh keepalive; `Stop` and `StopFailure` stop the activity. +Claude Code does not run `Stop` when you interrupt a turn. In that case, the +activity expires after its keepalive timeout; submitting another prompt in +the same session refreshes it. `SessionEnd` provides final cleanup. For long +assistant output, add this hook to the `hooks` object to refresh keepalive +for each displayed message batch: + +```json +{ + "hooks": { + "MessageDisplay": [{ + "hooks": [{ + "type": "command", + "command": "id=$(jq -r .session_id) && nyathing client keepalive \"$id\"" + }] + }] + } +} +``` + +This can add command overhead while text streams. Claude Code does not expose +an equivalent of Codex's per-model-request event. + +Keepalives are sent at hook boundaries, not on a timer. Configure +`max_wait_time` high enough for the longest gap between hooks. See +[Configuration](#-configuration) for the server-side limit. ## ⚡︎ Troubleshooting diff --git a/assets/claude-code-icon.png b/assets/claude-code-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..baf83f53882bc3c642623439b5a8de5ab78fa9dd GIT binary patch literal 2666 zcmZ`*3pkVQ8-M1IC7MG>!kQvJJ2*|Wt*~;)A%%}crZrlzjcr*;j-``xrD8SYl%k?Y ztQ^vbDJy+cOY!w7l#psE|Bb%t-_`fN*Yn=@`@8So{kxyTb-nNYwVuwZ$_tbM0IIGo z#C1};QZ}Hoq|Y<7NU_u?ggJOP0B|9F&SZ$9^c_xdS?2-3PGbP#lL3%Oq4)s+I2Zt4 zlL4?l27nGTug)7M4RERcuAv?tz)b2xfdWJW$V)wl^ahXxKvqra0RlwtyT3Yx1{A*G zo>D8jT%<#mH)G}bkRMg}a^JI8^5uW{GFn;3kdoBQX1WBh0GOjG8xU|JZ$1EWhiN|k zY<~}TdkP~06|$MJiHhPzFl8)& z_gD*eVnk8lSQG|@K@gPTa5ye%bEy3~;_7d7=^Gxgh0SK#qtVgP(Wq!E6eB7OZDD6; zhsIc;mta)+sLm> zCq_6UYCSWALM2FrrYS!`zh+PC1pKGYPmym-99p(-KkehpA(=*{r-Y!4Lw`SU1ZAV8 zH}L?>s&^$i_;4Y^r1td3#CfMK@G8Fy(Pt+vN0!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^sL#$_b@?s{Qc|j4=UD~ z29J2VE1#s?+wi(#0L~j~^nsCCnc-f|16EjJc-=BJ(*+O5#;EmrDhCwwp6aYUT*$!+ z82dzh644u9iMA0ZXq8C}REKdXpzxJX5o`gR16<@6?4Cz9w3_fPq@fWOFLd+Jh`K)= zP@QQYR+u1?XyjaWuS`Vpr_8#14fPYM8hNxUoQzl5O7}K2-pIXfF5>r9USiY;$EiAn0+bKwHw z2QjmAF^;-)UEoDV!dh!?38@`QSKXsJ&{;rdSHPo098 z`g_BMRjDZ+HOVIH>PyrNLdN@T#_zo}VC>FMi_h!XnpKxGq3G>aFJ11!ivbm)@uK@x mv1k}gXNqhLg~*T0IsV%i4~6I#Qy;fXgvG? literal 0 HcmV?d00001 diff --git a/assets/codex_icon.png b/assets/codex_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..bafba2e257193424e733d3a3d872302be9bba15e GIT binary patch literal 4941 zcmY*dc|6oz)c=j02%%&!V@Y;n*I2S|k$vB{GK4V(GuE*VB}qcEi=r&qN!E%`lwH}f zXBlH(!prkK@AJIxy`OW>_n!Mb-*eCX^Tr$A)}o_fqX7VbPDfka_{=Mx8x_UbT7vMM zJaZsFV=Yyn>?`~7*#_#OZLALfL3{v!iw1zhvk-0x0Q_M9@Y@jp;OPKx1)14sq;Pf+ z?PjTSM_(ThJi}A~Ip`8VdWJw}69BORfxnfJXpi|8T6&{Q1y6 zv$O1fJZUcIKgC>H#bsxwE8)VA^ifD26L1_ClNSKARHFRr?uA0ATp0qpo6#0j*gFBW*3Pr(fR(I(#n^w!w}Xj@;(| zWKtM0o!~p3_xQeKn>RIsVA>x>ZAYX8>2Ne3hwAd+rt-u{ij26XB=!6?Ef#0zHIMrjUF+lPBA_-?)UvXB8M@Q zKR$*FJ8MAvy%(=3jNQ>pQp(hk;riGu4L z#mih>TQ_$h%B>t9`In$>&yRle=z9kQtPjS2d~oe&wGMe~u@5$UE_gUN#oRNOvgc{C z2Amn<64jkNYfU*7XgqWB5TgD5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(jpXO~zd;2wf}Fb7p5&C$W6P{oQHXW_{GUii Date: Sat, 21 Nov 2026 17:56:27 +0400 Subject: [PATCH 34/43] Allow install prefixes under the home directory Permit safe nested home paths such as RUNNER_TEMP and ~/.local while continuing to reject the home directory itself, root, and paths containing parent-directory traversal. --- Scripts/force-uninstall.sh | 2 +- Scripts/install-cli.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/force-uninstall.sh b/Scripts/force-uninstall.sh index c9494de..622cc73 100644 --- a/Scripts/force-uninstall.sh +++ b/Scripts/force-uninstall.sh @@ -3,7 +3,7 @@ set -euo pipefail prefix="${PREFIX:-/usr/local}" if [[ "$prefix" != /* || "$prefix" == / || "$prefix" == "$HOME" \ - || "$prefix" == "$HOME"/* || "/$prefix/" == */../* ]]; then + || "/$prefix/" == */../* ]]; then echo "Refusing unsafe PREFIX: $prefix" >&2 exit 1 fi diff --git a/Scripts/install-cli.sh b/Scripts/install-cli.sh index 4722e8f..aeb0961 100644 --- a/Scripts/install-cli.sh +++ b/Scripts/install-cli.sh @@ -5,7 +5,7 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" PREFIX="${PREFIX:-/usr/local}" if [[ "$PREFIX" != /* || "$PREFIX" == / || "$PREFIX" == "$HOME" \ - || "$PREFIX" == "$HOME"/* || "/$PREFIX/" == */../* ]]; then + || "/$PREFIX/" == */../* ]]; then echo "Refusing unsafe PREFIX: $PREFIX" >&2 exit 1 fi From 4f4bc57cbbafd6fbd08cae9d1fc543a587118bb0 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 18:06:48 +0400 Subject: [PATCH 35/43] Use a single installer script Make the installer detect bundled release files or build from the repository, and use it from both the Makefile and release archive. Remove the generated archive wrapper and obsolete second script. --- Makefile | 2 +- Scripts/{install-cli.sh => install.sh} | 14 ++++++++++---- Scripts/package-cli.sh | 10 ++-------- 3 files changed, 13 insertions(+), 13 deletions(-) rename Scripts/{install-cli.sh => install.sh} (85%) diff --git a/Makefile b/Makefile index 2757e05..1654c1b 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ archive: PREFIX ?= /usr/local install: - PREFIX='$(PREFIX)' bash Scripts/install-cli.sh + PREFIX='$(PREFIX)' bash Scripts/install.sh uninstall: PREFIX='$(PREFIX)' bash Scripts/force-uninstall.sh diff --git a/Scripts/install-cli.sh b/Scripts/install.sh similarity index 85% rename from Scripts/install-cli.sh rename to Scripts/install.sh index aeb0961..8ba64bf 100644 --- a/Scripts/install-cli.sh +++ b/Scripts/install.sh @@ -1,8 +1,8 @@ #!/bin/bash set -euo pipefail -ROOT="$(cd "$(dirname "$0")/.." && pwd)" -cd "$ROOT" +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" PREFIX="${PREFIX:-/usr/local}" if [[ "$PREFIX" != /* || "$PREFIX" == / || "$PREFIX" == "$HOME" \ || "/$PREFIX/" == */../* ]]; then @@ -12,8 +12,14 @@ fi SOURCE_DIR="${1:-}" if [[ -z "$SOURCE_DIR" ]]; then - swift build -c release - SOURCE_DIR="$ROOT/.build/release" + if [[ -f "$SCRIPT_DIR/nyathing" && -d "$SCRIPT_DIR/Nyathing_Nyathing.bundle" ]]; then + SOURCE_DIR="$SCRIPT_DIR" + else + cd "$ROOT" + swift build -c release + SOURCE_DIR="$ROOT/.build/release" + fi + SOURCE_DIR="$(cd "$SOURCE_DIR" && pwd -P)" fi [[ -d "$SOURCE_DIR" && ! -L "$SOURCE_DIR" ]] || { echo "Invalid install source directory: $SOURCE_DIR" >&2; exit 1; diff --git a/Scripts/package-cli.sh b/Scripts/package-cli.sh index 08ffa4e..eecb30c 100755 --- a/Scripts/package-cli.sh +++ b/Scripts/package-cli.sh @@ -28,15 +28,9 @@ cleanup() { trap cleanup EXIT cp .build/release/nyathing "$STAGING/nyathing" cp -R .build/release/Nyathing_Nyathing.bundle "$STAGING/Nyathing_Nyathing.bundle" -cp Scripts/install-cli.sh "$STAGING/install-cli.sh" +cp Scripts/install.sh "$STAGING/install.sh" cp Scripts/force-uninstall.sh "$STAGING/uninstall.sh" -cat > "$STAGING/install.sh" <<'INSTALLER' -#!/bin/bash -set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -PREFIX="${PREFIX:-/usr/local}" bash "$SCRIPT_DIR/install-cli.sh" "$SCRIPT_DIR" -INSTALLER -chmod 755 "$STAGING/install.sh" "$STAGING/install-cli.sh" "$STAGING/uninstall.sh" +chmod 755 "$STAGING/install.sh" "$STAGING/uninstall.sh" if [[ -e "$OUTPUT_DIR" || -L "$OUTPUT_DIR" ]]; then [[ ! -L "$OUTPUT_DIR" && "$OUTPUT_DIR" == "$OUT_DIR/nyathing-macos-arm64" ]] || { echo "Refusing to replace unexpected output path: $OUTPUT_DIR" >&2; exit 1; From 68563322f189b61b5e6c95f391bb691de4c81814 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 18:39:13 +0400 Subject: [PATCH 36/43] Use Git metadata for development version --- Scripts/generate-version.sh | 14 ++++++++++++++ Scripts/install.sh | 1 + Scripts/package-cli.sh | 1 + Sources/Nyathing/CLI.swift | 7 +++---- Sources/Nyathing/Version.swift | 4 ++++ Sources/Nyathing/main.swift | 2 +- 6 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 Scripts/generate-version.sh create mode 100644 Sources/Nyathing/Version.swift diff --git a/Scripts/generate-version.sh b/Scripts/generate-version.sh new file mode 100644 index 0000000..d1c57dd --- /dev/null +++ b/Scripts/generate-version.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" + +version="$(git describe --tags --exact-match HEAD 2>/dev/null || git rev-parse --short HEAD)" +output="$ROOT/Sources/Nyathing/Version.swift" +cat > "$output" < Date: Sat, 21 Nov 2026 18:43:23 +0400 Subject: [PATCH 37/43] Stop tracking generated version source Ignore Sources/Nyathing/Version.swift and generate it before builds. Use the exact Git tag without its v prefix, or the short commit hash when no exact tag is available. . . . --- .github/workflows/ci.yml | 2 ++ .gitignore | 1 + README.md | 4 ++-- Scripts/generate-version.sh | 7 ++++++- Sources/Nyathing/CLI.swift | 3 ++- Sources/Nyathing/Version.swift | 4 ---- 6 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 Sources/Nyathing/Version.swift diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d67c889..8ab98cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,8 @@ jobs: uses: actions/checkout@v5 - name: Check formatting run: make lint + - name: Generate version + run: bash Scripts/generate-version.sh - name: Run tests run: swift test diff --git a/.gitignore b/.gitignore index 2ac4997..5fe770c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .agents/ .build/ +Sources/Nyathing/Version.swift .swiftpm/ out/ dist/ diff --git a/README.md b/README.md index d63304a..7a25e1b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ task is done. - [Describe a client](#describe-a-client) - [>_ Nyathing CLI](#-nyathing-cli) - [❯ Shell completion](#-shell-completion) -- [⚙ Configuration](#-configuration) +- [⚙︎ Configuration](#-configuration) - [▦ Animation file format](#-animation-file-format) - [⇄ Server communication protocol](#-server-communication-protocol) - [✦ Examples](#-examples) @@ -258,7 +258,7 @@ The completion script offers Nyathing commands and options, including server subcommands. It fetches available animations with `nyathing list` when completing an animation argument, so the suggestions reflect installed files. -## ⚙ Configuration +## ⚙︎ Configuration On first launch, Nyathing creates its configuration directory and adds these built-in animations: diff --git a/Scripts/generate-version.sh b/Scripts/generate-version.sh index d1c57dd..d96a5a5 100644 --- a/Scripts/generate-version.sh +++ b/Scripts/generate-version.sh @@ -4,7 +4,12 @@ set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" -version="$(git describe --tags --exact-match HEAD 2>/dev/null || git rev-parse --short HEAD)" +tag="$(git describe --tags --exact-match HEAD 2>/dev/null || true)" +if [[ -n "$tag" ]]; then + version="${tag#v}" +else + version="$(git rev-parse --short HEAD)" +fi output="$ROOT/Sources/Nyathing/Version.swift" cat > "$output" < Date: Sat, 21 Nov 2026 19:07:12 +0400 Subject: [PATCH 38/43] Resolve default animations like CLI selections Use the same resolver for configured and CLI animation selections. Default to the short name nyathing and preserve full PNG paths chosen in the configuration editor. Let the animation test script use the server's default unless an animation is explicitly selected. --- README.md | 13 +-- Scripts/run-test-animation.py | 18 ++--- Sources/Nyathing/CLI.swift | 17 +++- Sources/Nyathing/Configuration.swift | 42 ++++++---- Sources/Nyathing/main.swift | 80 +++++++++++-------- .../ConfigurationAndAPITests.swift | 27 ++++++- 6 files changed, 122 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 7a25e1b..81389b7 100644 --- a/README.md +++ b/README.md @@ -281,20 +281,23 @@ The complete initial configuration is: max_wait_time = 180 # Whether to launch Nyathing automatically when you log in. auto_start = false -# Animation filename (or "random") used when a client omits the animation field. -default_animation = "nyathing_36x36.png" +# Animation name, PNG path, or "random" used when a client omits the animation field. +default_animation = "nyathing" ``` Keep all three settings in your `config.toml`; Nyathing does not fill in omitted settings. Set `max_wait_time` to a positive number of seconds and `auto_start` to `true` or `false`. Clients use a default keepalive interval of 5 seconds, which they can override per activity. Activities expire after the smaller of -twice that interval and `max_wait_time`. Set `default_animation` to a valid -filename in `animations/` or to `random` to select a random animation per activity. +twice that interval and `max_wait_time`. Like `--animation`, `default_animation` +accepts a short name such as `nyathing`, a filename in `animations/`, a PNG path, +or `random` to select an animation per activity. Relative paths in `config.toml` +are resolved beside that file; CLI paths are relative to the working directory. Requests with an explicit animation use it; missing or unavailable requested animations fall back to the built-in ghost. Choose **Edit Configuration** from the menu to change these settings with -visual controls. **Accept** saves the configuration and reloads settings and +visual controls. **Choose PNG…** lets you select a file outside `animations/` +and saves its full path. **Accept** saves the configuration and reloads settings and animations; this also clears active activities and the disconnected-client count. **Cancel** closes the editor without applying changes. Accepting the current settings also reloads animation files changed outside the editor. diff --git a/Scripts/run-test-animation.py b/Scripts/run-test-animation.py index b5d8ac8..457e6a6 100644 --- a/Scripts/run-test-animation.py +++ b/Scripts/run-test-animation.py @@ -77,20 +77,14 @@ def configured_value(text, key, default): animations = os.environ.get("ANIMATIONS", "").replace(",", " ").split() if not animations: - animation = os.environ.get("ANIMATION") - if animation is None: - animation = configured_value(settings, "default_animation", "nyathing_36x36.png") - if animation != "random": - animation = str(config_path.parent / "animations" / animation) - animations = [animation] + animations = [os.environ.get("ANIMATION")] for animation in animations: - activity_id = request({ - "command": "start", - "animation": animation, - "keepalive_interval_seconds": interval, - })["activity_id"] + payload = {"command": "start", "keepalive_interval_seconds": interval} + if animation is not None: + payload["animation"] = animation + activity_id = request(payload)["activity_id"] activity_ids.append(activity_id) - print(f"Started {animation} ({activity_id})") + print(f"Started {animation or 'default animation'} ({activity_id})") keepalive_delay = interval run_deadline = time.monotonic() + duration diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 76591aa..6f50dbd 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -251,7 +251,7 @@ enum NyathingCLI { let animationsDirectory = AppConfiguration.configurationDirectory .appendingPathComponent("animations", isDirectory: true) let animation = try resolveAnimation( - cli.animation ?? configuration.defaultAnimation, in: animationsDirectory) + cli.animation ?? configuration.resolvedDefaultAnimation, in: animationsDirectory) let keepaliveInterval = LocalAPIServer.defaultKeepaliveInterval let client = try LocalAPIClient.connectOrStartServer() let activity = try client.command([ @@ -318,7 +318,11 @@ enum NyathingCLI { _ = try resolveAnimation(filename, in: directory) } - static func resolveAnimation(_ name: String, in directory: URL) throws -> String { + static func resolveAnimation( + _ name: String, in directory: URL, + relativeTo baseDirectory: URL = URL( + fileURLWithPath: FileManager.default.currentDirectoryPath, isDirectory: true) + ) throws -> String { if name == "random" { if let namedAnimation = try? resolveNamedAnimation(name, in: directory) { return namedAnimation @@ -331,9 +335,14 @@ enum NyathingCLI { if isShortAnimationName(name) { return try resolveNamedAnimation(name, in: directory) } + if !name.contains("/"), !name.contains("\\") { + let installed = directory.appendingPathComponent(name).standardizedFileURL + if FileManager.default.fileExists(atPath: installed.path) { + return try resolveAnimation(installed.path, in: directory) + } + } let path = URL( - fileURLWithPath: (name as NSString).expandingTildeInPath, - relativeTo: URL(fileURLWithPath: FileManager.default.currentDirectoryPath) + fileURLWithPath: (name as NSString).expandingTildeInPath, relativeTo: baseDirectory ).standardizedFileURL do { _ = try SpriteAnimation.load(from: path) diff --git a/Sources/Nyathing/Configuration.swift b/Sources/Nyathing/Configuration.swift index fb805de..7b07917 100644 --- a/Sources/Nyathing/Configuration.swift +++ b/Sources/Nyathing/Configuration.swift @@ -6,14 +6,15 @@ struct AppConfiguration { let maxWaitTime: TimeInterval let autoStart: Bool let defaultAnimation: String + let resolvedDefaultAnimation: String static let template = """ # Maximum seconds to wait since the last client keepalive. max_wait_time = 180 # Whether Nyathing should launch automatically when you log in. auto_start = false - # Animation filename (or "random") used when a client omits the animation field. - default_animation = "nyathing_36x36.png" + # Animation name, PNG path, or "random" used when a client omits the animation field. + default_animation = "nyathing" """ static var configurationDirectory: URL { @@ -161,24 +162,28 @@ struct AppConfiguration { throw ConfigError.invalidValue("auto_start") } guard let rawAnimation = values["default_animation"], - rawAnimation.count >= 2, rawAnimation.first == "\"", rawAnimation.last == "\"" - else { - throw ConfigError.invalidValue("default_animation") - } - let defaultAnimation = String(rawAnimation.dropFirst().dropLast()) - if defaultAnimation != "random" { - guard !defaultAnimation.contains("/"), !defaultAnimation.contains("\\"), - (try? SpriteAnimation.load( - from: animationsDirectory.appendingPathComponent( - defaultAnimation))) != nil - else { - throw ConfigError.invalidValue("default_animation") - } + let defaultAnimation = try? JSONDecoder().decode(String.self, from: Data(rawAnimation.utf8)), + !defaultAnimation.isEmpty + else { throw ConfigError.invalidValue("default_animation") } + let resolvedDefaultAnimation: String + do { + resolvedDefaultAnimation = try resolveDefaultAnimation(defaultAnimation, in: directory) + } catch { + throw ConfigError.invalidDefaultAnimation(error.localizedDescription) } return AppConfiguration( maxWaitTime: try number("max_wait_time"), autoStart: rawAuto == "true", - defaultAnimation: defaultAnimation) + defaultAnimation: defaultAnimation, + resolvedDefaultAnimation: resolvedDefaultAnimation) + } + + static func resolveDefaultAnimation(_ value: String, in directory: URL) throws -> String { + // Keep random selection deferred until a client starts an activity. + if value == "random" { return value } + return try NyathingCLI.resolveAnimation( + value, in: directory.appendingPathComponent("animations", isDirectory: true), + relativeTo: directory) } } @@ -186,6 +191,7 @@ enum ConfigError: LocalizedError { case invalidLine(Int) case invalidKey(String, Int) case invalidValue(String) + case invalidDefaultAnimation(String) var errorDescription: String? { switch self { @@ -195,6 +201,8 @@ enum ConfigError: LocalizedError { case .invalidKey(let key, let line): return "Unknown or duplicate setting '\(key)' on line \(line). Use each supported setting once." + case .invalidDefaultAnimation(let reason): + return "Invalid 'default_animation': \(reason)" case .invalidValue(let key): switch key { case "max_wait_time": @@ -204,7 +212,7 @@ enum ConfigError: LocalizedError { "Missing or invalid '\(key)'. Add it to config.toml with the value true or false." case "default_animation": return - "Missing or invalid 'default_animation'. Set it to the filename of a valid animation in the animations directory." + "Missing or invalid 'default_animation'. Set it to an animation name, PNG path, or 'random'." default: return "Missing or invalid setting: \(key). Check config.toml and correct its value." } diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index ea1c7f3..08d5aeb 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -1,5 +1,6 @@ import AppKit import Foundation +import UniformTypeIdentifiers let arguments = Array(CommandLine.arguments.dropFirst()) if arguments == [LaunchAgentSupport.serverArgument] { @@ -380,10 +381,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { animationsByName[name] = animation } let animationNames = ["random"] + animationsByName.keys.sorted() - guard animationNames.count > 1 else { - showConfigurationEditorError("No valid animations are available.") - return - } let maxWaitTimeField = NSTextField(string: String(configuration.maxWaitTime)) maxWaitTimeField.placeholderString = "Seconds" @@ -395,12 +392,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { animationPicker.menu?.addItem( animationMenuItem(title: name, frame: animationsByName[name]?.frames.first)) } - let selectedAnimationName = - Self.shortAnimationName(configuration.defaultAnimation) - ?? configuration.defaultAnimation - if let index = animationNames.firstIndex(of: selectedAnimationName) { - animationPicker.selectItem(at: index) - } + selectAnimation(configuration.defaultAnimation, in: animationPicker) + let browseButton = NSButton( + title: "Choose PNG…", target: self, action: #selector(chooseConfigurationAnimation)) + let animationControls = NSStackView(views: [animationPicker, browseButton]) + animationControls.spacing = 8 + animationPicker.widthAnchor.constraint(equalToConstant: 170).isActive = true let autoStart = NSButton( checkboxWithTitle: "Launch Nyathing at login", target: self, action: nil) @@ -418,7 +415,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { let fields = NSStackView(views: [ row("Maximum wait time (seconds)", control: maxWaitTimeField), - row("Default animation", control: animationPicker), + row("Default animation", control: animationControls), autoStart, ]) fields.orientation = .vertical @@ -450,7 +447,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { ]) let window = NSWindow( - contentRect: NSRect(x: 0, y: 0, width: 430, height: 230), + contentRect: NSRect(x: 0, y: 0, width: 540, height: 230), styleMask: [.titled, .closable], backing: .buffered, defer: false) window.title = "Edit Configuration" window.isReleasedWhenClosed = false @@ -465,6 +462,30 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { NSApp.activate(ignoringOtherApps: true) } + private func selectAnimation(_ value: String, in picker: NSPopUpButton) { + if let item = picker.itemArray.first(where: { ($0.representedObject as? String) == value }) { + picker.select(item) + return + } + let title = URL(fileURLWithPath: value).lastPathComponent + let item = NSMenuItem(title: title, action: nil, keyEquivalent: "") + item.representedObject = value + item.toolTip = value + picker.menu?.addItem(item) + picker.select(item) + } + + @objc private func chooseConfigurationAnimation() { + guard let configurationWindow else { return } + let panel = NSOpenPanel() + panel.allowedContentTypes = [.png] + panel.beginSheetModal(for: configurationWindow) { [weak self] response in + guard response == .OK, let url = panel.url, let self, let picker = self.defaultAnimationPicker + else { return } + self.selectAnimation(url.path, in: picker) + } + } + @objc private func cancelConfigurationEdit() { configurationWindow?.close() } @@ -484,18 +505,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } let animation: String - if selectedAnimation == "random" { - animation = selectedAnimation - } else { - let animationDirectory = AppConfiguration.configurationDirectory - .appendingPathComponent("animations", isDirectory: true) - do { - let resolved = try NyathingCLI.resolveAnimation(selectedAnimation, in: animationDirectory) - animation = URL(fileURLWithPath: resolved).lastPathComponent - } catch { - showConfigurationEditorError(error.localizedDescription) - return - } + do { + _ = try AppConfiguration.resolveDefaultAnimation( + selectedAnimation, in: AppConfiguration.configurationDirectory) + let encoder = JSONEncoder() + encoder.outputFormatting = [.withoutEscapingSlashes] + animation = String(decoding: try encoder.encode(selectedAnimation), as: UTF8.self) + } catch { + showConfigurationEditorError(error.localizedDescription) + return } let configurationText = """ @@ -503,8 +521,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { max_wait_time = \(maxWaitTime) # Whether Nyathing should launch automatically when you log in. auto_start = \(autoStartCheckbox.state == .on ? "true" : "false") - # Animation filename used when a client omits the animation field. - default_animation = "\(animation)" + # Animation name, PNG path, or "random" used when a client omits the animation field. + default_animation = \(animation) """ let configurationURL = AppConfiguration.configurationDirectory @@ -555,7 +573,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { NyathingLog.report(error, context: "Unable to configure login launch") } maxWaitTime = configuration.maxWaitTime - defaultAnimation = configuration.defaultAnimation + defaultAnimation = configuration.resolvedDefaultAnimation try startAPIServer() } catch { let configurationURL = AppConfiguration.configurationDirectory.appendingPathComponent( @@ -575,14 +593,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private func startAPIServer() throws { let generation = apiGeneration - let animationsDirectory = AppConfiguration.configurationDirectory - .appendingPathComponent("animations", isDirectory: true) - let serverDefaultAnimation = - defaultAnimation == "random" - ? defaultAnimation - : animationsDirectory.appendingPathComponent(defaultAnimation).standardizedFileURL.path apiServer = LocalAPIServer( - defaultAnimation: serverDefaultAnimation, + defaultAnimation: defaultAnimation, maxWaitTime: maxWaitTime, onStart: { [weak self] filename, description, requestedID, interval, intervalWasProvided, timeout in diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index c638fad..8c77144 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -215,7 +215,7 @@ final class ConfigurationTests: XCTestCase { func testFirstLaunchSeedsConfigurationAndSampleAnimation() throws { let configuration = try AppConfiguration.load(in: temporaryDirectory) XCTAssertEqual(configuration.maxWaitTime, 180) - XCTAssertEqual(configuration.defaultAnimation, "nyathing_36x36.png") + XCTAssertEqual(configuration.defaultAnimation, "nyathing") XCTAssertTrue( FileManager.default.fileExists( atPath: temporaryDirectory.appendingPathComponent("config.toml").path)) @@ -260,13 +260,34 @@ final class ConfigurationTests: XCTestCase { func testRandomIsAcceptedAsDefaultAnimation() throws { let configurationText = AppConfiguration.template.replacingOccurrences( - of: "default_animation = \"nyathing_36x36.png\"", + of: "default_animation = \"nyathing\"", with: "default_animation = \"random\"") try writeConfiguration(configurationText) let configuration = try AppConfiguration.load(in: temporaryDirectory) XCTAssertEqual(configuration.defaultAnimation, "random") + XCTAssertEqual(configuration.resolvedDefaultAnimation, "random") + } + + func testDefaultAnimationAcceptsShortNameAndPaths() throws { + let external = temporaryDirectory.appendingPathComponent("custom # sprite_36x36.png") + try writePNG(width: 36, height: 36, to: external) + let installed = temporaryDirectory.appendingPathComponent("animations/nyathing_36x36.png") + for (value, expected) in [ + ("nyathing", installed), + ("nyathing_36x36.png", installed), + (external.path, external), + ("./\(external.lastPathComponent)", external), + ] { + let configurationText = AppConfiguration.template.replacingOccurrences( + of: "default_animation = \"nyathing\"", + with: "default_animation = \"\(value)\"") + try writeConfiguration(configurationText) + let configuration = try AppConfiguration.load(in: temporaryDirectory) + XCTAssertEqual(configuration.defaultAnimation, value) + XCTAssertEqual(configuration.resolvedDefaultAnimation, expected.standardizedFileURL.path) + } } func testLoadsAnimationWithFrameDimensionsFromFilename() throws { @@ -314,7 +335,7 @@ final class ConfigurationTests: XCTestCase { func testRemovesObsoleteIconSettingAndKeepsDefaultAnimation() throws { let oldTemplate = AppConfiguration.template .replacingOccurrences( - of: "default_animation = \"nyathing_36x36.png\"", + of: "default_animation = \"nyathing\"", with: "default_animation = \"ghost_36x36.png\"" ) .replacingOccurrences( From 9c6e4cf7ac0f06e9a78a04cf10dc4b884b92283c Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 19:12:07 +0400 Subject: [PATCH 39/43] Skip default animation validation for explicit selections Resolve the configured default only when a start request omits the animation. Reject invalid explicit selections without falling back, and cover the precedence rules with a local API regression test. --- README.md | 5 +- Sources/Nyathing/CLI.swift | 41 +++++------ Sources/Nyathing/Configuration.swift | 72 ++++++++++++------- Sources/Nyathing/LocalAPIServer.swift | 15 ++-- Sources/Nyathing/main.swift | 16 ++--- .../ConfigurationAndAPITests.swift | 44 ++++++++++-- 6 files changed, 126 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 81389b7..51bb114 100644 --- a/README.md +++ b/README.md @@ -293,8 +293,9 @@ twice that interval and `max_wait_time`. Like `--animation`, `default_animation` accepts a short name such as `nyathing`, a filename in `animations/`, a PNG path, or `random` to select an animation per activity. Relative paths in `config.toml` are resolved beside that file; CLI paths are relative to the working directory. -Requests with an explicit animation use it; missing or unavailable requested -animations fall back to the built-in ghost. +An explicit `-a` or `--animation` skips `default_animation` validation. +An invalid explicit selection fails instead of falling back. The configured +default is checked only when an activity starts without an animation. Choose **Edit Configuration** from the menu to change these settings with visual controls. **Choose PNG…** lets you select a file outside `animations/` and saves its full path. **Accept** saves the configuration and reloads settings and diff --git a/Sources/Nyathing/CLI.swift b/Sources/Nyathing/CLI.swift index 6f50dbd..dfa275f 100644 --- a/Sources/Nyathing/CLI.swift +++ b/Sources/Nyathing/CLI.swift @@ -157,9 +157,10 @@ enum NyathingCLI { } } if arguments == ["list"] { - _ = try AppConfiguration.load() - let directory = AppConfiguration.configurationDirectory - .appendingPathComponent("animations", isDirectory: true) + let configurationDirectory = AppConfiguration.configurationDirectory + try AppConfiguration.prepareDirectory(configurationDirectory) + let directory = + configurationDirectory.appendingPathComponent("animations", isDirectory: true) let names = SpriteAnimation.loadAll(in: directory).keys.compactMap { filename -> String? in guard let separator = filename.range( @@ -197,13 +198,7 @@ enum NyathingCLI { switch option { case "--animation", "-a": guard animation == nil else { throw CLIError.usage } - if value == "random" || isShortAnimationName(value) { - animation = value - } else { - let directory = AppConfiguration.configurationDirectory - .appendingPathComponent("animations", isDirectory: true) - animation = try resolveAnimation(value, in: directory) - } + animation = value case "--description": guard description == nil else { throw CLIError.usage } description = value @@ -220,7 +215,7 @@ enum NyathingCLI { index += 2 } var request: [String: Any] = ["command": "start"] - if let animation { request["animation"] = animation } + if let animation { request["animation"] = try explicitAnimationForRequest(animation) } if let description { request["description"] = description } if let activityID { request["activity_id"] = activityID } if let interval { request["keepalive_interval_seconds"] = NSNumber(value: interval) } @@ -247,18 +242,16 @@ enum NyathingCLI { private static func execute(_ cli: CLIArguments) throws -> Int32 { let executable = try resolveExecutable(cli.command) - let configuration = try AppConfiguration.load() - let animationsDirectory = AppConfiguration.configurationDirectory - .appendingPathComponent("animations", isDirectory: true) - let animation = try resolveAnimation( - cli.animation ?? configuration.resolvedDefaultAnimation, in: animationsDirectory) let keepaliveInterval = LocalAPIServer.defaultKeepaliveInterval - let client = try LocalAPIClient.connectOrStartServer() - let activity = try client.command([ + var request: [String: Any] = [ "command": "start", - "animation": animation, "description": activityDescription(command: cli.command, arguments: cli.arguments), - ]) + ] + if let animation = cli.animation { + request["animation"] = try explicitAnimationForRequest(animation) + } + let client = try LocalAPIClient.connectOrStartServer() + let activity = try client.command(request) guard let activityID = activity["activity_id"] as? String else { throw CLIError.api("The server returned an invalid activity response.") } @@ -314,6 +307,14 @@ enum NyathingCLI { return child.terminationStatus } + private static func explicitAnimationForRequest(_ value: String) throws -> String { + if value == "random" { return value } + let directory = AppConfiguration.configurationDirectory + try AppConfiguration.prepareDirectory(directory) + return try resolveAnimation( + value, in: directory.appendingPathComponent("animations", isDirectory: true)) + } + static func validateAnimation(_ filename: String, in directory: URL) throws { _ = try resolveAnimation(filename, in: directory) } diff --git a/Sources/Nyathing/Configuration.swift b/Sources/Nyathing/Configuration.swift index 7b07917..dc597c5 100644 --- a/Sources/Nyathing/Configuration.swift +++ b/Sources/Nyathing/Configuration.swift @@ -5,8 +5,30 @@ import ImageIO struct AppConfiguration { let maxWaitTime: TimeInterval let autoStart: Bool - let defaultAnimation: String - let resolvedDefaultAnimation: String + private let defaultAnimationValues: [String] + private let directory: URL + + var defaultAnimation: String { + get throws { + guard defaultAnimationValues.count == 1, + let rawAnimation = defaultAnimationValues.first, + let value = try? JSONDecoder().decode(String.self, from: Data(rawAnimation.utf8)), + !value.isEmpty + else { throw ConfigError.invalidValue("default_animation") } + return value + } + } + + var resolvedDefaultAnimation: String { + get throws { + let value = try defaultAnimation + do { + return try Self.resolveDefaultAnimation(value, in: directory) + } catch { + throw ConfigError.invalidDefaultAnimation(error.localizedDescription) + } + } + } static let template = """ # Maximum seconds to wait since the last client keepalive. @@ -52,12 +74,7 @@ struct AppConfiguration { return String(line) } - static func load() throws -> AppConfiguration { - try load(in: configurationDirectory) - } - - /// Loads and validates configuration from a configuration directory. - static func load(in directory: URL) throws -> AppConfiguration { + static func prepareDirectory(_ directory: URL) throws { let configURL = directory.appendingPathComponent("config.toml") let animationsDirectory = directory.appendingPathComponent("animations", isDirectory: true) try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) @@ -77,6 +94,13 @@ struct AppConfiguration { } } } + } + + static func load( + in directory: URL = configurationDirectory, validateDefaultAnimation: Bool = true + ) throws -> AppConfiguration { + try prepareDirectory(directory) + let configURL = directory.appendingPathComponent("config.toml") var text = try String(contentsOf: configURL, encoding: .utf8) var removedObsoleteSettings = false var legacyMaxWaitTime: String? @@ -129,6 +153,7 @@ struct AppConfiguration { try text.write(to: configURL, atomically: true, encoding: .utf8) } var values: [String: String] = [:] + var defaultAnimationValues: [String] = [] for (offset, rawLine) in text.split(separator: "\n", omittingEmptySubsequences: false) .enumerated() { @@ -139,12 +164,13 @@ struct AppConfiguration { } let key = line[.. Double { @@ -161,21 +187,13 @@ struct AppConfiguration { guard let rawAuto = values["auto_start"], rawAuto == "true" || rawAuto == "false" else { throw ConfigError.invalidValue("auto_start") } - guard let rawAnimation = values["default_animation"], - let defaultAnimation = try? JSONDecoder().decode(String.self, from: Data(rawAnimation.utf8)), - !defaultAnimation.isEmpty - else { throw ConfigError.invalidValue("default_animation") } - let resolvedDefaultAnimation: String - do { - resolvedDefaultAnimation = try resolveDefaultAnimation(defaultAnimation, in: directory) - } catch { - throw ConfigError.invalidDefaultAnimation(error.localizedDescription) - } - return AppConfiguration( + let configuration = AppConfiguration( maxWaitTime: try number("max_wait_time"), autoStart: rawAuto == "true", - defaultAnimation: defaultAnimation, - resolvedDefaultAnimation: resolvedDefaultAnimation) + defaultAnimationValues: defaultAnimationValues, + directory: directory) + if validateDefaultAnimation { _ = try configuration.resolvedDefaultAnimation } + return configuration } static func resolveDefaultAnimation(_ value: String, in directory: URL) throws -> String { diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index 6ba61c7..9477628 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -4,7 +4,7 @@ import Foundation /// Serves the local JSON Lines API over a current-user Unix domain socket. final class LocalAPIServer { static let defaultKeepaliveInterval: TimeInterval = 5 - private let defaultAnimation: String + private let defaultAnimation: () throws -> String private let maxWaitTime: TimeInterval private let onStart: (String, String?, String?, TimeInterval, Bool, TimeInterval) throws -> String private let onKeepalive: (String) throws -> Void @@ -17,7 +17,7 @@ final class LocalAPIServer { init( socketPath: String = LocalAPIServer.socketPath, - defaultAnimation: String = "nyathing_36x36.png", + defaultAnimation: @escaping () throws -> String = { "nyathing_36x36.png" }, maxWaitTime: TimeInterval = 180, onStart: @escaping (String, String?, String?, TimeInterval, Bool, TimeInterval) throws -> String, @@ -219,8 +219,15 @@ final class LocalAPIServer { } switch command { case "start": - let animation = request["animation"] as? String ?? defaultAnimation - guard !animation.isEmpty else { throw LocalAPIError.invalidRequest } + let animation: String + if let explicit = request["animation"] { + guard let value = explicit as? String, !value.isEmpty else { + throw LocalAPIError.invalidRequest + } + animation = value + } else { + animation = try defaultAnimation() + } let requestedActivityID = request["activity_id"] as? String if request["activity_id"] != nil && (requestedActivityID?.isEmpty ?? true) { throw LocalAPIError.invalidRequest diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 08d5aeb..5b9f2f2 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -53,7 +53,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private var timedOutActivityDetails: [UUID: ActivityTimeoutDetails] = [:] private var activityStartOrder: [UUID: UInt64] = [:] private var nextActivityStartOrder: UInt64 = 0 - private var defaultAnimation = "nyathing_36x36.png" private var apiServer: LocalAPIServer? private var apiGeneration = 0 private var errorsWindow: NSWindow? @@ -360,8 +359,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } let configuration: AppConfiguration + let configuredAnimation: String do { - configuration = try AppConfiguration.load() + configuration = try AppConfiguration.load(validateDefaultAnimation: false) + configuredAnimation = try configuration.defaultAnimation } catch { showConfigurationEditorError(error.localizedDescription) return @@ -392,7 +393,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { animationPicker.menu?.addItem( animationMenuItem(title: name, frame: animationsByName[name]?.frames.first)) } - selectAnimation(configuration.defaultAnimation, in: animationPicker) + selectAnimation(configuredAnimation, in: animationPicker) let browseButton = NSButton( title: "Choose PNG…", target: self, action: #selector(chooseConfigurationAnimation)) let animationControls = NSStackView(views: [animationPicker, browseButton]) @@ -561,7 +562,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { apiServer = nil clearRuntimeState() do { - let configuration = try AppConfiguration.load() + let configuration = try AppConfiguration.load(validateDefaultAnimation: false) do { try LaunchAgentSupport.configure( enabled: configuration.autoStart, @@ -573,8 +574,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { NyathingLog.report(error, context: "Unable to configure login launch") } maxWaitTime = configuration.maxWaitTime - defaultAnimation = configuration.resolvedDefaultAnimation - try startAPIServer() + try startAPIServer(configuration: configuration) } catch { let configurationURL = AppConfiguration.configurationDirectory.appendingPathComponent( "config.toml") @@ -591,10 +591,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { updateMainStatusItem() } - private func startAPIServer() throws { + private func startAPIServer(configuration: AppConfiguration) throws { let generation = apiGeneration apiServer = LocalAPIServer( - defaultAnimation: defaultAnimation, + defaultAnimation: { try configuration.resolvedDefaultAnimation }, maxWaitTime: maxWaitTime, onStart: { [weak self] filename, description, requestedID, interval, intervalWasProvided, timeout in diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index 8c77144..fac33a4 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -215,7 +215,7 @@ final class ConfigurationTests: XCTestCase { func testFirstLaunchSeedsConfigurationAndSampleAnimation() throws { let configuration = try AppConfiguration.load(in: temporaryDirectory) XCTAssertEqual(configuration.maxWaitTime, 180) - XCTAssertEqual(configuration.defaultAnimation, "nyathing") + XCTAssertEqual(try configuration.defaultAnimation, "nyathing") XCTAssertTrue( FileManager.default.fileExists( atPath: temporaryDirectory.appendingPathComponent("config.toml").path)) @@ -266,8 +266,8 @@ final class ConfigurationTests: XCTestCase { let configuration = try AppConfiguration.load(in: temporaryDirectory) - XCTAssertEqual(configuration.defaultAnimation, "random") - XCTAssertEqual(configuration.resolvedDefaultAnimation, "random") + XCTAssertEqual(try configuration.defaultAnimation, "random") + XCTAssertEqual(try configuration.resolvedDefaultAnimation, "random") } func testDefaultAnimationAcceptsShortNameAndPaths() throws { @@ -285,8 +285,8 @@ final class ConfigurationTests: XCTestCase { with: "default_animation = \"\(value)\"") try writeConfiguration(configurationText) let configuration = try AppConfiguration.load(in: temporaryDirectory) - XCTAssertEqual(configuration.defaultAnimation, value) - XCTAssertEqual(configuration.resolvedDefaultAnimation, expected.standardizedFileURL.path) + XCTAssertEqual(try configuration.defaultAnimation, value) + XCTAssertEqual(try configuration.resolvedDefaultAnimation, expected.standardizedFileURL.path) } } @@ -499,6 +499,38 @@ final class ActivityLifecycleTests: XCTestCase { } final class LocalAPIServerTests: XCTestCase { + func testExplicitAnimationDoesNotRequireValidConfiguredDefault() throws { + let directory = URL( + fileURLWithPath: "/tmp/nyathing-\(UUID().uuidString.prefix(8))", isDirectory: true) + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + defer { try? FileManager.default.removeItem(at: directory) } + let text = AppConfiguration.template.replacingOccurrences( + of: "default_animation = \"nyathing\"", with: "default_animation = false") + try text.write( + to: directory.appendingPathComponent("config.toml"), atomically: true, encoding: .utf8) + let configuration = try AppConfiguration.load(in: directory, validateDefaultAnimation: false) + let animations = directory.appendingPathComponent("animations", isDirectory: true) + let socketPath = directory.appendingPathComponent("api.sock").path + let server = LocalAPIServer( + socketPath: socketPath, + defaultAnimation: { try configuration.resolvedDefaultAnimation }, + onStart: { animation, _, _, _, _, _ in + try NyathingCLI.resolveAnimation(animation, in: animations) + }, onKeepalive: { _ in }, onStop: { _ in }) + try server.start() + defer { server.stop() } + + let client = try UnixJSONClient(path: socketPath) + XCTAssertEqual( + try client.command(["command": "start", "animation": "nyathing"])["ok"] as? Bool, true) + let invalid = try client.command(["command": "start", "animation": "not-installed"]) + XCTAssertEqual(invalid["ok"] as? Bool, false) + XCTAssertTrue((invalid["error"] as? String)?.contains("not-installed") == true) + let omitted = try client.command(["command": "start"]) + XCTAssertEqual(omitted["ok"] as? Bool, false) + XCTAssertTrue((omitted["error"] as? String)?.contains("default_animation") == true) + } + func testMultipleCommandsOnConnectionAndConcurrentClients() throws { let directory = URL( fileURLWithPath: "/tmp/nyathing-\(UUID().uuidString.prefix(8))", isDirectory: true) @@ -515,7 +547,7 @@ final class LocalAPIServerTests: XCTestCase { var stoppedIDs: [String] = [] let server = LocalAPIServer( socketPath: socketPath, - defaultAnimation: "nyan_54x36.png", + defaultAnimation: { "nyan_54x36.png" }, maxWaitTime: 30, onStart: { animation, description, requestedID, interval, intervalWasProvided, timeout in lock.lock() From 58b9ce4bc2ca9c3b7bdb2ce5d892c1d58ef3c531 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 21:12:32 +0400 Subject: [PATCH 40/43] Reload configuration without interrupting active animations Update the default animation and wait limit for future activities without restarting the local API server or clearing active state. Extend the API test to verify that an existing connection can send keepalives and stop an activity after applying new settings, while new activities use the updated default animation and wait limit. --- README.md | 7 ++-- Sources/Nyathing/LocalAPIServer.swift | 26 ++++++++++-- Sources/Nyathing/main.swift | 40 +++++++------------ .../ConfigurationAndAPITests.swift | 13 ++++++ 4 files changed, 52 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 51bb114..a428020 100644 --- a/README.md +++ b/README.md @@ -298,10 +298,9 @@ An invalid explicit selection fails instead of falling back. The configured default is checked only when an activity starts without an animation. Choose **Edit Configuration** from the menu to change these settings with visual controls. **Choose PNG…** lets you select a file outside `animations/` -and saves its full path. **Accept** saves the configuration and reloads settings and -animations; this also clears active activities and the disconnected-client -count. **Cancel** closes the editor without applying changes. Accepting the -current settings also reloads animation files changed outside the editor. +and saves its full path. **Accept** applies the new default animation and wait +limit to future activities without interrupting running ones. **Cancel** closes +the editor without applying changes. ## ▦ Animation file format diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index 9477628..ab55f6b 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -4,8 +4,8 @@ import Foundation /// Serves the local JSON Lines API over a current-user Unix domain socket. final class LocalAPIServer { static let defaultKeepaliveInterval: TimeInterval = 5 - private let defaultAnimation: () throws -> String - private let maxWaitTime: TimeInterval + private var defaultAnimation: () throws -> String + private var maxWaitTime: TimeInterval private let onStart: (String, String?, String?, TimeInterval, Bool, TimeInterval) throws -> String private let onKeepalive: (String) throws -> Void private let onStop: (String) throws -> Void @@ -32,6 +32,23 @@ final class LocalAPIServer { self.socketPath = socketPath } + /// Updates the settings for future starts without disconnecting existing clients. + func updateStartSettings( + defaultAnimation: @escaping () throws -> String, maxWaitTime: TimeInterval + ) { + lock.lock() + defer { lock.unlock() } + self.defaultAnimation = defaultAnimation + self.maxWaitTime = maxWaitTime + } + + private func startSettings() -> (defaultAnimation: () throws -> String, maxWaitTime: TimeInterval) + { + lock.lock() + defer { lock.unlock() } + return (defaultAnimation, maxWaitTime) + } + deinit { stop() } static var socketPath: String { @@ -219,6 +236,7 @@ final class LocalAPIServer { } switch command { case "start": + let settings = startSettings() let animation: String if let explicit = request["animation"] { guard let value = explicit as? String, !value.isEmpty else { @@ -226,7 +244,7 @@ final class LocalAPIServer { } animation = value } else { - animation = try defaultAnimation() + animation = try settings.defaultAnimation() } let requestedActivityID = request["activity_id"] as? String if request["activity_id"] != nil && (requestedActivityID?.isEmpty ?? true) { @@ -242,7 +260,7 @@ final class LocalAPIServer { } else { keepaliveInterval = Self.defaultKeepaliveInterval } - let activityTimeout = min(keepaliveInterval * 2, maxWaitTime) + let activityTimeout = min(keepaliveInterval * 2, settings.maxWaitTime) return [ "ok": true, "activity_id": try onStart( diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 5b9f2f2..bb0c2d8 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -69,7 +69,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { if serverMode { startDedicatedServer() } else { - reloadConfigurationAndAnimations() + reloadConfiguration() } animationTimer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { [weak self] _ in self?.advanceAnimations() @@ -78,7 +78,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private func startDedicatedServer() { // Keep the AppKit event loop alive for API callbacks and animation updates. - reloadConfigurationAndAnimations() + reloadConfiguration() } func applicationWillTerminate(_ notification: Notification) { @@ -536,7 +536,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } configurationWindow?.close() - reloadConfigurationAndAnimations() + reloadConfiguration() } private func showConfigurationEditorError(_ message: String) { @@ -556,11 +556,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { defaultAnimationPicker = nil } - private func reloadConfigurationAndAnimations() { - apiGeneration += 1 - apiServer?.stop() - apiServer = nil - clearRuntimeState() + private func reloadConfiguration() { do { let configuration = try AppConfiguration.load(validateDefaultAnimation: false) do { @@ -574,7 +570,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { NyathingLog.report(error, context: "Unable to configure login launch") } maxWaitTime = configuration.maxWaitTime - try startAPIServer(configuration: configuration) + if let apiServer { + apiServer.updateStartSettings( + defaultAnimation: { try configuration.resolvedDefaultAnimation }, + maxWaitTime: maxWaitTime) + } else { + try startAPIServer(configuration: configuration) + } } catch { let configurationURL = AppConfiguration.configurationDirectory.appendingPathComponent( "config.toml") @@ -593,7 +595,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private func startAPIServer(configuration: AppConfiguration) throws { let generation = apiGeneration - apiServer = LocalAPIServer( + let server = LocalAPIServer( defaultAnimation: { try configuration.resolvedDefaultAnimation }, maxWaitTime: maxWaitTime, onStart: { @@ -633,22 +635,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } } ) - try apiServer?.start() - } - - private func clearRuntimeState() { - activeAnimations.removeAll() - activityTimeouts.removeAll() - externalActivityIDs.removeAll() - activityKeepaliveIntervals.removeAll() - activityKeepaliveIntervalSources.removeAll() - timedOutActivityDetails.removeAll() - activityStartOrder.removeAll() - nextActivityStartOrder = 0 - lifecycle.reset() - updateMainStatusItemVisibility() - updateMainStatusItem() - refreshErrorsWindow() + try server.start() + apiServer = server } /// Begins an activity for a named animation, sharing its status item with matching activities. diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index fac33a4..a8b080b 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -632,6 +632,19 @@ final class LocalAPIServerTests: XCTestCase { XCTAssertEqual(startedIntervalsWereProvided, [false, true, true, true, true]) lock.unlock() + server.updateStartSettings(defaultAnimation: { "new_36x36.png" }, maxWaitTime: 4) + XCTAssertEqual( + try second.command(["command": "keepalive", "activity_id": "activity-4"])["ok"] as? Bool, + true) + XCTAssertEqual(try second.command(["command": "start"])["activity_id"] as? String, "activity-6") + lock.lock() + XCTAssertEqual(startedAnimations.last, "new_36x36.png") + XCTAssertEqual(startedTimeouts.last, 4) + lock.unlock() + XCTAssertEqual( + try second.command(["command": "stop", "activity_id": "activity-4"])["ok"] as? Bool, + true) + let responseLock = NSLock() var concurrentResults: [Bool] = [] DispatchQueue.concurrentPerform(iterations: 4) { _ in From 015bf33cf6f1402553bb22f91c0238e85c379d58 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sat, 21 Nov 2026 22:58:34 +0400 Subject: [PATCH 41/43] Show elapsed time in active task menu --- Sources/Nyathing/main.swift | 60 ++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index bb0c2d8..97cd40d 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -26,7 +26,30 @@ private func runNyathingApplication(serverMode: Bool) { application.run() } -final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { +private final class ActiveTaskMenuRow: NSView { + init(description: String, time: String, icon: NSImage, width: CGFloat, font: NSFont, timeWidth: CGFloat) { + super.init(frame: NSRect(x: 0, y: 0, width: width, height: 22)) + let imageView = NSImageView(image: icon) + imageView.frame = NSRect(x: 0, y: 3, width: 16, height: 16) + addSubview(imageView) + + let timeField = NSTextField(labelWithString: time) + timeField.font = font + timeField.alignment = .right + timeField.frame = NSRect(x: width - timeWidth - 8, y: 2, width: timeWidth + 4, height: 18) + addSubview(timeField) + + let descriptionField = NSTextField(labelWithString: description) + descriptionField.font = font + descriptionField.lineBreakMode = .byTruncatingTail + descriptionField.frame = NSRect(x: 22, y: 2, width: max(0, width - 22 - timeWidth - 20), height: 18) + addSubview(descriptionField) + } + + required init?(coder: NSCoder) { nil } +} + +final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMenuDelegate { private let serverMode: Bool init(serverMode: Bool = false) { @@ -52,6 +75,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private var activityKeepaliveIntervalSources: [UUID: String] = [:] private var timedOutActivityDetails: [UUID: ActivityTimeoutDetails] = [:] private var activityStartOrder: [UUID: UInt64] = [:] + private var activityStartUptime: [UUID: TimeInterval] = [:] private var nextActivityStartOrder: UInt64 = 0 private var apiServer: LocalAPIServer? private var apiGeneration = 0 @@ -89,6 +113,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private func configureMenu(for item: NSStatusItem) { let menu = NSMenu() + menu.delegate = self let activities = activeTaskMenuItems() for menuItem in activities { menu.addItem(menuItem) } if !activities.isEmpty { menu.addItem(.separator()) } @@ -117,23 +142,33 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { ].map { ($0 as NSString).size(withAttributes: [.font: font]).width }.max() ?? 0 let iconColumnWidth: CGFloat = 16 let horizontalMenuPadding: CGFloat = 16 - let availableWidth = max(0, widestActionTitle - iconColumnWidth - horizontalMenuPadding) + let availableWidth = max(0, widestActionTitle * 1.3 - iconColumnWidth - horizontalMenuPadding) return rows.compactMap { id in guard let animation = lifecycle.animation(for: id), - let active = activeAnimations[animation], let icon = active.frames.first, + let active = activeAnimations[animation], !active.frames.isEmpty, let description = lifecycle.description(for: id) else { return nil } - let item = NSMenuItem( - title: Self.truncatedMenuDescription(description, font: font, width: availableWidth), - action: nil, keyEquivalent: "") - let menuIcon = (icon.copy() as? NSImage) ?? icon + let elapsed = max(0, ProcessInfo.processInfo.systemUptime - (activityStartUptime[id] ?? ProcessInfo.processInfo.systemUptime)) + let time = "⏱ \(Self.formattedElapsedTime(elapsed))s" + let timeWidth = (time as NSString).size(withAttributes: [.font: font]).width + let descriptionWidth = max(0, availableWidth - timeWidth - 12) + let shortenedDescription = Self.truncatedMenuDescription(description, font: font, width: descriptionWidth) + let item = NSMenuItem(title: "", action: nil, keyEquivalent: "") + let firstFrame = active.frames[0] + let menuIcon = (firstFrame.copy() as? NSImage) ?? firstFrame menuIcon.size = NSSize(width: iconColumnWidth, height: iconColumnWidth) - item.image = menuIcon + item.view = ActiveTaskMenuRow( + description: shortenedDescription, time: time, icon: menuIcon, + width: widestActionTitle * 1.3 + 18, font: font, timeWidth: timeWidth) item.isEnabled = false return item } } + private static func formattedElapsedTime(_ elapsed: TimeInterval) -> String { + String(format: "%d:%02d", Int(elapsed) / 60, Int(elapsed) % 60) + } + private static func truncatedMenuDescription(_ text: String, font: NSFont, width: CGFloat) -> String { @@ -149,6 +184,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { return result.isEmpty ? ellipsis : result + ellipsis } + func menuWillOpen(_ menu: NSMenu) { + if let mainStatusItem, mainStatusItem.menu === menu { + configureMenu(for: mainStatusItem) + } else if let active = activeAnimations.values.first(where: { $0.statusItem.menu === menu }) { + configureMenu(for: active.statusItem) + } + } + private func refreshStatusItemMenus() { if let mainStatusItem { configureMenu(for: mainStatusItem) } for active in activeAnimations.values { configureMenu(for: active.statusItem) } @@ -670,6 +713,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { let id = lifecycle.start( animation: resolvedFilename, description: description, deadline: deadlineUptime) activityStartOrder[id] = nextActivityStartOrder + activityStartUptime[id] = ProcessInfo.processInfo.systemUptime nextActivityStartOrder &+= 1 activityTimeouts[id] = timeout activityKeepaliveIntervals[id] = keepaliveInterval From 1f8c18b439ec8a2b9f74cf4648d7912229e15ff6 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sun, 22 Nov 2026 10:02:47 +0400 Subject: [PATCH 42/43] Add an active animations window Move elapsed time from the menu into a scrollable window that shows activity IDs, icons, and descriptions. Capture elapsed time when the window opens instead of updating it on a timer. Allow users to cancel individual activities and report the reason to the client on its next keepalive. --- Sources/Nyathing/LocalAPIServer.swift | 2 + Sources/Nyathing/main.swift | 185 ++++++++++++++++++++++---- 2 files changed, 158 insertions(+), 29 deletions(-) diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index ab55f6b..5d23cd4 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -352,6 +352,7 @@ enum LocalAPIError: LocalizedError { case serverManagedActivityTimeout case unknownCommand(String) case unknownActivity + case animationCancelled case activityIDInUse(String) case socketPathTooLong case alreadyRunning(String) @@ -368,6 +369,7 @@ enum LocalAPIError: LocalizedError { "'activity_timeout_seconds' is controlled by the server and cannot be set per activity." case .unknownCommand(let command): return "Unknown command: \(command)." case .unknownActivity: return "Unknown activity ID." + case .animationCancelled: return "Animation was cancelled." case .activityIDInUse(let id): return "Activity ID \"\(id)\" is already in use." case .socketPathTooLong: return "The local API socket path is too long." case .alreadyRunning(let path): return "Another Nyathing instance is listening at \(path)." diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 97cd40d..39ed972 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -27,7 +27,10 @@ private func runNyathingApplication(serverMode: Bool) { } private final class ActiveTaskMenuRow: NSView { - init(description: String, time: String, icon: NSImage, width: CGFloat, font: NSFont, timeWidth: CGFloat) { + init( + description: String, time: String, icon: NSImage, width: CGFloat, font: NSFont, + timeWidth: CGFloat + ) { super.init(frame: NSRect(x: 0, y: 0, width: width, height: 22)) let imageView = NSImageView(image: icon) imageView.frame = NSRect(x: 0, y: 3, width: 16, height: 16) @@ -42,14 +45,19 @@ private final class ActiveTaskMenuRow: NSView { let descriptionField = NSTextField(labelWithString: description) descriptionField.font = font descriptionField.lineBreakMode = .byTruncatingTail - descriptionField.frame = NSRect(x: 22, y: 2, width: max(0, width - 22 - timeWidth - 20), height: 18) + descriptionField.frame = NSRect( + x: 22, y: 2, width: max(0, width - 22 - timeWidth - 20), height: 18) addSubview(descriptionField) } required init?(coder: NSCoder) { nil } } -final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMenuDelegate { +private final class ActiveActivitiesDocumentView: NSView { + override var isFlipped: Bool { true } +} + +final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private let serverMode: Bool init(serverMode: Bool = false) { @@ -76,11 +84,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe private var timedOutActivityDetails: [UUID: ActivityTimeoutDetails] = [:] private var activityStartOrder: [UUID: UInt64] = [:] private var activityStartUptime: [UUID: TimeInterval] = [:] + private var activeActivitiesOpenedAt: TimeInterval = 0 private var nextActivityStartOrder: UInt64 = 0 private var apiServer: LocalAPIServer? private var apiGeneration = 0 private var errorsWindow: NSWindow? private var errorsStackView: NSStackView? + private var activeActivitiesWindow: NSWindow? + private var activeActivitiesStackView: NSStackView? + private var cancelledActivityIDs: Set = [] private var configurationWindow: NSWindow? private var maxWaitTimeField: NSTextField? private var autoStartCheckbox: NSButton? @@ -113,10 +125,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe private func configureMenu(for item: NSStatusItem) { let menu = NSMenu() - menu.delegate = self let activities = activeTaskMenuItems() for menuItem in activities { menu.addItem(menuItem) } - if !activities.isEmpty { menu.addItem(.separator()) } + if !activities.isEmpty { + menu.addItem( + withTitle: "View All Active Animations", action: #selector(viewActiveActivities(_:)), + keyEquivalent: "") + menu.addItem(.separator()) + } if !lifecycle.timedOutActivities.isEmpty { menu.addItem( withTitle: "View Errors", action: #selector(viewErrors), keyEquivalent: "") @@ -148,27 +164,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe let active = activeAnimations[animation], !active.frames.isEmpty, let description = lifecycle.description(for: id) else { return nil } - let elapsed = max(0, ProcessInfo.processInfo.systemUptime - (activityStartUptime[id] ?? ProcessInfo.processInfo.systemUptime)) - let time = "⏱ \(Self.formattedElapsedTime(elapsed))s" - let timeWidth = (time as NSString).size(withAttributes: [.font: font]).width - let descriptionWidth = max(0, availableWidth - timeWidth - 12) - let shortenedDescription = Self.truncatedMenuDescription(description, font: font, width: descriptionWidth) - let item = NSMenuItem(title: "", action: nil, keyEquivalent: "") + let shortenedDescription = Self.truncatedMenuDescription( + description, font: font, width: availableWidth) + let item = NSMenuItem(title: shortenedDescription, action: nil, keyEquivalent: "") let firstFrame = active.frames[0] let menuIcon = (firstFrame.copy() as? NSImage) ?? firstFrame menuIcon.size = NSSize(width: iconColumnWidth, height: iconColumnWidth) - item.view = ActiveTaskMenuRow( - description: shortenedDescription, time: time, icon: menuIcon, - width: widestActionTitle * 1.3 + 18, font: font, timeWidth: timeWidth) + item.image = menuIcon item.isEnabled = false return item } } - private static func formattedElapsedTime(_ elapsed: TimeInterval) -> String { - String(format: "%d:%02d", Int(elapsed) / 60, Int(elapsed) % 60) - } - private static func truncatedMenuDescription(_ text: String, font: NSFont, width: CGFloat) -> String { @@ -184,14 +191,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe return result.isEmpty ? ellipsis : result + ellipsis } - func menuWillOpen(_ menu: NSMenu) { - if let mainStatusItem, mainStatusItem.menu === menu { - configureMenu(for: mainStatusItem) - } else if let active = activeAnimations.values.first(where: { $0.statusItem.menu === menu }) { - configureMenu(for: active.statusItem) - } - } - private func refreshStatusItemMenus() { if let mainStatusItem { configureMenu(for: mainStatusItem) } for active in activeAnimations.values { configureMenu(for: active.statusItem) } @@ -231,6 +230,125 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe NSApp.terminate(nil) } + @objc private func viewActiveActivities(_ sender: NSMenuItem) { + if activeActivitiesWindow == nil { + let window = NSWindow( + contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), + styleMask: [.titled, .closable, .miniaturizable, .resizable], + backing: .buffered, defer: false) + window.title = "Active Animations" + window.isReleasedWhenClosed = false + let scrollView = NSScrollView() + scrollView.hasVerticalScroller = true + let stack = NSStackView() + stack.orientation = .vertical + stack.alignment = .leading + stack.spacing = 10 + stack.edgeInsets = NSEdgeInsets(top: 16, left: 20, bottom: 20, right: 20) + let document = ActiveActivitiesDocumentView() + document.translatesAutoresizingMaskIntoConstraints = false + stack.translatesAutoresizingMaskIntoConstraints = false + document.addSubview(stack) + scrollView.documentView = document + window.contentView = scrollView + NSLayoutConstraint.activate([ + document.widthAnchor.constraint(equalTo: scrollView.contentView.widthAnchor), + stack.leadingAnchor.constraint(equalTo: document.leadingAnchor), + stack.trailingAnchor.constraint(equalTo: document.trailingAnchor), + stack.topAnchor.constraint(equalTo: document.topAnchor), + stack.bottomAnchor.constraint(equalTo: document.bottomAnchor), + ]) + activeActivitiesWindow = window + activeActivitiesStackView = stack + } + activeActivitiesOpenedAt = ProcessInfo.processInfo.systemUptime + refreshActiveActivitiesWindow() + activeActivitiesWindow?.center() + activeActivitiesWindow?.makeKeyAndOrderFront(nil) + NSApp.activate(ignoringOtherApps: true) + } + + private func refreshActiveActivitiesWindow() { + guard let stack = activeActivitiesStackView else { return } + for view in Array(stack.arrangedSubviews) { + stack.removeArrangedSubview(view) + view.removeFromSuperview() + } + let ids = activityStartOrder.keys.sorted { + activityStartOrder[$0, default: 0] > activityStartOrder[$1, default: 0] + } + for id in ids { + guard let animation = lifecycle.animation(for: id), + let active = activeAnimations[animation], let description = lifecycle.description(for: id) + else { continue } + let row = NSStackView() + row.orientation = .horizontal + row.alignment = .centerY + row.spacing = 10 + if let frame = active.frames.first { + let icon = NSImageView(image: frame) + icon.imageScaling = .scaleProportionallyUpOrDown + row.addArrangedSubview(icon) + NSLayoutConstraint.activate([ + icon.widthAnchor.constraint(equalToConstant: 24), + icon.heightAnchor.constraint(equalToConstant: 24), + ]) + } + let idLabel = NSTextField(labelWithString: "ID: \(id.uuidString)") + idLabel.font = .monospacedSystemFont(ofSize: 11, weight: .regular) + idLabel.lineBreakMode = .byTruncatingTail + idLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + row.addArrangedSubview(idLabel) + let spacer = NSView() + spacer.setContentHuggingPriority(.defaultLow, for: .horizontal) + row.addArrangedSubview(spacer) + let cancel = NSButton( + title: "Cancel", target: self, action: #selector(cancelActiveActivity(_:))) + cancel.identifier = NSUserInterfaceItemIdentifier(id.uuidString) + row.addArrangedSubview(cancel) + + let block = NSStackView() + block.orientation = .vertical + block.alignment = .leading + block.spacing = 5 + block.addArrangedSubview(row) + row.widthAnchor.constraint(equalTo: block.widthAnchor).isActive = true + + let descriptionLabel = NSTextField(wrappingLabelWithString: "Description: \(description)") + descriptionLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + block.addArrangedSubview(descriptionLabel) + descriptionLabel.widthAnchor.constraint(equalTo: block.widthAnchor).isActive = true + + let startedAt = activityStartUptime[id] ?? activeActivitiesOpenedAt + let elapsed = Int(max(0, activeActivitiesOpenedAt - startedAt)) + let duration = String(format: "%ld:%02ld", elapsed / 60, elapsed % 60) + block.addArrangedSubview(NSTextField(labelWithString: "Time spent: \(duration)")) + stack.addArrangedSubview(block) + block.widthAnchor.constraint(equalTo: stack.widthAnchor, constant: -40).isActive = true + } + if stack.arrangedSubviews.isEmpty { + stack.addArrangedSubview(NSTextField(labelWithString: "No active animations")) + } + } + + @objc private func cancelActiveActivity(_ sender: NSButton) { + guard let id = UUID(uuidString: sender.identifier?.rawValue ?? ""), + let animation = lifecycle.animation(for: id) + else { return } + for (externalID, mappedID) in externalActivityIDs where mappedID == id { + cancelledActivityIDs.insert(externalID) + } + _ = lifecycle.stop(id) + activityStartOrder.removeValue(forKey: id) + activityStartUptime.removeValue(forKey: id) + activityTimeouts.removeValue(forKey: id) + activityKeepaliveIntervals.removeValue(forKey: id) + activityKeepaliveIntervalSources.removeValue(forKey: id) + removeActivityFromStatusItem(id, animation: animation) + refreshStatusItemMenus() + refreshActiveActivitiesWindow() + } + @objc private func viewErrors() { if errorsWindow == nil { let window = NSWindow( @@ -659,9 +777,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe }, onKeepalive: { [weak self] activityID in try DispatchQueue.main.sync { - guard let self, self.apiGeneration == generation, - let id = self.externalActivityIDs[activityID], self.keepaliveActivity(id) - else { + guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } + if self.cancelledActivityIDs.remove(activityID) != nil { + self.externalActivityIDs.removeValue(forKey: activityID) + throw LocalAPIError.animationCancelled + } + guard let id = self.externalActivityIDs[activityID], self.keepaliveActivity(id) else { throw LocalAPIError.unknownActivity } } @@ -726,6 +847,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe updateMainStatusItemVisibility() updateMainStatusItem() refreshStatusItemMenus() + refreshActiveActivitiesWindow() return id } @@ -739,6 +861,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe updateMainStatusItemVisibility() updateMainStatusItem() refreshStatusItemMenus() + refreshActiveActivitiesWindow() return id } @@ -749,6 +872,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe activityKeepaliveIntervals.removeValue(forKey: id) activityKeepaliveIntervalSources.removeValue(forKey: id) activityStartOrder.removeValue(forKey: id) + activityStartUptime.removeValue(forKey: id) + refreshActiveActivitiesWindow() removeActivityFromStatusItem(id, animation: filename) refreshStatusItemMenus() } @@ -869,6 +994,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe keepaliveInterval: interval, intervalSource: intervalSource, timeout: timeout, maxWaitTime: maxWaitTime) activityStartOrder.removeValue(forKey: id) + activityStartUptime.removeValue(forKey: id) + refreshActiveActivitiesWindow() removeActivityFromStatusItem(id, animation: expired.animation) refreshStatusItemMenus() presentActivityTimeout() From 90ae40d1eacdba69cd341c2120a5bbd99821ca16 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Sun, 22 Nov 2026 10:20:05 +0400 Subject: [PATCH 43/43] Add stable local API error codes Keep human-readable messages alongside machine-readable codes and document the response format in the README. Reserve cancelled IDs for max_wait_time so both keepalive and stop report cancellation and a new start cannot reuse the ID prematurely. Remove the obsolete activity_timeout_seconds override and migration. --- README.md | 44 ++++++++-- Sources/Nyathing/ActivityLifecycle.swift | 26 ++++++ Sources/Nyathing/Configuration.swift | 5 -- Sources/Nyathing/LocalAPIServer.swift | 63 +++++++++++--- Sources/Nyathing/main.swift | 39 +++++---- .../ConfigurationAndAPITests.swift | 84 ++++++++++++++++--- 6 files changed, 209 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index a428020..45e8f5d 100644 --- a/README.md +++ b/README.md @@ -143,8 +143,8 @@ nyathing client start The server starts automatically if it is not already running. On `start` Nyathing prints the activity ID. -You can provide an ID with `--activity-id`; starting an already active ID fails -with an error: +You can provide an ID with `--activity-id`. Starting an active or reserved ID +fails with an error: ```sh nyathing client start --activity-id "$(uuidgen)" @@ -349,7 +349,7 @@ messages are supported: | `animation` | string | No | Short name searched in the server's animation directory, or a path to a PNG sprite sheet. Defaults to the server's configured animation. Invalid explicit values return an error. | | `description` | string | No | Description shown for the activity. If omitted or not a string, the server uses its default description. | | `keepalive_interval_seconds` | number | No | Positive, finite interval in seconds at which the client promises to send keepalives. Defaults to 5 seconds. The activity expires after the smaller of twice this interval and the server's configured `max_wait_time`. | -| `activity_id` | string | No | Caller-provided activity ID. Must not match an active activity; otherwise the request fails and names the ID. If omitted, the server generates a UUID. | +| `activity_id` | string | No | Caller-provided activity ID. Must not match an active or reserved ID. If omitted, the server generates a UUID. | A short name without a frame-size suffix or `.png` is resolved in the server's animation directory. Other values are treated as file paths; relative paths @@ -415,14 +415,40 @@ Successful `keepalive` and `stop` responses are: A failed request returns an error response: ```json -{"ok":false,"error":""} +{"ok":false,"error_code":"animation_cancelled","error":"Animation was cancelled."} ``` -Errors include malformed requests, unknown commands or activity identifiers, -invalid keepalive intervals, per-activity timeout overrides, and oversized -request lines. An activity expires after the smaller of twice its keepalive -interval and the configured `max_wait_time`. Expiration increments the -disconnected-client count; an explicit `stop` does not. +Use `error_code` to identify the failure in client code. The existing `error` +field is a human-readable message; angle brackets below mark variable text. +Connection and socket setup failures do not return a JSON response. + +| Code | Reason | Message template | +| --------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------ | +| `invalid_request` | Malformed JSON, invalid request shape, or invalid arguments. | `Invalid JSON Lines request.` | +| `request_too_large` | The request line exceeds 1 MiB. | `Request line is too large.` | +| `unknown_command` | The command is not supported. | `Unknown command: .` | +| `invalid_keepalive_interval` | The keepalive interval is not a positive finite number. | `'keepalive_interval_seconds' must be a positive finite number of seconds.` | +| `activity_id_in_use` | The requested ID is active or reserved after cancellation. | `Activity ID "" is already in use.` | +| `unknown_activity` | The activity ID is not recognized. | `Unknown activity ID.` | +| `animation_cancelled` | A `keepalive` or `stop` targets a reserved, cancelled ID. | `Animation was cancelled.` | +| `invalid_default_animation` | The configured default animation could not be resolved. | `Cannot use the default animation: ` | +| `animation_unavailable` | The animation could not be resolved or loaded. | `Cannot load the animation: ` | +| `server_unavailable` | An in-flight request reaches the server during shutdown. | `The local API is unavailable.` | +| `internal_error` | An unexpected server error prevented completion. | `An internal server error occurred.` | + +During shutdown the socket may close before the server can send +`server_unavailable`; clients should also handle connection loss. + +An activity expires after the smaller of twice its keepalive interval and the +configured `max_wait_time`. Expiration increments the disconnected-client +count; an explicit `stop` does not. + +After **Cancel** in the app, the server reserves the ID for the `max_wait_time` +configured at the moment of cancellation. During that period, every `keepalive` +and `stop` for that ID returns `animation_cancelled`, and `start` with the same +ID returns `activity_id_in_use`. Requests do not extend the reservation. Once it +expires, `keepalive` and `stop` return `unknown_activity` until a successful +`start` reuses the ID. ## ✦ Examples diff --git a/Sources/Nyathing/ActivityLifecycle.swift b/Sources/Nyathing/ActivityLifecycle.swift index 5bb249e..7895d0d 100644 --- a/Sources/Nyathing/ActivityLifecycle.swift +++ b/Sources/Nyathing/ActivityLifecycle.swift @@ -1,5 +1,31 @@ import Foundation +/// Reserves cancelled protocol IDs until their monotonic deadlines. +struct CancelledActivityIDs { + private var deadlines: [String: DispatchTime] = [:] + + /// Records a cancellation and returns the deadline for scheduled cleanup. + mutating func reserve(_ id: String, for duration: TimeInterval, now: DispatchTime = .now()) + -> DispatchTime + { + let deadline = now + duration + deadlines[id] = deadline + return deadline + } + + /// Checks the reservation without consuming it or extending its lifetime. + func contains(_ id: String, now: DispatchTime = .now()) -> Bool { + guard let deadline = deadlines[id] else { return false } + return now < deadline + } + + /// Removes only the reservation associated with this cleanup callback. + mutating func remove(_ id: String, deadline: DispatchTime) { + guard deadlines[id] == deadline else { return } + deadlines.removeValue(forKey: id) + } +} + /// Tracks activity ownership, per-activity expiration generations, and disconnect accounting. struct ActivityLifecycle { static let missingDescription = "No description provided" diff --git a/Sources/Nyathing/Configuration.swift b/Sources/Nyathing/Configuration.swift index dc597c5..d77c5e4 100644 --- a/Sources/Nyathing/Configuration.swift +++ b/Sources/Nyathing/Configuration.swift @@ -123,11 +123,6 @@ struct AppConfiguration { if legacyMaxWaitTime == nil { legacyMaxWaitTime = "180" } return nil } - if key == "activity_timeout_seconds" { - removedObsoleteSettings = true - legacyMaxWaitTime = line[line.index(after: equal)...].trimmingCharacters(in: .whitespaces) - return nil - } if key == "animate_icon" { removedObsoleteSettings = true return nil diff --git a/Sources/Nyathing/LocalAPIServer.swift b/Sources/Nyathing/LocalAPIServer.swift index 5d23cd4..f40af59 100644 --- a/Sources/Nyathing/LocalAPIServer.swift +++ b/Sources/Nyathing/LocalAPIServer.swift @@ -212,13 +212,13 @@ final class LocalAPIServer { let line = Data(pending[.. 1_048_576 { - _ = writeResponse(["ok": false, "error": "Request line is too large."], to: client) + _ = writeResponse(errorResponse(.requestTooLarge), to: client) return } } @@ -226,10 +226,10 @@ final class LocalAPIServer { private func handle(_ line: Data) -> [String: Any] { guard isRunning else { - return ["ok": false, "error": LocalAPIError.unavailable.localizedDescription] + return errorResponse(.unavailable) } do { - guard let request = try JSONSerialization.jsonObject(with: line) as? [String: Any], + guard let request = (try? JSONSerialization.jsonObject(with: line)) as? [String: Any], let command = request["command"] as? String else { throw LocalAPIError.invalidRequest @@ -244,15 +244,16 @@ final class LocalAPIServer { } animation = value } else { - animation = try settings.defaultAnimation() + do { + animation = try settings.defaultAnimation() + } catch { + throw LocalAPIError.invalidDefaultAnimation(error.localizedDescription) + } } let requestedActivityID = request["activity_id"] as? String if request["activity_id"] != nil && (requestedActivityID?.isEmpty ?? true) { throw LocalAPIError.invalidRequest } - guard request["activity_timeout_seconds"] == nil else { - throw LocalAPIError.serverManagedActivityTimeout - } let keepaliveIntervalWasProvided = request["keepalive_interval_seconds"] != nil let keepaliveInterval: TimeInterval if let rawKeepaliveInterval = request["keepalive_interval_seconds"] { @@ -282,11 +283,25 @@ final class LocalAPIServer { default: throw LocalAPIError.unknownCommand(command) } + } catch let error as LocalAPIError { + return errorResponse(error) + } catch CLIError.animationUnavailable(let filename, let reason) { + return errorResponse(.animationUnavailable("Animation '\(filename)' \(reason)")) + } catch let error as AnimationError { + return errorResponse(.animationUnavailable(error.localizedDescription)) } catch { - return ["ok": false, "error": error.localizedDescription] + return errorResponse(.internalError) } } + private func errorResponse(_ error: LocalAPIError) -> [String: Any] { + let error = error.protocolCode == nil ? .internalError : error + return [ + "ok": false, "error_code": error.protocolCode ?? "internal_error", + "error": error.localizedDescription, + ] + } + @discardableResult private func writeResponse(_ response: [String: Any], to fd: Int32) -> Bool { guard var data = try? JSONSerialization.data(withJSONObject: response) else { return false } @@ -349,27 +364,49 @@ enum LocalAPIError: LocalizedError { case unavailable case invalidRequest case invalidKeepaliveInterval - case serverManagedActivityTimeout case unknownCommand(String) case unknownActivity case animationCancelled + case requestTooLarge + case invalidDefaultAnimation(String) + case animationUnavailable(String) + case internalError case activityIDInUse(String) case socketPathTooLong case alreadyRunning(String) case unsafeSocketPath(String) + /// Stable wire identifier for request failures; transport setup errors have no code. + var protocolCode: String? { + switch self { + case .unavailable: return "server_unavailable" + case .invalidRequest: return "invalid_request" + case .invalidKeepaliveInterval: return "invalid_keepalive_interval" + case .unknownCommand: return "unknown_command" + case .unknownActivity: return "unknown_activity" + case .animationCancelled: return "animation_cancelled" + case .activityIDInUse: return "activity_id_in_use" + case .requestTooLarge: return "request_too_large" + case .invalidDefaultAnimation: return "invalid_default_animation" + case .animationUnavailable: return "animation_unavailable" + case .internalError: return "internal_error" + case .socketPathTooLong, .alreadyRunning, .unsafeSocketPath: return nil + } + } + var errorDescription: String? { switch self { case .unavailable: return "The local API is unavailable." case .invalidRequest: return "Invalid JSON Lines request." case .invalidKeepaliveInterval: return "'keepalive_interval_seconds' must be a positive finite number of seconds." - case .serverManagedActivityTimeout: - return - "'activity_timeout_seconds' is controlled by the server and cannot be set per activity." case .unknownCommand(let command): return "Unknown command: \(command)." case .unknownActivity: return "Unknown activity ID." case .animationCancelled: return "Animation was cancelled." + case .requestTooLarge: return "Request line is too large." + case .invalidDefaultAnimation(let reason): return "Cannot use the default animation: \(reason)" + case .animationUnavailable(let reason): return "Cannot load the animation: \(reason)" + case .internalError: return "An internal server error occurred." case .activityIDInUse(let id): return "Activity ID \"\(id)\" is already in use." case .socketPathTooLong: return "The local API socket path is too long." case .alreadyRunning(let path): return "Another Nyathing instance is listening at \(path)." diff --git a/Sources/Nyathing/main.swift b/Sources/Nyathing/main.swift index 39ed972..64c48da 100644 --- a/Sources/Nyathing/main.swift +++ b/Sources/Nyathing/main.swift @@ -92,7 +92,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { private var errorsStackView: NSStackView? private var activeActivitiesWindow: NSWindow? private var activeActivitiesStackView: NSStackView? - private var cancelledActivityIDs: Set = [] + private var cancelledActivityIDs = CancelledActivityIDs() private var configurationWindow: NSWindow? private var maxWaitTimeField: NSTextField? private var autoStartCheckbox: NSButton? @@ -335,8 +335,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { guard let id = UUID(uuidString: sender.identifier?.rawValue ?? ""), let animation = lifecycle.animation(for: id) else { return } - for (externalID, mappedID) in externalActivityIDs where mappedID == id { - cancelledActivityIDs.insert(externalID) + if let externalID = externalActivityIDs.first(where: { $0.value == id })?.key { + externalActivityIDs.removeValue(forKey: externalID) + let deadline = cancelledActivityIDs.reserve(externalID, for: maxWaitTime) + DispatchQueue.main.asyncAfter(deadline: deadline) { [weak self] in + self?.cancelledActivityIDs.remove(externalID, deadline: deadline) + } } _ = lifecycle.stop(id) activityStartOrder.removeValue(forKey: id) @@ -763,7 +767,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { [weak self] filename, description, requestedID, interval, intervalWasProvided, timeout in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } - if let requestedID, self.externalActivityIDs[requestedID] != nil { + if let requestedID, + self.externalActivityIDs[requestedID] != nil + || self.cancelledActivityIDs.contains(requestedID) + { throw LocalAPIError.activityIDInUse(requestedID) } let id = try self.startActivity( @@ -778,22 +785,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { onKeepalive: { [weak self] activityID in try DispatchQueue.main.sync { guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } - if self.cancelledActivityIDs.remove(activityID) != nil { - self.externalActivityIDs.removeValue(forKey: activityID) - throw LocalAPIError.animationCancelled - } - guard let id = self.externalActivityIDs[activityID], self.keepaliveActivity(id) else { + let id = try self.activeActivityID(for: activityID) + guard self.keepaliveActivity(id) else { throw LocalAPIError.unknownActivity } } }, onStop: { [weak self] activityID in try DispatchQueue.main.sync { - guard let self, self.apiGeneration == generation, - let id = self.externalActivityIDs[activityID], self.lifecycle.animation(for: id) != nil - else { - throw LocalAPIError.unknownActivity - } + guard let self, self.apiGeneration == generation else { throw LocalAPIError.unavailable } + let id = try self.activeActivityID(for: activityID) self.stopActivity(id) self.externalActivityIDs.removeValue(forKey: activityID) } @@ -803,6 +804,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { apiServer = server } + private func activeActivityID(for externalID: String) throws -> UUID { + if cancelledActivityIDs.contains(externalID) { + throw LocalAPIError.animationCancelled + } + guard let id = externalActivityIDs[externalID], lifecycle.animation(for: id) != nil else { + throw LocalAPIError.unknownActivity + } + return id + } + /// Begins an activity for a named animation, sharing its status item with matching activities. @discardableResult func startActivity( diff --git a/Tests/NyathingTests/ConfigurationAndAPITests.swift b/Tests/NyathingTests/ConfigurationAndAPITests.swift index a8b080b..78c4a32 100644 --- a/Tests/NyathingTests/ConfigurationAndAPITests.swift +++ b/Tests/NyathingTests/ConfigurationAndAPITests.swift @@ -245,17 +245,16 @@ final class ConfigurationTests: XCTestCase { func testMigratesLegacyKeepaliveConfiguration() throws { let legacy = AppConfiguration.template.replacingOccurrences( of: "max_wait_time = 180", - with: "keepalive_interval_seconds = 7\nactivity_timeout_seconds = 24") + with: "keepalive_interval_seconds = 7") try writeConfiguration(legacy) let configuration = try AppConfiguration.load(in: temporaryDirectory) - XCTAssertEqual(configuration.maxWaitTime, 24) + XCTAssertEqual(configuration.maxWaitTime, 180) let saved = try String( contentsOf: temporaryDirectory.appendingPathComponent("config.toml"), encoding: .utf8) XCTAssertFalse(saved.contains("keepalive_interval_seconds")) - XCTAssertFalse(saved.contains("activity_timeout_seconds")) - XCTAssertTrue(saved.contains("max_wait_time = 24")) + XCTAssertTrue(saved.contains("max_wait_time = 180")) } func testRandomIsAcceptedAsDefaultAnimation() throws { @@ -410,6 +409,22 @@ final class ConfigurationTests: XCTestCase { } final class ActivityLifecycleTests: XCTestCase { + func testCancelledIDIsReservedUntilItsDeadlineWithoutConsumingIt() { + var cancelled = CancelledActivityIDs() + let start = DispatchTime(uptimeNanoseconds: 1_000_000_000) + let deadline = cancelled.reserve("test", for: 5, now: start) + XCTAssertEqual(deadline, start + .seconds(5)) + XCTAssertTrue(cancelled.contains("test", now: start + .seconds(1))) + XCTAssertTrue(cancelled.contains("test", now: start + .seconds(4))) + XCTAssertFalse(cancelled.contains("test", now: deadline)) + + let replacement = cancelled.reserve("test", for: 2, now: deadline) + cancelled.remove("test", deadline: deadline) + XCTAssertTrue(cancelled.contains("test", now: deadline)) + cancelled.remove("test", deadline: replacement) + XCTAssertFalse(cancelled.contains("test", now: deadline)) + } + func testAggregatesActivitiesAndDistinguishesExplicitStopFromTimeout() throws { var lifecycle = ActivityLifecycle() let first = lifecycle.start(animation: "same_36x36.png", deadline: 10) @@ -525,12 +540,61 @@ final class LocalAPIServerTests: XCTestCase { try client.command(["command": "start", "animation": "nyathing"])["ok"] as? Bool, true) let invalid = try client.command(["command": "start", "animation": "not-installed"]) XCTAssertEqual(invalid["ok"] as? Bool, false) + XCTAssertEqual(invalid["error_code"] as? String, "animation_unavailable") XCTAssertTrue((invalid["error"] as? String)?.contains("not-installed") == true) let omitted = try client.command(["command": "start"]) XCTAssertEqual(omitted["ok"] as? Bool, false) + XCTAssertEqual(omitted["error_code"] as? String, "invalid_default_animation") XCTAssertTrue((omitted["error"] as? String)?.contains("default_animation") == true) } + func testRequestFailuresIncludeStableCodesAndReadableMessages() throws { + let directory = URL( + fileURLWithPath: "/tmp/nyathing-\(UUID().uuidString.prefix(8))", isDirectory: true) + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + defer { try? FileManager.default.removeItem(at: directory) } + let socketPath = directory.appendingPathComponent("api.sock").path + let server = LocalAPIServer( + socketPath: socketPath, defaultAnimation: { "nyathing" }, + onStart: { _, _, _, _, _, _ in throw LocalAPIError.activityIDInUse("test") }, + onKeepalive: { _ in throw LocalAPIError.animationCancelled }, + onStop: { id in + if id == "test" { throw LocalAPIError.animationCancelled } + throw LocalAPIError.unknownActivity + }) + try server.start() + defer { server.stop() } + + let client = try UnixJSONClient(path: socketPath) + let malformed = try client.commandLine(Data("{".utf8)) + XCTAssertEqual(malformed["ok"] as? Bool, false) + XCTAssertEqual(malformed["error_code"] as? String, "invalid_request") + XCTAssertEqual(malformed["error"] as? String, "Invalid JSON Lines request.") + + let cases: [([String: Any], String, String)] = [ + (["command": "bogus"], "unknown_command", "Unknown command: bogus."), + ( + ["command": "start", "activity_id": "test"], "activity_id_in_use", + "Activity ID \"test\" is already in use." + ), + ( + ["command": "keepalive", "activity_id": "test"], "animation_cancelled", + "Animation was cancelled." + ), + ( + ["command": "stop", "activity_id": "test"], "animation_cancelled", + "Animation was cancelled." + ), + (["command": "stop", "activity_id": "missing"], "unknown_activity", "Unknown activity ID."), + ] + for (request, code, message) in cases { + let response = try client.command(request) + XCTAssertEqual(response["ok"] as? Bool, false) + XCTAssertEqual(response["error_code"] as? String, code) + XCTAssertEqual(response["error"] as? String, message) + } + } + func testMultipleCommandsOnConnectionAndConcurrentClients() throws { let directory = URL( fileURLWithPath: "/tmp/nyathing-\(UUID().uuidString.prefix(8))", isDirectory: true) @@ -585,12 +649,6 @@ final class LocalAPIServerTests: XCTestCase { ]) XCTAssertEqual(largeInterval["activity_id"] as? String, "activity-2") XCTAssertEqual(startedTimeouts[1], 30) - let clientTimeoutOverride = try first.command([ - "command": "start", "keepalive_interval_seconds": 5, "activity_timeout_seconds": 10, - ]) - XCTAssertEqual(clientTimeoutOverride["ok"] as? Bool, false) - XCTAssertTrue( - (clientTimeoutOverride["error"] as? String)?.contains("controlled by the server") == true) let firstStart = try first.command([ "command": "start", "activity_id": "turn-123", "animation": "same_36x36.png", "description": "first client", "keepalive_interval_seconds": 8, @@ -695,7 +753,11 @@ private final class UnixJSONClient { deinit { Darwin.close(descriptor) } func command(_ request: [String: Any]) throws -> [String: Any] { - var data = try JSONSerialization.data(withJSONObject: request) + try commandLine(JSONSerialization.data(withJSONObject: request)) + } + + func commandLine(_ line: Data) throws -> [String: Any] { + var data = line data.append(0x0A) let written = data.withUnsafeBytes { Darwin.write(descriptor, $0.baseAddress!, $0.count) } guard written == data.count else { throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno)) }

Project page: https://github.com/dokwork/nyathing