Files
hapi/ios/Hapi/Features/Pairing/PairingAttempt.swift
T
weishu bc9df82dc6 fix(ios): refine pairing and session list UX
- 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
2026-08-27 11:16:53 +08:00

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
}
}
}