Skip to content

fix(android): stabilize Custom Live Pendant capture - #23643

Open
jverbakel wants to merge 4 commits into
BasedHardware:mainfrom
jverbakel:codex/omi-custom-live-routing-fix-1.0.574
Open

jverbakel wants to merge 4 commits into
BasedHardware:mainfrom
jverbakel:codex/omi-custom-live-routing-fix-1.0.574

Conversation

@jverbakel

Copy link
Copy Markdown

Summary

  • Send binary audio frames only to the Custom Live primary socket, while routing non-audio control messages only to the official Omi secondary socket. This prevents Custom Live from receiving unsupported String control frames.
  • Suspend new “Transcribe Later” work while Custom Live is active, then restore the prior user preference when it stops.
  • Add bounded local device offload for Pendant flash pages: persist the batch on the phone before acknowledging/freeing the device page, without migrating or deleting existing recordings or offline backlog.

Validation

  • flutter analyze --no-pub on the 13 changed source/test files: no issues.
  • Targeted Flutter regressions: 101/101 passing.
  • git diff --check passed.

User impact

This targets the connected-but-no-transcript failure where the Android app logged Unsupported message type: String despite a connected Custom Live socket. It preserves the normal Omi route for summaries, memories, and cloud conversation processing.

@jverbakel
jverbakel requested a review from mdmohsin7 as a code owner October 25, 2026 23:28
@Git-on-my-level

Copy link
Copy Markdown
Member

Strong, well-scoped fix with genuinely good test coverage — one behavior change beyond Custom Live needs maintainer confirmation before merge.

Correctness (verified on head 1e0b6ec):

  • composite_transcription_socket.dart — send() now routes String control messages only to the Omi secondary socket and binary audio only to the custom primary; this directly fixes the 'Unsupported message type: String' destabilisation, and suppressing an orphaned capture_evidence_frame record when its audio won't follow to secondary is the right call.
  • capture_coordinator.dart — the shared _reduceRealtimeBatchSuspension correctly composes the onboarding and Custom Live suspend reasons so releasing one never restores Transcribe Later while the other still needs realtime audio; the BatchModeSetRequested guard (reject result:false while customLiveRealtimeRequired) closes the race where the native batch writer would consume Pendant frames before the custom WebSocket sees them. Both paths have new coordinator tests.
  • capture_controller.dart — _reconcileCustomLiveBatchMode on settings change and before DeviceStartRequested self-heals a restart mid-switch; the persisted marker in preferences.dart preserves the user's Transcribe Later preference across the suspension.
  • device_provider.dart — Limitless detection moved before the supportsMultiFileSync guard; countLimitlessPendingFlashPages rejects reversed/absent ranges. I verified the threshold-parity claim against flash_page_wal_sync.dart (pageCount > 30 there, pendingPages <= 30 here). Nit: a status map missing both keys yields 1 (0..0), not 0 as the doc comment implies — harmless under the 30-page gate but worth tightening.
  • sync_provider.dart / wal_syncs.dart — single-flight coalescing of duplicate BLE offline-data notifications, and a device-to-phone-only drain (syncDeviceWalsToPhone) whose ACK-after-durable-write ordering comes from the existing flash-page implementation; the new test asserts the cloud-sync route is never taken (genericSyncAllCalls == 0).
  • home/page.dart — the custom-STT branch now local-offloads instead of skipping. Note the reordering: users who disabled 'auto-sync offline recordings' get no drain either — a defensible reading of the setting, but it changes 'never' into 'unless disabled'.
  • transcription_settings_page.dart — making the active config authoritative for its provider and treating a custom URL as a request customization are both correct editor-consistency fixes.

For maintainer confirmation: the new Limitless branch in device_provider.dart fires onOfflineDataDetected for ALL provider users of a Limitless Pendant, not just Custom Live ones — an Omi-provider user with >30 pending pages now gets automatic cloud upload on connect, where the previous guard skipped the device entirely. Likely exactly the intended fix (a full Pendant could never drain), but it newly auto-uploads audio for that cohort, so it deserves an explicit maintainer yes.

