diff --git a/apps/macos/Sources/OpenClaw/CanvasWindowController+Testing.swift b/apps/macos/Sources/OpenClaw/CanvasWindowController+Testing.swift index ae6551b861c..c2442d7e17b 100644 --- a/apps/macos/Sources/OpenClaw/CanvasWindowController+Testing.swift +++ b/apps/macos/Sources/OpenClaw/CanvasWindowController+Testing.swift @@ -25,11 +25,22 @@ extension CanvasWindowController { } static func _testParseIPv4(_ host: String) -> (UInt8, UInt8, UInt8, UInt8)? { - LoopbackHost.parseIPv4(host) + let parts = host.split(separator: ".", omittingEmptySubsequences: false) + guard parts.count == 4 else { return nil } + let bytes: [UInt8] = parts.compactMap { UInt8($0) } + guard bytes.count == 4 else { return nil } + return (bytes[0], bytes[1], bytes[2], bytes[3]) } static func _testIsLocalNetworkIPv4(_ ip: (UInt8, UInt8, UInt8, UInt8)) -> Bool { - LoopbackHost.isLocalNetworkIPv4(ip) + let (a, b, _, _) = ip + if a == 10 { return true } + if a == 172, (16...31).contains(Int(b)) { return true } + if a == 192, b == 168 { return true } + if a == 127 { return true } + if a == 169, b == 254 { return true } + if a == 100, (64...127).contains(Int(b)) { return true } + return false } static func _testIsLocalNetworkCanvasURL(_ url: URL) -> Bool { diff --git a/apps/macos/Sources/OpenClaw/PairingAlertSupport.swift b/apps/macos/Sources/OpenClaw/PairingAlertSupport.swift index 84f0da698e3..e806510c03a 100644 --- a/apps/macos/Sources/OpenClaw/PairingAlertSupport.swift +++ b/apps/macos/Sources/OpenClaw/PairingAlertSupport.swift @@ -134,7 +134,8 @@ enum PairingAlertSupport { messageText: String, informativeText: String, alertHostWindow: inout NSWindow?, - completion: @escaping (NSApplication.ModalResponse, NSWindow) -> Void) -> NSAlert { + completion: @escaping (NSApplication.ModalResponse, NSWindow) -> Void) -> NSAlert + { NSApp.activate(ignoringOtherApps: true) let alert = NSAlert() @@ -164,32 +165,6 @@ enum PairingAlertSupport { completion: completion) } - static func presentPairingAlert( - request: Request, - requestId: String, - messageText: String, - informativeText: String, - activeAlert: inout NSAlert?, - activeRequestId: inout String?, - alertHostWindow: inout NSWindow?, - clearActive: @escaping @MainActor (NSWindow) -> Void, - onResponse: @escaping @MainActor (NSApplication.ModalResponse, Request) async -> Void) - { - self.presentPairingAlert( - requestId: requestId, - messageText: messageText, - informativeText: informativeText, - activeAlert: &activeAlert, - activeRequestId: &activeRequestId, - alertHostWindow: &alertHostWindow) - { response, hostWindow in - Task { @MainActor in - clearActive(hostWindow) - await onResponse(response, request) - } - } - } - static func presentPairingAlert( request: Request, requestId: String, @@ -199,19 +174,18 @@ enum PairingAlertSupport { onResponse: @escaping @MainActor (NSApplication.ModalResponse, Request) async -> Void) { self.presentPairingAlert( - request: request, requestId: requestId, messageText: messageText, informativeText: informativeText, activeAlert: &state.activeAlert, activeRequestId: &state.activeRequestId, - alertHostWindow: &state.alertHostWindow) - { response, hostWindow in - Task { @MainActor in - self.clearActivePairingAlert(state: state, hostWindow: hostWindow) - await onResponse(response, request) - } - } + alertHostWindow: &state.alertHostWindow, + completion: { response, hostWindow in + Task { @MainActor in + self.clearActivePairingAlert(state: state, hostWindow: hostWindow) + await onResponse(response, request) + } + }) } static func clearActivePairingAlert( @@ -231,12 +205,12 @@ enum PairingAlertSupport { hostWindow: hostWindow) } - static func stopPairingPrompter( + static func stopPairingPrompter( isStopping: inout Bool, activeAlert: inout NSAlert?, activeRequestId: inout String?, task: inout Task?, - queue: inout [Request], + queue: inout [some Any], isPresenting: inout Bool, alertHostWindow: inout NSWindow?) { @@ -252,10 +226,10 @@ enum PairingAlertSupport { alertHostWindow = nil } - static func stopPairingPrompter( + static func stopPairingPrompter( isStopping: inout Bool, task: inout Task?, - queue: inout [Request], + queue: inout [some Any], isPresenting: inout Bool, state: PairingAlertState) { diff --git a/apps/macos/Sources/OpenClaw/PeekabooBridgeHostCoordinator.swift b/apps/macos/Sources/OpenClaw/PeekabooBridgeHostCoordinator.swift index 968931ca33f..07928e50943 100644 --- a/apps/macos/Sources/OpenClaw/PeekabooBridgeHostCoordinator.swift +++ b/apps/macos/Sources/OpenClaw/PeekabooBridgeHostCoordinator.swift @@ -36,6 +36,7 @@ final class PeekabooBridgeHostCoordinator { ?? fileManager.homeDirectoryForCurrentUser.appendingPathComponent("Library/Application Support") return Self.legacySocketDirectoryNames.map { Self.makeSocketPath(for: $0, in: base) } } + func setEnabled(_ enabled: Bool) async { if enabled { await self.startIfNeeded() @@ -85,7 +86,7 @@ final class PeekabooBridgeHostCoordinator { } private func ensureLegacySocketSymlinks() { - Self.legacySocketPaths.forEach { legacyPath in + for legacyPath in Self.legacySocketPaths { self.ensureLegacySocketSymlink(at: legacyPath) } } @@ -116,7 +117,9 @@ final class PeekabooBridgeHostCoordinator { } try fileManager.createSymbolicLink(atPath: legacyPath, withDestinationPath: Self.openclawSocketPath) } catch { - self.logger.debug("Failed to create legacy PeekabooBridge socket symlink: \(error.localizedDescription, privacy: .public)") + let message = "Failed to create legacy PeekabooBridge socket symlink: \(error.localizedDescription)" + self.logger + .debug("\(message, privacy: .public)") } } diff --git a/apps/macos/Sources/OpenClawDiscovery/TailscaleNetwork.swift b/apps/macos/Sources/OpenClawDiscovery/TailscaleNetwork.swift index c1db2fdcf13..53bb738e642 100644 --- a/apps/macos/Sources/OpenClawDiscovery/TailscaleNetwork.swift +++ b/apps/macos/Sources/OpenClawDiscovery/TailscaleNetwork.swift @@ -13,8 +13,8 @@ public enum TailscaleNetwork { } public static func detectTailnetIPv4() -> String? { - for entry in NetworkInterfaceIPv4.addresses() { - if self.isTailnetIPv4(entry.ip) { return entry.ip } + for entry in NetworkInterfaceIPv4.addresses() where self.isTailnetIPv4(entry.ip) { + return entry.ip } return nil }