fix(computer): close helper session review gaps (#11428)

* fix(computer): close helper session review gaps

* perf(computer): stop released session registration retries
This commit is contained in:
Neil
2026-07-29 16:38:11 -07:00
committed by GitHub
parent 24a2accc3c
commit 4f536ed601
3 changed files with 54 additions and 21 deletions
@@ -1,19 +1,35 @@
public enum AgentSessionRegistration: Sendable, Equatable {
case rejected
case sessionReleased
case joined
case claimed
}
public struct AgentSessionOwnership: Sendable {
private var authenticatedConnections: Set<Int32> = []
private var wasClaimed = false
private var wasReleased = false
public init() {}
public mutating func registerConnection(_ connection: Int32, authenticated: Bool) -> Bool {
guard authenticated else { return false }
public mutating func registerConnection(
_ connection: Int32,
authenticated: Bool
) -> AgentSessionRegistration {
guard authenticated else { return .rejected }
guard !wasReleased else { return .sessionReleased }
let inserted = authenticatedConnections.insert(connection).inserted
guard inserted, !wasClaimed else { return false }
guard inserted, !wasClaimed else { return .joined }
wasClaimed = true
return true
return .claimed
}
public mutating func disconnect(_ connection: Int32) -> Bool {
guard authenticatedConnections.remove(connection) != nil else { return false }
return wasClaimed && authenticatedConnections.isEmpty
let released = wasClaimed && authenticatedConnections.isEmpty
if released {
wasReleased = true
}
return released
}
}