feat(keyboard): unify assistant voice and AI workflows

Merge dictation and AI controls into one assistant surface, preserve safe insertion and clipboard actions, and align settings and tests with the new flow.
This commit is contained in:
Rocky
2026-08-16 12:07:06 +08:00
parent 46f6d818b8
commit fb97ec2937
45 changed files with 1969 additions and 2143 deletions
+22 -3
View File
@@ -22,6 +22,14 @@ enum AppPermissions {
case restricted
}
enum PasteAccessResult: Equatable {
case verified
case noTextAvailable
case unavailable
}
private static let pasteAccessVerifiedKey = "clipboard.pasteAccessVerified.v1"
static var micStatus: MicStatus {
switch AVAudioApplication.shared.recordPermission {
case .granted: return .granted
@@ -46,6 +54,12 @@ enum AppPermissions {
micStatus == .granted && speechStatus == .granted
}
/// iOS does not expose the current "Paste from Other Apps" setting.
/// This records the last explicit, successful user-initiated read instead.
static var hasVerifiedPasteAccess: Bool {
UserDefaults.standard.bool(forKey: pasteAccessVerifiedKey)
}
/// Show guided permission pages when any Flow permission is not granted.
static var needsPermissionGuidance: Bool {
micStatus != .granted || speechStatus != .granted
@@ -82,10 +96,15 @@ enum AppPermissions {
/// and create the app's "Paste from Other Apps" settings entry.
@MainActor
@discardableResult
static func requestPasteAccess() -> Bool {
static func requestPasteAccess() -> PasteAccessResult {
let pasteboard = UIPasteboard.general
guard pasteboard.hasStrings else { return false }
return pasteboard.string != nil
guard pasteboard.hasStrings else { return .noTextAvailable }
guard pasteboard.string != nil else {
UserDefaults.standard.set(false, forKey: pasteAccessVerifiedKey)
return .unavailable
}
UserDefaults.standard.set(true, forKey: pasteAccessVerifiedKey)
return .verified
}
/// Home-screen guidance when Flow permissions are missing after onboarding.