Repository navigation
fix(app): keep custom STT live when Omi listen socket fails - #23875
Conversation
CompositeTranscriptionSocket treated a secondary (Omi /v4/listen) connect failure, close or error as fatal for both sockets, so an Omi outage also disconnected the user's working custom/local STT engine and retried it in the reconnect loop (#15500, #20381). Port of the approved #20382 design: when keepPrimaryWhenSecondaryFails is on (live custom STT and on-device composite), a secondary failure enters a degraded state instead — the primary keeps transcribing, the secondary is retried with backoff, and audio/suggested transcripts never reach Omi while degraded. WAL frames are marked synced only when the socket delivers to Omi, so audio Omi never received stays durable for later sync.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e00cc1032
ℹ️ 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".
| if (name == 'Secondary' && keepPrimaryWhenSecondaryFails) { | ||
| _enterDegraded('closed:${closeCode ?? -1}'); | ||
| return; |
There was a problem hiding this comment.
Preserve application-level close-code handling
When the secondary closes with an application-level code, this unconditional return bypasses the existing handling in CaptureController._socketClosedBody: 4001 forces a rejected-token refresh, 4002 refreshes the out-of-credits state, and 4005 expires a deleted-account session. Treating these as ordinary transport outages leaves those actions unexecuted and instead retries the secondary indefinitely; in particular, a server-rejected token that still appears valid locally is reused by getAuthHeader(). Preserve or explicitly dispatch these control-code actions rather than swallowing every secondary close.
Useful? React with 👍 / 👎.
| if (secondarySocket.status == PureSocketStatus.connected) { | ||
| CustomSttLogService.instance.info('Composite', 'Omi socket restored after $_secondaryRetryAttempts attempt(s)'); | ||
| DebugLogManager.logEvent('composite_secondary_restored', {'attempts': _secondaryRetryAttempts}); | ||
| _clearDegraded(); |
There was a problem hiding this comment.
Rebase transcript timestamps when restoring the secondary
When raw-audio forwarding is enabled and an audio frame reaches the restored secondary before the next transcript, the new backend session establishes first_audio_byte_timestamp from that frame (backend/routers/listen/receiver.py, _mark_first_audio). However, the primary remains connected and continues emitting timestamps relative to its original session—for example, PurePollingSocket retains _audioOffsetSeconds. Clearing degraded state resumes forwarding those unchanged timestamps, and backend/routers/listen/transcripts.py adds them to the new backend origin, shifting subsequent transcripts into the future by the primary's pre-reconnect duration and misaligning them with the recording. Establish a timestamp mapping for each restored secondary session before resuming suggested-transcript forwarding.
Useful? React with 👍 / 👎.
Summary
/v4/listensecondary fails to connect, closes, or errors; retry the Omi socket with bounded exponential backoff.Root cause
The custom STT composite treated any Omi secondary failure as fatal and disconnected the still-working local provider. The #15500 support reply confirms this app-side failure mode.
Verification
/Users/dazheng/workspace/omi/bin/omi-heavy run -- nice -n 19 flutter test test/unit/composite_transcription_socket_test.dart(app unit suite, 27 passed)./Users/dazheng/workspace/omi/bin/omi-heavy run -- nice -n 19 scripts/pr-preflight --lane ci --pr-body-file /Volumes/Ephemeral/scratch/cs-androidstt/pr-body.md(26 checks passed).dart formaton the two updated Dart files (no changes);git diff --check(clean).Scope
language=ko&stt_service=parakeetquery is still sent by the app and generic close handling retries after 15 seconds; whether the backend route closes that tuple with 1011 remains backend-owned and is not changed here.Refs #15500
Luna review follow-up
Owns: #23875
UI-Evidence: none -- only service/socket and capture plumbing changed; no visible UI changed.
Failure-Class: none