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

View File

@@ -79,10 +79,9 @@ final class ControlChannel: ObservableObject {
case .local:
await self.configure()
case let .remote(target, identity):
// Create/ensure SSH tunnel, then talk to the forwarded local port.
_ = (target, identity)
do {
_ = try await RemoteTunnelManager.shared.ensureControlTunnel()
_ = (target, identity)
_ = try await GatewayEndpointStore.shared.ensureRemoteControlTunnel()
await self.configure()
} catch {
self.state = .degraded(error.localizedDescription)
@@ -215,8 +214,7 @@ final class ControlChannel: ObservableObject {
switch push {
case let .event(evt) where evt.event == "agent":
if let payload = evt.payload,
let payloadData = try? JSONEncoder().encode(payload),
let agent = try? JSONDecoder().decode(ControlAgentEvent.self, from: payloadData)
let agent = try? GatewayPayloadDecoding.decode(payload, as: ControlAgentEvent.self)
{
AgentEventStore.shared.append(agent)
self.routeWorkActivity(from: agent)