mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-30 23:27:57 +00:00
- Pairing now allows direct entry/scan with inline progress and error feedback - PairingConfirmView is now deep-link-only for security confirmations - Session list rows: move thinking spinner and unread indicator to trailing edge - Extracted shared PairingAttempt state for reuse - Updated strings: "Continue" → "Pair" button label - Removed unused PendingPairing.source Claude-Session: https://claude.ai/code/session_01ViH4oaLSpTcksxDFEMQgeD
29 lines
900 B
Swift
29 lines
900 B
Swift
import HapiClient
|
|
import Observation
|
|
|
|
/// Inline pairing progress/error state shared by manual entry, QR scan,
|
|
/// and the deep-link confirm step.
|
|
@Observable @MainActor
|
|
final class PairingAttempt {
|
|
private(set) var isPairing = false
|
|
var failure: PairingFailure?
|
|
|
|
func pair(_ model: AppModel, hubUrl: String, accessToken: String) {
|
|
guard !isPairing else { return }
|
|
isPairing = true
|
|
failure = nil
|
|
Task {
|
|
do {
|
|
try await model.pair(hubUrl: hubUrl, accessToken: accessToken)
|
|
// Success: AppModel flips to .paired and tears down the
|
|
// presenting hierarchy; nothing to do here.
|
|
} catch let pairingFailure as PairingFailure {
|
|
failure = pairingFailure
|
|
} catch {
|
|
failure = .unreachable
|
|
}
|
|
isPairing = false
|
|
}
|
|
}
|
|
}
|