Repository navigation
fix(app): fall back to phone capture after BLE disconnect - #11066
aryanorastar wants to merge 5 commits into
Conversation
Failure-Class: none
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for this — the direction is right and the predicate/test structure is clean. There's a blocking issue before this can land.
The fallback won't trigger for active BLE device streaming.
onRecordingDeviceDisconnected() gates on recordingState == RecordingState.record, but active BLE device streaming uses RecordingState.deviceRecord (set in _initiateDeviceAudioStreaming). No path transitions a live device recording into .record — that state is only used by the phone-mic flows (streamRecording, _startPhoneMicBatch, _resumeMicRecording). So when a wearable drops mid-stream, shouldFallbackToPhoneOnDeviceDisconnect evaluates isRecording: false and returns early. The exact scenario this PR targets is missed.
The fix should check the device-record lane:
isRecording: recordingState == RecordingState.deviceRecord ||
recordingState == RecordingState.record,(and possibly .interrupted if a socket drop preceded the BLE disconnect).
Two secondary points:
-
The predicate checks
phoneMicSupportsTranscribeLater(iOS/Android) but notdeviceSupportsTranscribeLater. If the intent is to fall back only for supported wearable types, adding the device-side check (deviceSupportsTranscribeLater) would keep the fallback scoped. -
In the reconnect hand-off,
ServiceManager.instance().phoneMic.stop()is fire-and-forget. The comment says the phone batch is finalized before device streaming resumes, but sincestop()isn't awaited the ordering isn't guaranteed. Ifstop()can be made awaitable (or the hand-off serialized), that would make the transition deterministic.
The unit tests cover the predicate matrix nicely but don't exercise the RecordingState integration, which is why they pass despite the mismatch. Adding a test that verifies the fallback triggers from deviceRecord would catch this.
Flagging for maintainer review since this touches the core capture state machine.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
mdmohsin7
left a comment
There was a problem hiding this comment.
The tagged issue actually means recording on the device offline when not connected to bluetooth. Right now it does record offline but it breaks sometimes. This PR is not the right fix for this
|
@mdmohsin7 thanks — understood. I’ll treat this PR as the wrong approach for #7194 if the intended behavior is on-device offline recording when BLE is disconnected (which already exists but is flaky), rather than falling back to phone capture. @Git-on-my-level your Please confirm preferred next step:
Happy to take whichever you prefer. |
|
Retargeting this PR per @mdmohsin7's feedback above: #7194 is specifically about on-device offline recording continuing when BLE is disconnected (which already exists but is flaky) — this PR implements a different behavior, falling back to phone-mic capture while BLE is down, which isn't the right fix for #7194. Filed #11078 to scope and track the phone-capture-fallback behavior on its own, distinct from #7194, and updated this PR's description to reference it ("Relates to #11078" rather than an auto-closing keyword, since the approach itself is still pending maintainer confirmation). @Git-on-my-level's Not closing or merging anything — just re-pointing this at the correct issue for continued review. |
…ch stop Co-authored-by: Cursor <[email protected]>
|
Pushed an update for the remaining CHANGES_REQUESTED on this PR:
Could you re-review and dismiss the Changes requested once CI is green? |
|
Update pushed for CHANGES_REQUESTED:
Please re-review / dismiss once CI is green. |
…rdware#7194) Co-authored-by: Cursor <[email protected]>
Failure-Class: none Co-authored-by: Cursor <[email protected]>
Failure-Class: none Co-authored-by: Cursor <[email protected]>
|
Closing as superseded.
Sorry for the tip/history confusion on this branch. |
|
Hey @aryanorastar 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
#11134) ## Summary Reverts #11084 (`75e4e1789d`), which added `CaptureController.onRecordingDeviceDisconnected()` and the `DeviceProvider` hook that starts a **phone-mic batch recording whenever the wearable disconnects mid-session**. ## Why **This behaviour was already reviewed and rejected.** #11066 proposed the same phone-side fallback and received `CHANGES_REQUESTED` from the app maintainer: > The tagged issue actually means recording on the device offline when not connected to bluetooth. Right now it does record offline but it breaks sometimes. This PR is not the right fix for this #11066 was closed, and #11078 was opened specifically so a phone-side fallback could be scoped on its own merits. **#11078 is still open and unapproved.** **The PR description did not match its diff.** #11084 is titled "preserve on-device offline batch across BLE disconnect" and its body states it "prevents the phone-mic fallback from triggering". Before #11084 there was no such fallback to prevent: `onRecordingDeviceDisconnected` did not exist and nothing called it, and `_startPhoneMicBatch` was reachable only from user-initiated paths. The PR introduced the feature together with a guard for it; the Implementation section listed neither the new method nor the `device_provider.dart` call site. **The guard does not cover Omi hardware.** It reads: ```dart final bool isOnDeviceOfflineBatchActive = SharedPreferencesUtil().batchModeEnabled && _recordingDevice != null && (_recordingDevice!.type == DeviceType.limitless || _offlineSessionStartSeconds != 0); ``` It consults `batchModeEnabled`, but ring-buffer capture is keyed on firmware (`WalSyncs.isRingBufferFirmware`, 3.0.20+) and is independent of that pref. With batch mode off, an Omi on 3.0.20+ keeps writing to its on-device ring while the phone starts its own mic batch — the same interval is captured twice and syncs as duplicate conversations, plus an unrequested mic activation and the battery cost. #11084 did address the technical review notes from #11066 (`deviceRecord` state, awaited stop hand-off, `deviceSupportsTranscribeLater`). The product objection was not addressed. ## Scope Revert only. #11064 and #11085 from the same batch are left in place — #11064 is a genuine sort fix, and #11085 needs a real fix rather than a revert (its `filterFullySyncedConversations` never releases a WAL retired to `WalStatus.outsideRecoveryWindow` by #10995, so those conversations stay filtered out of the synced list; tracked separately). #7194 remains open on its actual subject: on-device offline recording that works but is flaky across disconnects. ## Verification ``` flutter analyze lib/services/capture/capture_controller.dart lib/utils/batch_recording.dart \ lib/providers/device_provider.dart test/unit/batch_recording_phone_test.dart -> 1 info (unnecessary_import at device_provider.dart:4), confirmed pre-existing on main; 0 new flutter test test/unit/batch_recording_phone_test.dart test/providers/capture_provider_test.dart \ test/providers/sync_provider_fully_synced_conversations_test.dart \ test/unit/synced_conversation_pointer_order_test.dart -> 89 tests, all passed grep shouldFallbackToPhoneOnDeviceDisconnect | onRecordingDeviceDisconnected | isRecordingDuringDeviceDisconnect | _phoneMicBatchStopCompleter -> no matches remain under app/ make preflight -> 11 checks passed ``` Clean revert: no later commit touched `capture_controller.dart`, `batch_recording.dart`, `device_provider.dart`, or `batch_recording_phone_test.dart` between #11084 and `84e4c1828b`. ## Product invariants affected none ## Failure class (fixes) No `fix:` commits; no declaration required. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/11134?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Reverts 75e4e17 (BasedHardware#11084), which added `onRecordingDeviceDisconnected()` and the `device_provider` hook that starts a phone-mic batch recording whenever the wearable drops mid-session. The same behaviour was proposed in BasedHardware#11066 and rejected by the app maintainer: BasedHardware#7194 asks for on-device offline recording to keep working across a disconnect, not for the phone to start recording in its place. BasedHardware#11066 was closed and BasedHardware#11078 was opened to scope a phone-side fallback on its own merits; BasedHardware#11078 is still open and unapproved. BasedHardware#11084 landed the feature anyway, described as a guard against it. Its guard is also wrong for Omi hardware: it consults `batchModeEnabled`, but ring-buffer capture is keyed on firmware (`isRingBufferFirmware`, 3.0.20+) and is independent of that pref. With batch mode off, an Omi on 3.0.20+ keeps writing to its ring while the phone starts its own mic batch, so the same interval is captured twice and syncs as duplicate conversations. Verification: flutter analyze lib/services/capture/capture_controller.dart \ lib/utils/batch_recording.dart lib/providers/device_provider.dart \ test/unit/batch_recording_phone_test.dart -> 1 pre-existing info (unnecessary_import, already on main), 0 new flutter test test/unit/batch_recording_phone_test.dart \ test/providers/capture_provider_test.dart \ test/providers/sync_provider_fully_synced_conversations_test.dart \ test/unit/synced_conversation_pointer_order_test.dart -> 89 tests, all passed grep for shouldFallbackToPhoneOnDeviceDisconnect / onRecordingDeviceDisconnected / isRecordingDuringDeviceDisconnect / _phoneMicBatchStopCompleter -> no matches Failure-Class: none
Summary
Relates to #11078.
Retargeted 2026-08-04: this PR was originally opened against #7194, but maintainers (@mdmohsin7, @Git-on-my-level) flagged that #7194 is specifically about on-device offline recording (a separate, existing-but-flaky path), and that a phone-capture fallback is a different behavior. This PR now tracks against #11078, filed to scope that phone-fallback behavior on its own. Using "Relates to" rather than "Fixes" since the approach for #11078 itself is still pending maintainer confirmation — see the also-still-open
deviceRecordstate-gating issue raised in review.When an active supported wearable recording lost Bluetooth, the app stopped
receiving device audio but did not start its existing automatic phone-mic batch
fallback. The missing interval was therefore lost until the wearable reconnected.
The capture controller now starts the existing automatic phone batch writer on
an unexpected BLE disconnect during an active supported recording. The batch is
finalized before device streaming resumes on reconnect, and manual stops,
unsupported devices, inactive sessions, and already-active batch sessions do
not trigger the fallback.
Verification
flutter test test/unit/batch_recording_phone_test.dartdart format --output=none --set-exit-if-changed test/unit/batch_recording_phone_test.dartflutter analyze lib/providers/device_provider.dart lib/services/capture/capture_controller.dart lib/utils/batch_recording.dart test/unit/batch_recording_phone_test.dartunnecessary_importindevice_provider.dart.Invariants
No product invariants are affected.
Failure-Class: none