refactor(ios): dedupe status, gateway, and service flows

This commit is contained in:
Peter Steinberger
2026-03-02 11:32:00 +00:00
parent 2ca5722221
commit cd011897d0
19 changed files with 334 additions and 626 deletions

View File

@@ -1,5 +1,6 @@
import Foundation
import Network
import OpenClawKit
import os
extension NodeAppModel {
@@ -11,24 +12,12 @@ extension NodeAppModel {
guard let raw = await self.gatewaySession.currentCanvasHostUrl() else { return nil }
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty, let base = URL(string: trimmed) else { return nil }
if let host = base.host, Self.isLoopbackHost(host) {
if let host = base.host, LoopbackHost.isLoopback(host) {
return nil
}
return base.appendingPathComponent("__openclaw__/a2ui/").absoluteString + "?platform=ios"
}
private static func isLoopbackHost(_ host: String) -> Bool {
let normalized = host.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
if normalized.isEmpty { return true }
if normalized == "localhost" || normalized == "::1" || normalized == "0.0.0.0" {
return true
}
if normalized == "127.0.0.1" || normalized.hasPrefix("127.") {
return true
}
return false
}
func showA2UIOnConnectIfNeeded() async {
guard let a2uiUrl = await self.resolveA2UIHostURL() else {
await MainActor.run {