From 9859ad31763d87ddd934fbde2a47d3ef86ebb165 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 7 Jan 2026 20:39:03 +0000 Subject: [PATCH] style(macos): swiftformat + swiftlint cleanup --- .../Clawdbot/GatewayAgentChannel.swift | 7 +++---- .../Clawdbot/GatewayDiscoveryModel.swift | 19 +++++++++++++++---- .../Clawdbot/GatewayLaunchAgentManager.swift | 6 +++++- apps/macos/Sources/Clawdbot/Launchctl.swift | 1 - .../Clawdbot/MenuSessionsInjector.swift | 2 +- .../Clawdbot/MenuUsageHeaderView.swift | 1 - .../Sources/Clawdbot/RemotePortTunnel.swift | 4 ++-- apps/macos/Sources/Clawdbot/UsageData.swift | 5 ++--- .../Sources/Clawdbot/UsageMenuLabelView.swift | 5 ++--- 9 files changed, 30 insertions(+), 20 deletions(-) diff --git a/apps/macos/Sources/Clawdbot/GatewayAgentChannel.swift b/apps/macos/Sources/Clawdbot/GatewayAgentChannel.swift index da96723a1..69e70b2b6 100644 --- a/apps/macos/Sources/Clawdbot/GatewayAgentChannel.swift +++ b/apps/macos/Sources/Clawdbot/GatewayAgentChannel.swift @@ -16,12 +16,11 @@ enum GatewayAgentChannel: String, CaseIterable, Sendable { func shouldDeliver(_ isLast: Bool) -> Bool { switch self { case .webchat: - return false + false case .last: - return isLast + isLast case .whatsapp, .telegram: - return true + true } } } - diff --git a/apps/macos/Sources/Clawdbot/GatewayDiscoveryModel.swift b/apps/macos/Sources/Clawdbot/GatewayDiscoveryModel.swift index 5770670d1..384f9ca4f 100644 --- a/apps/macos/Sources/Clawdbot/GatewayDiscoveryModel.swift +++ b/apps/macos/Sources/Clawdbot/GatewayDiscoveryModel.swift @@ -208,9 +208,15 @@ final class GatewayDiscoveryModel { return merged } - static func parseGatewayTXT(_ txt: [String: String]) - -> (lanHost: String?, tailnetDns: String?, sshPort: Int, gatewayPort: Int?, cliPath: String?) - { + struct GatewayTXT: Equatable { + var lanHost: String? + var tailnetDns: String? + var sshPort: Int + var gatewayPort: Int? + var cliPath: String? + } + + static func parseGatewayTXT(_ txt: [String: String]) -> GatewayTXT { var lanHost: String? var tailnetDns: String? var sshPort = 22 @@ -242,7 +248,12 @@ final class GatewayDiscoveryModel { cliPath = trimmed.isEmpty ? nil : trimmed } - return (lanHost, tailnetDns, sshPort, gatewayPort, cliPath) + return GatewayTXT( + lanHost: lanHost, + tailnetDns: tailnetDns, + sshPort: sshPort, + gatewayPort: gatewayPort, + cliPath: cliPath) } static func buildSSHTarget(user: String, host: String, port: Int) -> String { diff --git a/apps/macos/Sources/Clawdbot/GatewayLaunchAgentManager.swift b/apps/macos/Sources/Clawdbot/GatewayLaunchAgentManager.swift index f97ae9fd9..a4b718f35 100644 --- a/apps/macos/Sources/Clawdbot/GatewayLaunchAgentManager.swift +++ b/apps/macos/Sources/Clawdbot/GatewayLaunchAgentManager.swift @@ -62,7 +62,11 @@ enum GatewayLaunchAgentManager { let desiredBind = self.preferredGatewayBind() ?? "loopback" let desiredToken = self.preferredGatewayToken() let desiredPassword = self.preferredGatewayPassword() - let desiredConfig = DesiredConfig(port: port, bind: desiredBind, token: desiredToken, password: desiredPassword) + let desiredConfig = DesiredConfig( + port: port, + bind: desiredBind, + token: desiredToken, + password: desiredPassword) // If launchd already loaded the job (common on login), avoid `bootout` unless we must // change the config. `bootout` can kill a just-started gateway and cause attach loops. diff --git a/apps/macos/Sources/Clawdbot/Launchctl.swift b/apps/macos/Sources/Clawdbot/Launchctl.swift index 9a0cee654..ba52bb96b 100644 --- a/apps/macos/Sources/Clawdbot/Launchctl.swift +++ b/apps/macos/Sources/Clawdbot/Launchctl.swift @@ -79,4 +79,3 @@ enum LaunchAgentPlist { return token.isEmpty ? nil : token } } - diff --git a/apps/macos/Sources/Clawdbot/MenuSessionsInjector.swift b/apps/macos/Sources/Clawdbot/MenuSessionsInjector.swift index 286f460f7..8c2e01656 100644 --- a/apps/macos/Sources/Clawdbot/MenuSessionsInjector.swift +++ b/apps/macos/Sources/Clawdbot/MenuSessionsInjector.swift @@ -267,7 +267,7 @@ final class MenuSessionsInjector: NSObject, NSMenuDelegate { let rows = self.usageRows let errorText = self.cachedUsageErrorText - if rows.isEmpty && errorText == nil { + if rows.isEmpty, errorText == nil { return cursor } diff --git a/apps/macos/Sources/Clawdbot/MenuUsageHeaderView.swift b/apps/macos/Sources/Clawdbot/MenuUsageHeaderView.swift index 199b01cf1..73152143d 100644 --- a/apps/macos/Sources/Clawdbot/MenuUsageHeaderView.swift +++ b/apps/macos/Sources/Clawdbot/MenuUsageHeaderView.swift @@ -42,4 +42,3 @@ struct MenuUsageHeaderView: View { return "\(self.count) providers" } } - diff --git a/apps/macos/Sources/Clawdbot/RemotePortTunnel.swift b/apps/macos/Sources/Clawdbot/RemotePortTunnel.swift index cf0818b28..34e952540 100644 --- a/apps/macos/Sources/Clawdbot/RemotePortTunnel.swift +++ b/apps/macos/Sources/Clawdbot/RemotePortTunnel.swift @@ -41,8 +41,8 @@ final class RemotePortTunnel { static func create( remotePort: Int, preferredLocalPort: UInt16? = nil, - allowRemoteUrlOverride: Bool = true - ) async throws -> RemotePortTunnel { + allowRemoteUrlOverride: Bool = true) async throws -> RemotePortTunnel + { let settings = CommandResolver.connectionSettings() guard settings.mode == .remote, let parsed = CommandResolver.parseSSHTarget(settings.target) else { throw NSError( diff --git a/apps/macos/Sources/Clawdbot/UsageData.swift b/apps/macos/Sources/Clawdbot/UsageData.swift index 0db492938..2318d98e8 100644 --- a/apps/macos/Sources/Clawdbot/UsageData.swift +++ b/apps/macos/Sources/Clawdbot/UsageData.swift @@ -29,8 +29,8 @@ struct UsageRow: Identifiable { let error: String? var titleText: String { - if let plan, !plan.isEmpty { return "\(displayName) (\(plan))" } - return displayName + if let plan, !plan.isEmpty { return "\(self.displayName) (\(plan))" } + return self.displayName } var remainingPercent: Int? { @@ -107,4 +107,3 @@ enum UsageLoader { return try JSONDecoder().decode(GatewayUsageSummary.self, from: data) } } - diff --git a/apps/macos/Sources/Clawdbot/UsageMenuLabelView.swift b/apps/macos/Sources/Clawdbot/UsageMenuLabelView.swift index c5514a53d..4b1193e2f 100644 --- a/apps/macos/Sources/Clawdbot/UsageMenuLabelView.swift +++ b/apps/macos/Sources/Clawdbot/UsageMenuLabelView.swift @@ -21,7 +21,7 @@ struct UsageMenuLabelView: View { } HStack(alignment: .firstTextBaseline, spacing: 6) { - Text(row.titleText) + Text(self.row.titleText) .font(.caption.weight(.semibold)) .foregroundStyle(self.primaryTextColor) .lineLimit(1) @@ -30,7 +30,7 @@ struct UsageMenuLabelView: View { Spacer(minLength: 4) - Text(row.detailText()) + Text(self.row.detailText()) .font(.caption.monospacedDigit()) .foregroundStyle(self.secondaryTextColor) .lineLimit(1) @@ -43,4 +43,3 @@ struct UsageMenuLabelView: View { .padding(.trailing, self.paddingTrailing) } } -