Repository navigation
fix(app): keep pendant recording identity across short reconnects - #25534
Conversation
Codex Review Summary: ✅ CompletedThis 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: a33a30a315
ℹ️ 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 (state.pendantOwns && connected != null && state.active?.deviceId == connected.id) { | ||
| return CaptureTransition(state, effects); |
There was a problem hiding this comment.
Make duplicate starts preserve the running session's admission
When orphan-audio recovery starts capture before the provider's start callback, this branch still executes the previously queued UpdateRecordingDeviceStage. That stage calls _updateRecordingDeviceBody, which unconditionally rolls the capture session, revokes MobileStandardBatch authorization, and ends local preview—even though this branch leaves the existing socket and recording running. Consequently, the supposedly joined start interrupts local preview and switches authorized batch audio back to live streaming until another server admission arrives; it also invalidates pending session-token-bound work such as location capture. Skip the session-replacing update for a duplicate start, or use an identity-preserving update instead.
Useful? React with 👍 / 👎.
| if (deviceId == connectedDevice?.id || deviceId == pairedDevice?.id) { | ||
| // Capture sees the loss before a sub-500ms reconnect can cancel the | ||
| // UI debounce. Native published its reason before this callback. | ||
| _notifyCaptureLinkLost(deviceId); |
There was a problem hiding this comment.
Preserve live-capture eligibility before clearing the device
For an unexpected disconnect during live pendant capture, _notifyCaptureLinkLost synchronously clears captureProvider.recordingDevice before the debounced setConnectedDevice(null) runs. That method still determines endedDeviceWasLiveCapture by comparing the departing device against capture.recordingDevice (lines 363–369), so the condition now fails and _wedgeMonitor.onBleSessionEnded is skipped. This disables the existing rapid-reconnect recovery detection for ordinary live-capture disconnects: three sessions shorter than 15 seconds no longer trigger its recovery flow. Snapshot and retain the departing session's capture eligibility before forwarding the immediate link-loss notification.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f9ab5dc0e
ℹ️ 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 (entry.reason == SuspendReason.reconnect && state.callActive) { | ||
| suspended[suspended.indexOf(entry)] = entry.withReason(SuspendReason.call); | ||
| effects.add(const RunStage(ReconnectObservationStage('reconnect_resumed'))); |
There was a problem hiding this comment.
Restore physical capture setup after reconnecting during a call
If a paused pendant loses its link, an Omi call begins during reconnect grace, and the pendant reconnects before the call ends, converting the retained entry to a call suspension preserves its non-null sessionKey. Consequently, _reduceCall selects ResumeSuspendedPendantStage rather than the full device-start stage. _resumeSuspendedPendantBody immediately returns when wasPaused is true, but disconnect teardown already cancelled _bleButtonStream and disabled native background streaming. The pendant therefore remains without its button listener after the call, so double-tap cannot resume recording. Preserve the requirement for physical reconnect setup when converting this suspension, and reinstall the listeners even when restoring a paused recording.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78436be0b0
ℹ️ 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 (retain) { | ||
| suspended.add(SuspendedCapture( | ||
| source: CaptureSource.pendant, | ||
| reason: SuspendReason.reconnect, |
There was a problem hiding this comment.
Allow deferred sync-pass starts to consume reconnect grace
If an eligible disconnect happens before a sync-only pass and the pendant reconnects during that pass, the new reconnect suspension prevents capture from restarting afterward. streamDeviceRecording defers the reconnect start while SyncWakeScope.syncOnly is true, but _runDeferredDeviceStart in capture_live_recovery.dart clears deferredStart and returns whenever _pendantSuspension != null, including this new suspension. Consequently, the connected pendant remains idle instead of restoring its recording; grace expiry only retires the identity and does not retry startup. This is particularly persistent in batch mode, where orphan-audio recovery is disabled. Allow the deferred-start path to consume a reconnect suspension while continuing to block phone/call suspensions.
Useful? React with 👍 / 👎.
## 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.
Problem and change
Short pendant BLE links currently mint a new client recording at every connect. Keep one coordinator-owned recording for 120 seconds after a classified connection timeout or remote termination, and restore it only for the same device strictly before the deadline. Preserve transport and pause intent; manual stop/disconnect, source/mode/device/account changes and process restart retire reuse.
Link loss reaches capture before the provider's 500 ms UI debounce. Physical teardown, WAL tail finalization and normal ingress restart remain in place. Early post-reconnect orphan frames still enter the safety WAL before the provider publishes its device mirror; account identity is checked as well as device identity; competing provider/recovery starts join the same owner. Existing Recording Observation telemetry distinguishes
reconnect_resumedfromreconnect_grace_expired_freshwithout claiming gap audio recovery or another Recording Started.Panel follow-ups bind the active recording to its original account before any disconnect, make duplicate starts a true no-op, emit call-deferred reconnect observations only at capture restoration, clear stale success diagnostics, and fence automatic policy restoration against the live call state after an awaited marker write. Manual-disconnect markers now belong only to a connected episode: already-down actions retire capture without poisoning the next connection, live markers survive metadata refresh, and ID casing is normalized. Refused phone handoffs retain the existing grace through the original admission reducer instead of retiring it before rejection. The final follow-up rechecks live call ownership after every awaited reconnect effect, invalidates pending physical setup and fences BLE callbacks while a call is active, and revokes native ingress immediately; expiry retires stale automatic-pause markers while preserving manual mute. Regression cases reproduced the reported failures before the fixes.
Server and v3 compatibility
Live listen continuation already resolves the retained origin/client ID with source/device/lifecycle checks. For
batch_live_v1, main's flag-offresumable_after_droppath commits the archive tail and retains an eligible mobile row when committed audio and a durable quiet-check owner exist. Existing tests prove teardown plus a same-ID reconnect at 35 seconds. Source at David's supplied serving SHA235baeaalso contains this legacy runtime branch and the live resolver; this was checked from Git without production access. Empty/uncommitted, terminal, privacy-fenced or quiet-owner-unavailable rows can still create a new server conversation: client identity reuse does not override those boundaries.LISTEN_BATCH_RECONNECT_ENABLED=trueis not required for this existing batch continuation path. Do not activate its stronger producer-grace protocol without Release's mandatory all-old-listeners-and-sockets drain gate. In-repo activation inputs arebackend/deploy/runtime_env/prod.overlay.yaml: GKEbackend-listen.envand Cloud Runbackend-sync.env, followed bypython3 backend/deploy/compose_runtime_env.pyand Release's train. Use{value: 'true', category: rollout}; default grace is already 120s. Ramp, clean metrics, owner, November 20 review and false/drain/zero-marked-row rollback live inconfig/feature-flags.yamlandbackend/docs/listen_pusher_pipeline/changes/2026-11-16-batch-reconnect-grace.md. This PR changes no server code or env and makes no fleet-drain claim.Read PR #25500's full diff. No touched capture/device files overlap. Its v3 projection folds recording IDs and time-range pieces, including multiple pieces from one recording; the preserved identity keeps that input contract. Did not alter its branch. Cross-PR rendered/device integration remains a Release acceptance item.
Verification
All heavy commands run through
/Users/dazheng/workspace/omi/bin/omi-heavy run --.pendant_live_1, gotpendant_live_2; the existing tests passed.flutter test test/services/capture/capture_coordinator_test.dart test/services/capture/tiered_capture_test.dart test/services/capture/resume_sync_fence_test.dart test/providers/device_provider_disconnect_telemetry_test.dart test/services/bridges/ble_bridge_test.dart test/unit/recording_lifecycle_telemetry_test.dart— 217 passed across coordinator, retention/sync-fence, provider classification, bridge and lifecycle suites. Includes exact/after expiry, same/wrong device, manual stops, mute/unmute, duplicates, calls, account reset, permission refusal, snapshot/launch and actual controller/WAL/socket identity.flutter analyzeon all 12 touched Dart files — no issues;dart format -l 120with pinned SDK — clean.env PYTHONPATH=backend backend/.venv/bin/python -m pytest -q backend/tests/unit/test_listen_reconnect_continuity.py backend/tests/unit/test_mobile_batch_disconnect.py backend/tests/unit/test_listen_batch_reconnect_grace.py— 110 passed (17 existing async-mock warnings).env PYTHONPATH=backend backend/.venv/bin/python -m pytest -q backend/tests/unit/test_conversations_v3_engine.py— 37 passed, including repeated speech within one recording, long recording splits and playback-piece trims. Fresh Home redesign: recordings and conversations (v3) #25500 head945cba1abd4574f9f0adf9a8d99b5c2e835ea8e2has zero touched-file overlap.ruby app/ios/test/omi_ble_connection_policy_test.rb— 2 tests, 4 assertions passed, including the production manager callback with manual precedence.:app:testDevDebugUnitTest --tests com.friend.ios.ble.DeviceDiagnosticsContractTest --no-daemonusing cached Gradle 8.14.2 and JDK 21 — passed (JDK 21, Gradle 8.14.2, full app/test Kotlin compilation; build successful in 10m57s).make preflight,scripts/pr-preflight --suggestandscripts/pr-preflight --pr-body-file /Volumes/Ephemeral/scratch/lane-b-pr-body.md— both local and PR-body gates passed all 35 selected checks (53s / 57s).No production account data/config was read or changed; GCP tier: none. No device build, production deployment, lost-frame recovery or measured reduction in conversation amplification is claimed. Genuine setup exceptions keep the existing tested fail-closed retirement semantics; this change does not hide failed setup by automatically retrying it. Remaining risk: platform/device acceptance and v3 integration; server finalization boundaries can still split conversations.
Failure-Class: FC-transport-drop-terminalizes-resumable-capture
UI-Evidence: none
Product invariants affected
Line-Count-Exception: app/lib/providers/device_provider.dart | 1734 -> 1754 | Forward capture link loss before the UI debounce using the existing provider connection callbacks.
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4969 -> 5030 | Wire typed coordinator grace to the existing lifetime timer and recording telemetry ports.
Line-Count-Exception: app/lib/services/capture/capture_coordinator.dart | 3026 -> 3258 | Keep reconnect identity and its deadline in the existing typed state and serialized reducers alongside call suspension.
Review provenance
Full panel
review-20261116t205911-a99erevieweddb907642d4a: all eight findings triaged (seven accepted and addressed; clean/nil-error expansion rejected as outside the requested cause scope, already documented). Follow-upreview-20261116t212210-5d11reviewed3f9ab5dc0e6: all six findings accepted and addressed. Delta panelreview-20261116t214804-68bareviewed78436be0b067: all three findings accepted and addressed, covering call preemption during awaited reconnect setup, expired manual pause versus stale automatic resume, and stale diagnostic clearing. Its DeepSeek member failed without an answer and is not counted as approval. Panelreview-20261116t222543-d1e4found an additional installed-listener call admission gap, reproduced by a real-controller held-registration regression (expected zero frames, got one). The follow-up fences that callback with live call state and immediately revokes native ingress. A later delta review found that a permanent callback revision could strand initial audio after a fast-failing call; a new held-registration test reproduced it, and the permanent revision fence was removed while retaining live-call admission and reconnect setup invalidation. The two-member panel completed: its listener finding was accepted and fixed; its diagnostic-only test nit was rejected as duplicating a straightforward assignment rather than discriminating the asynchronous behavior at risk. Both findings are triaged. Delta panelreview-20261116t223502-ad11has a GLM SHIP-with-minor result: the fast-call listener finding is fixed with a failing-before regression; its optional native authorization harness nit remains an explicit coverage gap. Both findings are triaged; its outstanding Luna member was cancelled after the target was superseded, so that panel is incomplete and does not count as SHIP. Panelreview-20261116t224745-74c9completed on8822c421198: Luna SHIP; GLM identified the reconnect fast-call failure plus its missing regression. Both findings are accepted and fixed inb52f7d5268e. A further real-controller probe reproduced a call that starts and ends during reconnect setup dropping the original recording ID to null. A typed environment call epoch now preserves that interruption through the await and enters ordinary call suspension/release, restoring the same ID. Its failing-before regression now passes. Exact-head delta panelreview-20261116t225138-7c67completed onb52f7d5268e: GLM SHIP, Luna FIX-FIRST on retaining identity after a genuine setup exception. F1 is rejected and triaged: the existing real-controller setup-failure tests require fail-closed retirement; no causal path from ordinary call notification to that exception was established, and automatic retry of failed setup changes that safety boundary. Successful-return fast-call interruption is independently checked and covered. The raw panel verdict is mixed; this is not unanimous approval. Hardware/native-channel acceptance remains unverified. No initial failed/aborted panel is counted as approval.