Repository navigation
refactor(desktop): make PTT voice turns reducer-driven - #9370
Conversation
Centralize PTT lifecycle, deadlines, UI projection, and terminal ownership in a typed reducer/coordinator. Fence provider callbacks, persistence, seed refresh, and audible output with turn-scoped identities and leases. Verification:\n- 97 focused voice-turn tests passed\n- desktop agent logic harness passed (212 lifecycle tests)\n- clean arm64 release build passed\n- isolated omi-ptt-orchestrator PTT entry/cleanup exercised
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0455398a27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return | ||
| } | ||
|
|
||
| voiceTurnCoordinator.send(.transcriptionFinal(turnID: turnID, text: query)) |
There was a problem hiding this comment.
Finish non-hub PTT turns after chat completion
When the Omni/Deepgram path reaches this event, the reducer enters awaitingResponse and schedules the provider-response deadline, but the normal floating-chat path that sendQuery uses never emits providerTurnFinished (repo-wide, that event is only sent from RealtimeHubController). For any non-hub PTT turn—such as hub warm fallback, hub unavailable, or voice answers disabled—the user can still get a successful text/voice answer, then 20s later the turn times out as provider_no_response and shows the failure hint / records a false terminal.
Useful? React with 👍 / 👎.
| func release(_ lease: VoiceOutputLease) -> Bool { | ||
| guard activeLease == lease, turnID == lease.turnID else { return false } | ||
| activeLease = nil | ||
| providerOutputSuppressed = false |
There was a problem hiding this comment.
Keep deterministic ack suppression for the whole turn
If a .deterministicAgentAck lease drains before the provider's post-tool audio/text arrives (for example the spawn_agent path speaks the local kickoff and then returns the tool result), releasing the lease clears providerOutputSuppressed. The hub gates provider audio/text on this flag, so late provider output in the same turn is no longer suppressed and can speak a second acknowledgement after the deterministic one; this suppression should last until endTurn/the next turn rather than until playback release.
Useful? React with 👍 / 👎.
Address independent review findings across cancel rewarm handoff, late transcript continuity, canonical stale-safe agent delegation, presenter ownership, diagnostic privacy, fallback telemetry, and realtime identity cleanup. Verification: OMI_SWIFT_TEST_SUITE_WORKERS=4 ./scripts/swift-test-suites.sh (184 suites passed); desktop launcher test discovery passed; desktop-core-harness --self-check passed; strict e2e flow coverage passed; named-bundle ptt-lifecycle flow passed; focused PushToTalkStateMachineTests passed.
Summary
VoiceTurnReducer/VoiceTurnCoordinatorfor PTT phase, route, deadlines, terminal reasons, presentation, diagnostics, and exact-once cleanup.VoiceOutputCoordinator, including realtime PCM, selected-voice fallback, deterministic agent acknowledgement, filler, and system-voice fallback.Why this closes #9264
The issue's underlying failure mode—multiple components independently owning one turn, output lane, and UI phase—is removed. The reducer/coordinator is now the semantic owner; capture, realtime providers, playback, and presentation code are adapters around it.
The hot PCM buffer remains bounded sidecar storage in
PushToTalkManager, andRealtimeHubControllerremains a compatibility facade. Its route booleans are derived projections rather than an independent state machine. This centralizes lifecycle ownership without putting audio chunks through the main-actor reducer or combining an unrelated mechanical class split with the behavioral refactor.Independent review hardening
A separate subagent reviewed the implementation before push. Its findings were addressed with:
Verification
OMI_SWIFT_TEST_SUITE_WORKERS=4 ./scripts/swift-test-suites.sh— all 184 isolated Swift suites passed../scripts/desktop-core-harness.sh --self-check— 28 flows and 65 actions validated.omi-ptt-orchestrator, flowptt-lifecycle— 5/5 steps passed in 218.75 ms, exercising actualptt_start/ptt_stopactions through recording toterminal_too_short, with zero stale or invalid-transition anomalies.git diff --checkvalidations passed.The named bundle was intentionally hermetic and signed out, so this run did not send live audio to an external provider. It did exercise the real PTT lifecycle, coordinator projections, terminal cleanup, and diagnostic assertions without requiring microphone permission or network state.
Closes #9264
Related: #9342 tracks a distinct agent-bridge startup failure. This PR improves the shared robustness patterns but does not claim to fix or close that separate issue.
Product invariants affected
INV-CHAT-1— preserves one kernel-owned transcript across typed, floating-bar, PTT/realtime, and pill surfaces. This refactor changes PTT lifecycle ownership only; it introduces no transcript/session store or per-surface history.