feat(instances): beacon on connect and relay self-entry

This commit is contained in:
Peter Steinberger
2025-12-09 03:56:04 +01:00
parent 280c7c851f
commit 38c4f4f76c
4 changed files with 1798 additions and 1747 deletions

View File

@@ -1,5 +1,6 @@
import Foundation
import OSLog
import SwiftUI
struct ControlHeartbeatEvent: Codable {
let ts: Double
@@ -91,6 +92,7 @@ final class ControlChannel: ObservableObject {
self.state = .connecting
try await AgentRPC.shared.start()
self.state = .connected
PresenceReporter.shared.sendImmediate(reason: "connect")
} catch {
self.state = .degraded(error.localizedDescription)
}

View File

@@ -39,6 +39,11 @@ final class PresenceReporter {
}
}
/// Fire an immediate presence beacon (e.g., right after connecting).
func sendImmediate(reason: String = "connect") {
Task { await self.push(reason: reason) }
}
private static func composePresenceSummary(mode: String, reason: String) -> String {
let host = Host.current().localizedName ?? "unknown-host"
let ip = Self.primaryIPv4Address() ?? "ip-unknown"

File diff suppressed because it is too large Load Diff