UX: while a Custom Live route is active, the Transcribe Later toggle silently no-ops (result: false). Consider surfacing why in the UI. Also noted: the five _failClosed( -> await _failClosed( fixes in capture_coordinator.dart are unrelated to the title but clearly correct (recovery was previously unawaited).

USER IMPACT: Custom Live users get live transcripts from their Pendant again (no more connected-but-silent socket), their device recordings auto-copy to the phone without being uploaded to Omi, and the Pendant's storage keeps draining so it doesn't fill up.

Action items: (1) maintainer confirms the Omi-provider Limitless auto-upload change; (2) tighten countLimitlessPendingFlashPages for missing keys; (3) consider UI feedback for the rejected Transcribe Later toggle.

Leaving for human maintainer review on the Limitless auto-upload behavior change only — the implementation itself is solid.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution needs-maintainer-review Needs a human maintainer to sign off before merge flutter flutter work labels Oct 26, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

First-ever PR from an old (2023) but previously-inactive-in-this-repo account; no abuse signal, no self-bounty, but diff (757 lines) exceeds the confidence-gate size cap and has no linked issue — approve only, do not merge.

@Git-on-my-level

Copy link
Copy Markdown
Member

Since my last review: addressed — the one open maintainer question (Omi-provider Limitless auto-upload on connect) was confirmed by a maintainer approval of that head on Oct 26, and the unawaited recovery fixes are retained · still open — countLimitlessPendingFlashPages still returns 1 for a status map missing both keys (device_provider.dart:1154; harmless under the 30-page gate), and the rejected Transcribe Later toggle still gives no UI feedback · newly introduced — none found.

Verdict: the new stalled-audio-recovery commit is correct, tightly bounded, and well tested; no blocking issues.

  • limitless_connection.dart — the old _publishAudioFrames cancelled the stream-health watch on the first decoded frame and never re-armed it, so audio that stopped mid-session was invisible. The new version (limitless_connection.dart:456) keeps a watch armed while frames flow and tracks first/last frame times; _checkStreamHealth now distinguishes audio_stalled from no_rx_packets/rx_without_audio_frames, and the recovery ladder is bounded: one firmware stream reactivation, then one GATT link replacement, then budget-exhausted and stop, with the budget restored only after sustained audio. limitless_golden_test.dart pins exactly that (one recovery, no reconnect loop).
  • native_ble_transport.dart / device_transport.dart — SilentAudioRecovery is a clean transport capability gated to Android; the iOS implementation (BleHostApiImpl.swift) is a documented no-op, and recoverSilentAudio errors surface through the probe's existing catch path.
  • OmiBleForegroundService.kt:566 — recoverSilentAudio delegates to forceReconnect without touching managed-device, bonding, saved-reconnect, or user-disconnect state, matching its doc comment.
  • Security/privacy: no new endpoints or permissions; control messages and orphaned evidence records stay off the custom endpoint (composite_transcription_socket.dart:156), and the custom-STT device drain still never uploads to Omi's cloud route (asserted in sync_provider_local_device_offload_test.dart).
  • CI note: no app test lane ran on this head, so the reported 101/101 is CI-unverified; the new golden test is the right regression pin once CI exercises it.

Performance: the watchdog adds one BLE status probe per health window only while the stream is silent — negligible. Blast radius: realtime-mode Limitless users only; batch and suppressed modes are excluded by _shouldMonitorRealtimeStream.

USER IMPACT: Android Pendant users get live transcription that heals itself when the audio stream stalls mid-session, instead of staying silently connected until a manual reconnect.

Action items: (1) confirm the hand-edited Pigeon files (PigeonCommunicator.g.kt/.g.swift, pigeon_communicator.g.dart) match pigeon regeneration so a future regen can't drop recoverSilentAudio; (2) consider bounding the health-probe error retry (health_recovery_error reschedules indefinitely, one BLE read per window, while probes keep failing); (3) optionally surface why the Transcribe Later toggle is rejected while Custom Live is active.

needs-maintainer-review stays because the maintainer approval predates this head's new native Pigeon surface — the Android/iOS plumbing deserves one human pass before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level

Copy link
Copy Markdown
Member

Since my last review: addressed — nothing new needed addressing: the only new commit is a clean merge of latest main, and I verified it did not modify any of this PR's changes (23 of 24 files byte-identical; home/page.dart and capture_controller.dart received only main-side edits in regions this PR doesn't touch) · still open — the four carry-over nits below, unchanged and non-blocking · newly introduced — none.

Verdict: unchanged — solid, well-tested work; the merge integrates cleanly and the guard/resolve checks pass on this head.

One thing the merge does change: main's pendant ring-custody rework (flash_page_wal_sync.dart, ring_storage_sync.dart, pendant_ring_custody.dart) landed in the same WAL/offload layer this PR's syncDeviceWalsToPhone builds on, and no app test lane has run on the merged head — so the golden/coordinator regressions remain the right pins but are still CI-unverified here.

Carry-over nits: (1) countLimitlessPendingFlashPages still returns 1 for a status map missing both flash-page keys (device_provider.dart, the two ?? 0 defaults span to +1; harmless under the <=30-page gate); (2) confirm the hand-edited Pigeon files (PigeonCommunicator.g.kt/.g.swift, pigeon_communicator.g.dart) match pigeon regeneration so a future regen can't drop recoverSilentAudio; (3) consider bounding the health-probe error retry (health_recovery_error reschedules indefinitely, one BLE read per window); (4) optionally surface why the Transcribe Later toggle is rejected while Custom Live is active.

USER IMPACT: none from this update — it is a merge of main only; the user-visible behavior (self-healing live transcription and local-only device offload for Custom Live users) is exactly as reviewed previously.

needs-maintainer-review stays for one specific reason: the hand-written native Pigeon surface plus the fact that the merged head (main's ring-custody rework meeting this PR's offload path) hasn't been exercised by an app test lane — worth one human pass before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

Git-on-my-level added a commit that referenced this pull request Nov 21, 2026
## Summary

Supersedes #23643 for Android Custom Live realtime capture.
[SCA-3592](https://multica-01.tail76ea03.ts.net/scaling-forever/issues/01a1ff2e-a8dd-7191-a8bd-303b9ec9deb0)
owns design, acceptance and release follow-through.

- On all supported Custom Live platforms, send Omi controls to the
secondary and binary audio to Custom Live. Send an Omi evidence record
together with its binary frame only when the user enables secondary raw
audio.
- Watch decoded Limitless audio for the admitted Android Custom Live
capture and BLE epoch. Retry firmware stream enable once per episode,
under live ownership checks. Require a full window of progressing
decoded audio before rearming. Close the watch when that owner retires,
the link drops or flash drain takes over.
- Preserve #25534's recording identity across short reconnects and the
existing WAL/reclaim paths, including #25415's range and proof behavior.
The original PR also proposed automatic flash offload, persistent
Transcribe Later preference switching and GATT replacement. Those
behaviors are outside this successor's approved recovery path.

## Verification and release

- Three regression assertions failed on pinned main
`460379212835226dfbc3baa7b37b16b373f2bf55` before the socket fix. All 86
focused tests passed on Flutter 3.44.5. The suites exercise the
raw-audio consent pair, decoded-frame stall retry and link loss,
sustained frame progress, pending-write ownership, reconnect telemetry
and the protected capture paths.
- The provider republishes normalized metadata after capture starts. A
new replay failed on the draft when that update retired the watchdog.
The fix retains the same admitted recording and BLE link across that
refresh and fences changes in account or pause.
- The retained-capture reconnect regression failed on the second-round
head. The connector now closes the old epoch immediately and re-arms
after setup only if that same capture still owns the new link. The
replay proves one retry on each link without a second capture start.
- Release QA needs a paired Android+Limitless run verifying normal quiet
behavior, a known utterance around an injected midstream stall,
decoded-audio resumption, and a transcript on the Custom Live endpoint.
The local device lab had no Android handset attached.
- Production readback uses `Recording Observation` by app version/build.
Count one detection-eligible and one detection-enabled/disabled
observation per recording, and report restored, exhausted and censored
outcomes. Report exhausted episodes per 1,000 detection-enabled
recordings alongside enabled/eligible coverage. Older builds lack the
Custom Live session dimension, so SCA-3592 records the historical
baseline as unavailable. Use the first complete qualifying 24 UTC hours
on the first instrumented build for the production baseline.
- Default on. Release can disable the firmware watchdog using the cached
PostHog boolean `android-custom-live-audio-recovery-kill`. Full rollback
is a rebuild with `--dart-define=OMI_CUSTOM_LIVE_CAPTURE_FIX=false` or a
revert. No backend write, new endpoint, or audio retention change.

## Product invariants affected

- INV-CAP-1. The Android Limitless retry adds no uplink pause or
subscription removal and makes no claim about audio from before
restoration. The tiered-capture and resume/sync-fence guard suites were
exercised.

Failure-Class: new
UI-Evidence: none
Line-Count-Exception: app/lib/services/capture/capture_controller.dart |
5095 -> 5175 | Bind watchdog admission and telemetry to the admitted
recording, account and BLE connection.
Line-Count-Exception:
app/lib/services/devices/connectors/limitless_connection.dart | 2237 ->
2294 | Connect realtime health to BLE setup, decoded audio and
generation teardown.

## Review provenance

- R1 `review-20261121t180552-ffc0` reviewed
`f091e051a8f8e9809f1fb8aa4339b4ce81b130c5`. Two reviewers returned SHIP.
The third timed out. The controller-level coverage finding was accepted
and tested on the next head.
- R2 `review-20261121t183640-a410` reviewed
`7ea054a3f366f9f50545f166c5d8164f7a32e780`. The retained-capture
reconnect finding was a blocker. The other answered reviewer raised
three nonblocking findings. The third timed out. All four findings were
triaged.
- Pipeline accepted the verified reconnect correction at
`1899388f6ea4f10e93542c194391de3963694cfd` under the two-round rule. The
disposition and regression evidence are on SCA-3592. Regular binary
consent routing passed a supplemental local replay. Maintained coverage
and unchanged-settings refresh behavior are tracked in SCA-3617 and
SCA-3616.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants