native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
1.3 kB · 47 lines
Swift
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import ComposableArchitectureimport Foundationimport Observation
@MainActor@Observablefinal class RemoteMirrorStore { let host: MirrorHost private(set) var clients: [MirrorClient] = [] var selectedID: UUID? let knownHosts = MirrorKnownHostStore() @ObservationIgnored private let runtime: GhosttyRuntime
init(manager: WorktreeTerminalManager, runtime: GhosttyRuntime) { @Dependency(FeatureFlags.self) var flags host = MirrorHost( source: GhosttyMirrorPaneSource(manager: manager), enabled: flags.remoteMirror) self.runtime = runtime }
var selected: MirrorClient? { clients.first { $0.id == selectedID } }
func makeClient(address: String, port: UInt16, pairingKey: String) -> MirrorClient { let client = MirrorClient( configuration: .init(address: address, port: port, pairingKey: pairingKey), replica: MirrorReplica(runtime: runtime) ) return client }
func add(_ client: MirrorClient, pane: MirrorPaneDescriptor) { clients.append(client) selectedID = client.id client.subscribe(pane) }
func remove(_ client: MirrorClient) { client.close() clients.removeAll { $0.id == client.id } if selectedID == client.id { selectedID = nil } }
func stop() { host.stop() for client in clients { client.close() } }}