Repository navigation
fix(mobile): re-arm live STT retries and clear recovered audio banner - #22094
Conversation
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: b299f2bd5c
ℹ️ 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".
| final state = _devices[deviceId]; | ||
| final episode = state?.episode; | ||
| if (state == null || episode == null || !_isBleIngressTrigger(episode.trigger)) return; |
There was a problem hiding this comment.
Preserve recovery evidence while declaration is pending
When the third zero-byte session or rapid disconnect starts _maybeDeclare, the feature-gate await can remain pending while BLE audio recovers. Every packet reaching this branch is discarded because state.episode is still null (and a fresh native health lease is likewise only applied to an active episode); once the gate completes, the stale episode is declared and its retry can restore the warning even though ingress has already recovered. Track recovery evidence while declaration is pending or recheck evidence after the feature-gate await before creating the episode.
Useful? React with 👍 / 👎.
| _capture.stagedReadModel.phase != CapturePhase.pendantLive || | ||
| !_shouldReconnectTranscriptionSocket || | ||
| _transcriptServiceReady || | ||
| (_keepAliveTimer?.isActive ?? false)) { |
There was a problem hiding this comment.
Replace keepalive timers whose session token is stale
During an STT outage, a same-device updateRecordingDevice refresh rolls the capture session in _updateRecordingDeviceBody, but this active-timer check preserves the timer that captured the previous session token. On its next tick, _startKeepAliveServices detects that stale token and cancels the timer, and no later reconciliation is triggered, so transcription retries stop indefinitely after routine Home or speech-profile device refreshes. Reconciliation needs to verify that the active timer belongs to the current session or replace it when the session rolls.
Useful? React with 👍 / 👎.
| for (final session in _openSessions.values) { | ||
| if (session.deviceId == deviceId && session.bytesSinceTranscript == 0) session.watchdogDeclared = false; |
There was a problem hiding this comment.
Re-arm the socket watchdog after BLE ingress recovers
When a connected socket first raises connected_no_bytes, runConnectedWatchdog sets watchdogDeclared. If BLE then recovers while the socket is still open, each packet is forwarded after onBleIngressBytes, so bytesSinceTranscript is already positive by the time the five-second proof resolves the episode; this condition therefore leaves watchdogDeclared set. The watchdog subsequently skips that session forever, so a socket that accepts the recovered audio but produces no transcripts can never raise bytes_sent_no_transcript (or another ingress alarm) until it closes. Re-arm the watchdog on BLE-only resolution so the distinct transcription failure remains detectable.
Useful? React with 👍 / 👎.
Summary
Fix mobile live-transcription recovery after BLE capture returns during an STT outage, and clear the device-audio reconnect banner once BLE ingress has recovered.
On 2026-10-18, app 1.0.566+1410 recovered David's CV1 BLE stream, but a subsequent
stt_failed/ 1011 socket close was followed by 70+ minutes without another/v4/listensocket. Native capture health reported flowing audio while Home and the capturing page kept showing “Omi isn't sending audio”. The incident timeline is supplied evidence; this PR reproduces the failure conditions hermetically, without a physical-device run.Root causes and changes
deviceRecordmirror, which BLE startup sets after asynchronous setup. A failed socket setup or a close handled before that mirror is restored can leave no timer. The uplink-policy seam now reconciles retries whendeviceRecordbecomes active and when the coordinator commitspendantLive, preserving an existing timer and marking the device reconnect callback pending. Ownership, pause, batch, auth and session-generation admission remain in the existing paths.connected_no_bytes,zero_byte_streak,rapid_reconnects) now resolve after five seconds of ingress with no gap over two seconds, or a fresh, unexpired nativeflowinglease with subscription confirmed. Recovery does not require a live socket or transcript. Cached health, isolated packets, other devices and zero-byte events cannot clear them. Late recovery completion cannot restore a resolved banner.Transcription/upload/storage recovery semantics remain separate. The server's terminal “Not transcribing” state stays through the outage and clears when the next socket receives
ready.Validation
All heavy commands ran through
/Users/dazheng/workspace/omi/bin/omi-heavy run --.cd app && flutter test --no-pub --concurrency=1 test/services/capture/capture_socket_generation_test.dart test/services/capture/capture_wedge_monitor_test.dart test/services/capture/capture_device_pause_test.dart test/services/capture/capture_one_source_test.dart test/services/capture/capture_coordinator_test.dart test/services/capture/tiered_capture_test.dart test/services/capture/resume_sync_fence_test.dart test/widgets/capture_recovery_banner_test.dart test/providers/device_provider_capture_wedge_test.dart test/unit/capture_recovery_replay_scenarios_test.dart test/spine/c1_composition_test.dart— 251 passed.cd app && dart analyze lib/services/capture/capture_controller.dart lib/services/capture/capture_uplink_policy.dart lib/services/capture/capture_wedge_monitor.dart test/services/capture/capture_socket_generation_test.dart test/services/capture/capture_wedge_monitor_test.dart— no issues.dart format --line-length 120 --set-exit-if-changed --output=noneon the five touched Dart files — clean.make preflight— 24 checks passed; committed-diff and PR-body validation run before push.Contracts
Product invariants: INV-CAP-1, INV-UI-1, INV-UI-3, INV-PERF-1. Retries restore transcription while preserving audio ingress and existing capture admission; this adds no new UI primitive or per-frame rebuild.
Failure-Class: none
The failures are a missing retry wake at capture activation and an ingress alert resolved by evidence from the wrong layer; no existing registry class describes these mechanisms. Regression coverage exercises the shared production controller and wedge-monitor seams.
UI-Evidence: none -- controller/monitor state changes only; no UI source or layout changes. Existing recovery-banner widget coverage passes.
🤖 Generated with Codex