Repository navigation
fix(desktop): recover dead mic on buffered PTT silent turns (#9081) - #9390
Merged
Merged
Conversation
The two buffered push-to-talk silent-turn exits — commitBufferedRealtimeHubTurn
(source "buffered_hub") and transcribeBufferedWarmWaitAudio ("warm_wait_fallback"),
both hit when the realtime hub is still warming at release — discarded near-silent
turns without ever feeding silentMicRecoveryPolicy.recordDiscardedTurn or requesting
a CoreAudio capture rebuild. The primary hub/omni/batch gates already do this. A
user whose hold-mode turns landed on the warm-wait path could accumulate silent
turns forever with recovery_action=none / recovery_result=not_attempted — exactly
the telemetry in #9081 (169 users, 0.12.0, hold mode).
Fix: wire both buffered paths into the same dead-mic recovery the primary paths use
— count each discard toward the threshold, attempt a capture rebuild once tripped,
and emit the real recovery_action/recovery_result. Also reset the counter on the
buffered success paths so a recovered mic clears accumulated dead turns.
Regression test (source-scrape, matching PTTAudioCaptureRaceTests since the manager
is a @mainactor singleton): every recordPTTSilentTurn site must wire recovery.
Verification: xcrun swift build -c debug succeeded (Build complete!, 177s).
UNVERIFIED at runtime: could not reproduce a physical dead-mic + hub-warm-wait turn.
kodjima33
force-pushed
the
watchdog/issue-9081-ptt-silent-turn-recovery
branch
from
July 13, 2026 05:21
789cfaa to
c415bf1
Compare
…e-inspection ratchet check_desktop_test_quality.py (added on main since this branch opened) rejects new production-source-reading tests unless they carry a reasoned static-contract escape. This test is exactly that: a static wiring tripwire over a @mainactor singleton with no behavioral seam.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug (#9081)
Desktop telemetry showed
ptt_audio_capture_silent_turnwithrecovery_action=none/recovery_result=not_attemptedfor 169 users on 0.12.0 in hold mode — push-to-talk turns recorded silence and nothing was done to recover the mic.Root cause
There are four silent-turn discard sites in
PushToTalkManager. The two primary gates (finalize()hub path and the omni/batch path) already runsilentMicRecoveryPolicy.recordDiscardedTurn(...)and, once consecutive dead-mic turns cross the threshold, callrequestCoreAudioCaptureRecovery(...)to rebuild CoreAudio capture.The two buffered exits did not:
commitBufferedRealtimeHubTurn()—source: "buffered_hub"transcribeBufferedWarmWaitAudio()—source: "warm_wait_fallback"Both are taken when the user releases before the realtime hub has finished warming — the common hold-mode path. They discarded near-silent turns and passed no recovery args, so
recordPTTSilentTurnfell back to itsrecoveryAction: "none"default and the dead-mic counter never advanced. A user stuck on this path could never trip recovery.Fix
Wire both buffered paths into the exact same dead-mic recovery the primary paths use:
recordDiscardedTurn,recovery_action/recovery_result,Surgical, mirrors the existing sibling pattern.
additions+deletions = 80across 1 source file + 1 test + 1 changelog.Test
PTTSilentTurnRecoveryWiringTests— sincePushToTalkManageris a@MainActorsingleton not constructible in a unit test, this follows the repo's existing source-scrape pattern (PTTAudioCaptureRaceTests): asserts everyrecordPTTSilentTurnsite wires recovery, so a future unwired site fails CI.Product invariants affected
INV-VOICE-1 — no behavior change to the invariant.
VoiceTurnCoordinatorremains the sole voice-turn lifecycle owner: this PR adds no parallel lifecycle enum, current-turn boolean, or completion timer.PTTSilentMicRecoveryPolicyis a pre-existing dead-mic counter already driven by the primary hub/omni/batch paths; the two buffered paths now feed the same counter. Turn terminalization still goes through the existingvoiceTurnCoordinator.send(.finish(...))/cancelTurncalls, unchanged, and no turn is declared successful earlier than before.requestCoreAudioCaptureRecoveryacts on the microphone as a physical driver, which is the layer INV-VOICE-1 assigns it to.INV-CHAT-1 — no behavior change to the invariant. This PR touches
PushToTalkManager.swift(a guarded path) but only wires the existing dead-mic recovery policy into two buffered silent-turn exits. It introduces no new transcript/session store, no per-surface continuity ring, and no change to turn identity or journal ownership: discarded turns were already discarded, they are now merely counted toward the existing recovery threshold and reported with a truthfulrecovery_action/recovery_result.Verification
main(3e55052acc);PushToTalkManager.swiftmoved a lot since this branch opened, so the fix was re-validated against it.xcrun swift build -c debug --package-path Desktop→ Build complete! (132s) post-rebase.recordPTTSilentTurnsites and all 4 now wirerecordDiscardedTurn/recoveryResult/requestCoreAudioCaptureRecovery(4/4/4/4), so the wiring test's invariant holds against the new code.Desktop Swift Build & Tests+ the source-scrape wiring test.🤖 automated by hourly watchdog.