fix(computer): reap mac helper after client loss (#11425)

This commit is contained in:
Neil
2026-07-29 16:17:30 -07:00
committed by GitHub
parent 8f36cd9baf
commit 0349cb6bdb
3 changed files with 123 additions and 3 deletions
@@ -0,0 +1,19 @@
public struct AgentSessionOwnership: Sendable {
private var authenticatedConnections: Set<Int32> = []
private var wasClaimed = false
public init() {}
public mutating func registerConnection(_ connection: Int32, authenticated: Bool) -> Bool {
guard authenticated else { return false }
let inserted = authenticatedConnections.insert(connection).inserted
guard inserted, !wasClaimed else { return false }
wasClaimed = true
return true
}
public mutating func disconnect(_ connection: Int32) -> Bool {
guard authenticatedConnections.remove(connection) != nil else { return false }
return wasClaimed && authenticatedConnections.isEmpty
}
}