Repository navigation
fix(desktop): bind the hub route when the realtime transport goes ready - #9699
Merged
Merged
Conversation
dbd69e7 ("make realtime context admission fail closed") stopped the `hubReady` reducer case from binding `route = .hub(sessionID:)`, intending to keep transport readiness separate from context admission. But the route is what the PTT driver reads to decide it owns a hub turn — admission is fenced separately by `providerConnection` + `RealtimeInputAdmissionPolicy` inside RealtimeHubController. With the route stranded in `.hubWarmWait`, every PTT turn taken while the socket was still warming died silently: - `commitBufferedRealtimeHubTurn()` opens with `guard isHubMode` (route `.hub`), so the buffered warm-wait commit — the one function that exists to serve this path — returned immediately. - `hubCommitPending` therefore stayed false, so when admission landed, `finishContextFreshInputOnCurrentSession()` replayed the audio and called `beginInputTurn` but never `commitInputTurn`. - `hubReady` had already cancelled the `.hubWarm` deadline and the successful reconnect cancelled `.providerReconnect`, so no deadline was armed: the turn sat in `finalizing` with the thinking spinner forever — no reply, no transcription fallback, no journal row. Only a new PTT press escaped it. Mid-hold mic audio in that window never reached the hub at all. Restore the binding and widen the `hubAdmissionRejected` guard to `routeMatchesHub`, since that event is sent from inside the `prepareHubInput` effect handler — i.e. after the route is applied — so the PR #9684 transcription fallback would otherwise go stale. The fail-closed property is unchanged: `feedAudio` still parks audio in `reconnectAudioBuffer`, and `commitTurn` still defers via `hubCommitDeferred` (which also arms the `deferredCommit` deadline) until the admission policy admits the input. Verification: - Added `testBufferedWarmWaitTurnStaysCommittableAfterTransportReady` and reworked `testTransportReadyBindsHubRouteAndPreparesContext`; both fail on the pre-fix reducer and pass after it (verified by stashing the source fix). - desktop/macos/scripts/agent-logic-harness.sh --swift-only → 379 tests, 0 failures.
9 tasks
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.
Product invariants affected
The bug
Every push-to-talk turn taken while the realtime socket was still warming up died silently: the thinking spinner stayed up forever, the user's speech was dropped, and no reply, transcription fallback, or journal row was ever produced. Only pressing PTT again escaped it.
Root cause
dbd69e71c5("make realtime context admission fail closed") removed theroute = .hub(sessionID:)binding from thehubReadyreducer case, to keep transport readiness distinct from context admission. But the route is precisely what the PTT driver reads to decide it owns a hub turn — admission is fenced separately, byproviderConnectionandRealtimeInputAdmissionPolicyinsideRealtimeHubController.With the route stranded in
.hubWarmWait:commitBufferedRealtimeHubTurn()opens withguard isHubMode(route.hub) — so the one function that exists to serve the buffered warm-wait path returned immediately.hubCommitPendingtherefore stayedfalse, so when admission landed,finishContextFreshInputOnCurrentSession()replayed the buffered audio and calledbeginInputTurnbut nevercommitInputTurn— the provider was never asked to respond.hubReadyhad already cancelled the.hubWarmdeadline, and the successful reconnect cancelled.providerReconnect, so no deadline was armed. The turn sat infinalizingindefinitely.Mid-hold mic audio in that window never reached the hub at all: the tap only calls
feedAudiowhenisHubMode.Ironically it broke precisely when admission succeeded — a rejected admission at least terminated the turn via
providerReconnectFailed.The fix
Restore the route binding in
hubReady, and widen thehubAdmissionRejectedguard torouteMatchesHub. That event is sent from inside theprepareHubInputeffect handler — i.e. after the route has been applied — so the #9684 transcription fallback would otherwise go stale.The fail-closed property is preserved. The route is a driver-routing signal, not an admission grant. Audio still cannot reach the provider before the canonical context is bound:
feedAudioparks chunks inreconnectAudioBuffer, andcommitTurndefers throughhubCommitDeferred(which also arms thedeferredCommitdeadline, closing the no-deadline hang) untilRealtimeInputAdmissionPolicyadmits the input.Verification
testBufferedWarmWaitTurnStaysCommittableAfterTransportReadyand reworkedtestTransportReadyBindsHubRouteAndPreparesContext(it previously asserted the broken state). Both fail on the pre-fix reducer and pass after it — verified by stashing the source fix and re-running.desktop/macos/scripts/agent-logic-harness.sh --swift-only→ 379 tests, 0 failures.make preflight→ green.Not runtime-exercised in a live named bundle (UNVERIFIED on-device); the finding and fix are established by static trace plus the reducer/coordinator regression tests above.
Scope / risk
The regressing commit is on
mainand rode into thev0.12.73candidate, but that release is stillchannel: candidate— it has not been promoted to beta or stable, so no production user is affected yet. This lands the fix before it can ship.🤖 automated by hourly watchdog; opened for review, not merged (not live on prod → outside the auto-merge gate).