fix(tcc): explicit mic + camera permission requests in installVoice/installVision
Live test 2026-05-06 surfaced that the production app never actually triggered
the macOS mic or camera permission dialogs — the wizard's TCC stage was
explainer-only ("(later)") and the "first-use prompt" code that was supposed
to land later was never written. Result: AVAudioEngine opened cleanly, mic
input was silent, no wake-word ever fired, and CameraCapture.open() failed
.cameraDenied without ever asking.
Fix: explicit AVCaptureDevice.requestAccess(for:) calls at the first-use
boundary of each subsystem.
* App/AppDelegate.swift installVoice — checks mic auth status; on
.notDetermined awaits requestAccess(for: .audio) BEFORE
graphOwner.open(); on .denied/.restricted logs and returns dormant. Voice
loop only proceeds with confirmed mic grant.
* App/AppDelegate.swift installVision — same pattern for camera. Checks
status; .notDetermined → requestAccess(for: .video); .denied/.restricted
surfaces the existing degradationStream banner via cameraDegradationTask.
* App/Wizard/WizardStageTCCView.swift — wizard rows updated from
"Microphone (later)" / "Camera (later)" to "(auto-prompts shortly)" with
body text matching reality: prompts fire automatically after the wizard,
when the matching subsystem starts. The previous "later" copy implied
indefinite deferral when actually the prompts fire ~5s after wizard
completion.
Live verification:
- tccutil reset Microphone com.koftwentytwo.jarvis
- Launch → wizard appears → click through
- tccd log: "AUTHREQ_PROMPTING ... kTCCServiceMicrophone" — system
dialog displayed
- After click-Allow: AudioGraph: probed format sampleRate=48000 channels=4,
AudioGraphOwner: opened with variant <private>, WakeWordDAG: started
ring-feed loop, VoiceController: starting
Voice 87/87 pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb7ee6fbb8
commit
b92d062f8b
2 files changed
+57
-4
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import AppKit
|
||||
import AVFoundation
|
||||
import Bus
|
||||
import Config
|
||||
import DevOverlay
|
||||
@@ -806,6 +807,37 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// 2026-05-06 — TCC mic permission. macOS does not deterministically
|
||||
// surface the microphone prompt from AVAudioEngine alone; without an
|
||||
// explicit `AVCaptureDevice.requestAccess(for: .audio)` call the
|
||||
// app receives a silent input stream and the wizard's "request at
|
||||
// first use" contract is violated. This is the single point where
|
||||
// the voice loop first claims the mic, so it's the right place to
|
||||
// request. Failure to grant degrades voice to dormant — the rest of
|
||||
// the app keeps running.
|
||||
let micStatus = AVCaptureDevice.authorizationStatus(for: .audio)
|
||||
let micGranted: Bool
|
||||
switch micStatus {
|
||||
case .authorized:
|
||||
micGranted = true
|
||||
case .notDetermined:
|
||||
systemLogger?.info("installVoice: requesting mic permission (.notDetermined)")
|
||||
micGranted = await AVCaptureDevice.requestAccess(for: .audio)
|
||||
systemLogger?.info("installVoice: mic permission \(micGranted ? "granted" : "denied")")
|
||||
case .denied, .restricted:
|
||||
systemLogger?.warning("installVoice: mic permission \(String(describing: micStatus)) — voice loop dormant; user must grant in System Settings")
|
||||
micGranted = false
|
||||
@unknown default:
|
||||
micGranted = false
|
||||
}
|
||||
|
||||
guard micGranted else {
|
||||
audioGraphDegradationTask?.cancel()
|
||||
audioGraphRebuildTask?.cancel()
|
||||
self.audioGraphOwner = nil
|
||||
return
|
||||
}
|
||||
|
||||
// Open the graph. Failure here is non-fatal: voice degrades to
|
||||
// dormant + banner, the rest of the app keeps running. The owner
|
||||
// itself emits `.aecUnavailable` on its retry path, so we only need
|
||||
@@ -1571,6 +1603,27 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// 2026-05-06 — TCC camera permission. Mirrors the mic-permission
|
||||
// pattern in installVoice. Without an explicit
|
||||
// `AVCaptureDevice.requestAccess(for: .video)` call macOS does not
|
||||
// surface the camera prompt and `CameraCapture.open()` silently
|
||||
// fails as `.cameraDenied`. We request before `open()` so the
|
||||
// first-launch path either gets the prompt or we proceed
|
||||
// gracefully degraded.
|
||||
let camStatus = AVCaptureDevice.authorizationStatus(for: .video)
|
||||
switch camStatus {
|
||||
case .authorized:
|
||||
break
|
||||
case .notDetermined:
|
||||
systemLogger?.info("installVision: requesting camera permission (.notDetermined)")
|
||||
let granted = await AVCaptureDevice.requestAccess(for: .video)
|
||||
systemLogger?.info("installVision: camera permission \(granted ? "granted" : "denied")")
|
||||
case .denied, .restricted:
|
||||
systemLogger?.warning("installVision: camera permission \(String(describing: camStatus)) — vision features dormant")
|
||||
@unknown default:
|
||||
break
|
||||
}
|
||||
|
||||
// Try to open. Failure is non-fatal — banner already enqueued by
|
||||
// the degradation watcher above on .cameraDenied.
|
||||
do {
|
||||
|
||||
@@ -32,13 +32,13 @@ struct WizardStageTCCView: View {
|
||||
inputMonitoringRow
|
||||
|
||||
explainerRow(
|
||||
title: "Microphone (later)",
|
||||
body: "Will be requested when the voice loop is turned on. Jarvis will not listen until then.",
|
||||
title: "Microphone (auto-prompts shortly)",
|
||||
body: "Jarvis will request mic access automatically a moment after this wizard, when the voice loop starts. Wake-word + voice replies depend on it.",
|
||||
ctaLabel: "Learn more →"
|
||||
)
|
||||
explainerRow(
|
||||
title: "Camera (later)",
|
||||
body: "Will be requested when the vision features are turned on. Jarvis will not watch until then.",
|
||||
title: "Camera (auto-prompts shortly)",
|
||||
body: "Jarvis will request camera access automatically a moment after this wizard, when vision features start. Used for presence detection and the camera button.",
|
||||
ctaLabel: "Learn more →"
|
||||
)
|
||||
explainerRow(
|
||||
|
||||
Reference in new issue
Block a user