Files
Ryan Vogel 2e7fc060ed iOS: let the keyboard dictate once Hex has the mic, even if it opened before the grant (#2071)
TestFlight (build 32, iOS 27.2.1): onboarding's practice field said the
microphone wasn't allowed after it had been, until Skip for now.

Cause (reproduced on an iOS 27.2 simulator): a keyboard process keeps the
microphone permission it read when it started. AVAudioApplication,
AVAudioSession and AVCaptureDevice all still read "undetermined" in it after
Hex is allowed the mic, so a Hex keyboard opened before the grant (tried in
another app first, then onboarding) hits KeyboardLocalDictation's guard and
shows "Allow the microphone in Hex first" on the Try the keyboard page. The
app and the try page had the right state; only the keyboard's own reading
was stale.

What changed
- KeyboardBridge.appMicrophoneAllowed (App Group key app.microphoneAllowed):
  the app's own reading, written by KeyboardSetupMonitor.refresh (every
  second on onboarding and home, on becoming active, and after the mic
  prompt), only when it changes.
- KeyboardLocalDictation.start accepts the mic when its own reading or the
  app's says granted; WebKit's capture still checks, and a NotAllowedError
  still shows the same message. The probe log notes app=granted|no.
- Nothing removed. Onboarding is unchanged: #2058's no Allow button before
  the prompt, and Continue after a decline, stay as they are.

#2058 made this easier to hit, not the cause: build 32 needed the mic for
Continue, so it took a keyboard opened earlier; now declining leads to the
try page with the keyboard open, and allowing it later in Settings left that
keyboard stale too.

Verified (anomastudio, iPhone 18 Pro Max simulator, iOS 27.2, fresh install,
mic reset, Full Access via TCC): Hex keyboard tried in Spotlight first, then
onboarding with the mic allowed at the system prompt. Before: same keyboard
pid, mic=undetermined, "Allow the microphone in Hex first" on the try page.
After: same pid, mic=undetermined app=granted, web capture started in the
practice field. xcodebuild test: 267 tests, 0 failures, 1 skipped.
Not verified: a physical iPhone (the simulator's WebKit captures without a
TCC check and has no speech assets), or a keyboard that started with the mic
denied and was allowed in Settings.
2026-11-20 16:59:42 +00:00
..