fix: keep voice wake permission callbacks on main actor
parent
f444604e7c
commit
09ed3f37db
|
|
@ -1025,15 +1025,52 @@ struct SessionsSettings: View {
|
||||||
.foregroundStyle(.secondary)
|
.foregroundStyle(.secondary)
|
||||||
.padding(.top, 6)
|
.padding(.top, 6)
|
||||||
} else {
|
} else {
|
||||||
ScrollView {
|
Table(rows) {
|
||||||
LazyVStack(spacing: 10) {
|
TableColumn("Key") { row in
|
||||||
ForEach(rows) { row in
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
SessionRowView(row: row)
|
Text(row.key)
|
||||||
|
.font(.body.weight(.semibold))
|
||||||
|
HStack(spacing: 6) {
|
||||||
|
SessionKindBadge(kind: row.kind)
|
||||||
|
if !row.flagLabels.isEmpty {
|
||||||
|
ForEach(row.flagLabels, id: \.self) { flag in
|
||||||
|
Badge(text: flag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.width(170)
|
||||||
|
|
||||||
|
TableColumn("Updated", value: \.ageText)
|
||||||
|
.width(80)
|
||||||
|
|
||||||
|
TableColumn("Tokens") { row in
|
||||||
|
Text(row.tokens.summary)
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
.width(210)
|
||||||
|
|
||||||
|
TableColumn("Model") { row in
|
||||||
|
Text(row.model ?? "—")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
.width(120)
|
||||||
|
|
||||||
|
TableColumn("Session ID") { row in
|
||||||
|
Text(row.sessionId ?? "—")
|
||||||
|
.font(.caption.monospaced())
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.lineLimit(1)
|
||||||
|
.truncationMode(.middle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tableStyle(.inset(alternatesRowBackgrounds: true))
|
||||||
|
.frame(maxHeight: .infinity, alignment: .top)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func refresh() async {
|
private func refresh() async {
|
||||||
|
|
@ -1149,6 +1186,20 @@ private struct SessionKindBadge: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct Badge: View {
|
||||||
|
let text: String
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Text(text)
|
||||||
|
.font(.caption2.weight(.semibold))
|
||||||
|
.padding(.horizontal, 6)
|
||||||
|
.padding(.vertical, 3)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.background(Color.secondary.opacity(0.12))
|
||||||
|
.clipShape(Capsule())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct SettingsRootView: View {
|
struct SettingsRootView: View {
|
||||||
@ObservedObject var state: AppState
|
@ObservedObject var state: AppState
|
||||||
@State private var permStatus: [Capability: Bool] = [:]
|
@State private var permStatus: [Capability: Bool] = [:]
|
||||||
|
|
@ -1344,9 +1395,11 @@ final class VoiceWakeTester {
|
||||||
if speechStatus == .notDetermined {
|
if speechStatus == .notDetermined {
|
||||||
let granted = await withCheckedContinuation { continuation in
|
let granted = await withCheckedContinuation { continuation in
|
||||||
SFSpeechRecognizer.requestAuthorization { status in
|
SFSpeechRecognizer.requestAuthorization { status in
|
||||||
|
Task { @MainActor in
|
||||||
continuation.resume(returning: status == .authorized)
|
continuation.resume(returning: status == .authorized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
guard granted else { return false }
|
guard granted else { return false }
|
||||||
} else if speechStatus != .authorized {
|
} else if speechStatus != .authorized {
|
||||||
return false
|
return false
|
||||||
|
|
@ -1356,7 +1409,11 @@ final class VoiceWakeTester {
|
||||||
switch micStatus {
|
switch micStatus {
|
||||||
case .authorized: return true
|
case .authorized: return true
|
||||||
case .notDetermined:
|
case .notDetermined:
|
||||||
return await AVCaptureDevice.requestAccess(for: .audio)
|
return await withCheckedContinuation { continuation in
|
||||||
|
AVCaptureDevice.requestAccess(for: .audio) { granted in
|
||||||
|
Task { @MainActor in continuation.resume(returning: granted) }
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue