Skip to content

fix(mobile): re-arm live STT retries and clear recovered audio banner - #22094

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/stt-reconnect-banner
Oct 18, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/stt-reconnect-banner

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

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/listen socket. 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

  • Keep-alive arming depends on the legacy deviceRecord mirror, 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 when deviceRecord becomes active and when the coordinator commits pendantLive, preserving an existing timer and marking the device reconnect callback pending. Ownership, pause, batch, auth and session-generation admission remain in the existing paths.
  • A stuck BLE codec read could hold the serialized keep-alive tick and its reconnect guard indefinitely. The reconnect codec read now has a ten-second capture-scheduler deadline; expiry releases the tick without failing capture, and a late result cannot open a socket.
  • Legacy BLE wedge episodes depended on a transcript to resolve. BLE-only triggers (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 native flowing lease 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 --.

  • Before the fix: ten new regression cases failed, covering early-close re-arming, failed startup, a held codec read, all three BLE triggers with byte/native-health recovery, and preservation of simultaneous transcription/upload evidence.
  • 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=none on the five touched Dart files — clean.
  • make preflight — 24 checks passed; committed-diff and PR-body validation run before push.
  • No physical-device, native build, or production acceptance run. CI will supply additional coverage.

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

View guided diff Turn on auto-fix

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T05:10:12.660595Z b299f2b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +218 to +220
final state = _devices[deviceId];
final episode = state?.episode;
if (state == null || episode == null || !_isBleIngressTrigger(episode.trigger)) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +695 to +696
for (final session in _openSessions.values) {
if (session.deviceId == deviceId && session.bytesSinceTranscript == 0) session.watchdogDeclared = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 1ad79c1 into main Oct 18, 2026
50 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/stt-reconnect-banner branch October 18, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant