refactor(macos): centralize gateway endpoint resolution

This commit is contained in:
Peter Steinberger
2025-12-12 22:26:43 +00:00
parent 6354dddff2
commit 14e3b34a8e
5 changed files with 127 additions and 23 deletions
@@ -109,20 +109,6 @@ actor GatewayConnection {
}
private static func defaultConfigProvider() async throws -> Config {
let mode = await MainActor.run { AppStateStore.shared.connectionMode }
let token = ProcessInfo.processInfo.environment["CLAWDIS_GATEWAY_TOKEN"]
switch mode {
case .local:
let port = GatewayEnvironment.gatewayPort()
return (URL(string: "ws://127.0.0.1:\(port)")!, token)
case .remote:
if let forwarded = await RemoteTunnelManager.shared.controlTunnelPortIfRunning() {
return (URL(string: "ws://127.0.0.1:\(Int(forwarded))")!, token)
}
throw NSError(
domain: "RemoteTunnel",
code: 2,
userInfo: [NSLocalizedDescriptionKey: "Remote mode is enabled, but the control tunnel is not active"])
}
try await GatewayEndpointStore.shared.requireConfig()
}
}