Repository navigation
fix: preserve transcription through Wi-Fi and provider settings changes - #22197
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
|
Verdict: the core fixes here are correct and well-fenced — no blocking issues found. Positive signal from me; merge sign-off stays with a human maintainer. What I verified:
Performance: reachability now runs on a service-owned 10s tick calling Security: no new data leaves the device; key rotation only rewrites locally stored request JSON. USER IMPACT: Transcription keeps working through Wi-Fi-to-cellular switches, and updating a provider API key no longer wipes your custom request settings; saving provider changes also no longer fails just because an unused on-device Whisper model is missing. Still wanted before merge: an on-device confirmation of a Wi-Fi-to-cellular handover during active transcription (the PR itself notes the customer case is unverified), and the probe-cadence check above. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Trusted backend/mobile fixer, well-documented connectivity/credential/settings regression fixes. mergeStateStatus is DIRTY (no rebase per standing policy) and diff (788 lines) exceeds the scoped-diff bar anyway — approve-only, needs author/bot rebase before it can land.
…covery # Conflicts: # app/lib/pages/settings/transcription_settings_page.dart
|
Pushed 1e48a7c (from f4ddf9c): merged current origin/main.
Tests after the merge: connectivity, STT credentials, settings retention, capture/WAL and paid-upgrade suites, 527 passed / 14 skipped; on-device render suite 183 passed; analyzer clean; Physical Wi‑Fi↔cellular handover is still unverified on a device. |
|
Auto-fix isn't included in your plan ↗ |
Git-on-my-level
left a comment
There was a problem hiding this comment.
The production change here is correct and nicely scoped, and the recovery/retention tests are genuinely strong; one mechanical blocker from the main merge — the analyzer ratchet fails on one new unused import, so Dart Analyze & Tests and Mobile Release Eligibility are red on this head.
Blocking: Mobile App Checks run for 1e48a7c fails at the "Run analyzer ratchet" step with unused_import: 1 found, baseline 0; the Flutter test step was skipped after it, so tests haven't run on this head either. Your previous head f4ddf9c was green and main was green at the merge base — the stray import came in with the merge commit (transcription_settings_page.dart is the only app file whose merge result differs from both parents). Running flutter analyze in app/ will point at it; drop the import, or if it's deliberate follow the ratchet's own instruction (app/scripts/analyze_ratchet.sh --update-baseline in this PR).
What I verified on the new code:
- app/lib/services/connectivity_service.dart: subscription-before-snapshot ordering in _initialize() plus the network/probe revision fence in _refreshInternet() correctly prevents a stale Wi-Fi probe from overwriting a newer cellular result; the @VisibleForTesting seams keep production behavior identical.
- app/lib/models/stt_request_credentials.dart: updateSttRequestApiKey rotates only headers still equal to the previous generated value (case-insensitive name match), preserves explicit overrides, and passes malformed JSON through to existing validation — exactly the reported bug.
- app/lib/models/custom_stt_config.dart: audio_field_name/schema join toJson only when set, so legacy sttConfigIds without overrides stay stable; the new legacy-identity test plus the paywall-pin release test in usage_provider_paywall_pin_test.dart cover the compatibility case.
- app/lib/pages/settings/transcription_settings_page.dart: parsing request/schema JSON regardless of Advanced collapse, and the _useCustomStt guard on the on-device model check, fix both settings-loss paths from the PR description.
- Tests: connectivity_service_test.dart (out-of-order probes, shared init), transcription_settings_recovery_test.dart (key rotation through the real widget), transcription_settings_retention_test.dart (session + durable audio survive a settings change via CaptureReplayWorld) — the right coverage for the bug class.
- app/docs/transcription-connectivity-recovery.md, AppSetup.mdx, the CAPTURE_ARCHITECTURE.md cross-link and the changelog fragment all match the implementation.
Performance: the service now owns a 10s periodic reachability probe (2 URIs, 3s timeout) — same cadence the checker previously used, negligible change. Security: no new secret surfaces; tests use fixture keys only. Blast radius: transcription connectivity and STT settings saves for all app users; the retention tests cover the feared recording-loss path.
USER IMPACT: Transcription keeps working through Wi-Fi/cellular switches, and updating a provider API key no longer discards your custom request settings or blocks saving Omi/Parakeet.
Only remaining ask: green analyzer ratchet (and therefore green Mobile Release Eligibility) on the merged head — everything else looks ready.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Pushed dc5fcbc: merged current main (8edd56d). No code changes.
|
kodjima33
left a comment
There was a problem hiding this comment.
Reconfirming: connectivity/credential/settings fix is well-tested and CI is green on the current head (Dart Analyze & Tests, Mobile Release Eligibility both pass). Git-on-my-level's CHANGES_REQUESTED cited a specific analyzer failure on an earlier commit (1e48a7c) that is fixed on the current head (dc5fcbc) — stale, not applicable. kodjima33 already approved. 4/5 confidence (diff size is the only failing criterion).
…#22873) ## Why On 2026-10-20 a user lost about 4 hours of pendant audio, including a 2-hour conversation, and uploads stalled for the same 4 hours. A cold start fixed both. Two investigations traced it to several gaps that compound: 1. **Primary cause: a reconnect during a sync pass skipped capture, and nothing restarted it.** - Every BLE connect wakes a `deviceConnected` pass. - That pass ran inside `SyncWakeScope`, so `DeviceProvider._onDeviceConnected` and `streamDeviceRecording` silently skipped the capture start, and the uplink fence blocked socket and audio opens. - Nothing re-drove the skipped start when the pass ended or when the app came to the foreground. - The pass itself could hang forever on an untimed BLE read. Every later wake (foreground, Retry) joined the stuck pass, so no uploads happened either. - A connected pendant on firmware 3.0.21 with no audio subscriber **discards** audio (`transport.c` pusher, connected + unsubscribed branch). 2. **Live socket recovery had dead ends.** - A normal server close (1000/1001) waited for the 15 s keep-alive. - The keep-alive cancels itself permanently on several conditions. - A network change or app resume never re-armed it. 3. **The upload worker only ran on wake events.** - A wifi→cellular handover never reports offline, so it caused no wake. - Retries and the cooldown-end wake were dropped in the background. - Nothing woke the worker while rows sat in "Waiting to sync". 4. **BLE reads and writes had no timeouts.** On iOS, a second read of the same characteristic overwrote the first caller's completion, so the first caller's future never resolved. ## What changes **1. Capture is never stranded by an upload pass.** - Only the OS-granted `periodic` window (BGTask) still fences live capture. Reconnect and watchdog passes no longer do (`RecordingTransferCoordinator.fencesLiveCapture`). - `DeviceProvider` always calls `streamDeviceRecording`. - If a start lands inside a fenced pass, it is recorded and **replayed when the fence drops**. - Foreground resume starts a connected pendant that capture left idle. - **Every pass has a hard time limit:** 60 min, or 10 min when fenced. The limit sits inside the scope, so a hung stage releases the fence and `_inFlight`. `SyncProvider` cancels the abandoned sync, and the coordinator schedules a retry. **2. Pendant audio is never silently dropped.** - `NativeBleTransport` hands audio notifications that arrive with no Dart listener to `OrphanAudioRoute`. These packets were previously dropped by the broadcast controller, because the native GATT subscription outlives capture's listener. - Capture writes them synchronously to the existing safety WAL while the WAL tracks the pendant codec. They then upload through the normal sync path. - **Why the WAL and not unsubscribing:** on shipped firmware, unsubscribing while connected makes the pendant *discard* audio. It writes flash only while disconnected (`omi/firmware/omi/src/lib/core/transport.c` pusher). Unsubscribing is therefore not a fallback. - **Excluded:** muted policy (user intent), a caller stop (the voice-profile flow), Transcribe Later (the native writer owns that audio), and phone or call ownership. **3. Live socket recovery.** - A server close (except terminal codes 1008/4001/4002/4004/4005), a socket error, connectivity restore, a network-type change and app resume each kick an immediate reconnect. - Backoff is bounded: 1, 2, 5, 10 and 15 s over a 5-minute window, with the 15 s keep-alive still running underneath. - The kick re-arms a keep-alive that had cancelled itself, and re-installs a missing pendant audio stream while capture still owns it. **4. Upload worker.** - Any connectivity change wakes the worker, including a network-type change (`ConnectivityService.onNetworkChange`). - `cooldownElapsed` is accepted in the background. Retries also run in the background, capped at 6 consecutive failures. - A new `watchdog` wake runs every 10 minutes while recordings are pending and no pass is running. - The multipart upload response-body read now has a 2-minute timeout. **5. BLE timeouts.** - Dart `NativeBleTransport` read and write calls time out after 10 s. A timed-out read returns empty; a timed-out write throws. - Capture's codec read is bounded at 35 s and falls back to the last known codec. - **iOS** `OmiBleManager`: pending reads and writes are queued FIFO per characteristic instead of overwritten, and each fails with `TIMEOUT` after 10 s. **6. Telemetry.** - New registered event `Capture Recovery Observed`, with `kind` (`capture_start_skipped`, `capture_start_redriven`, `pendant_audio_orphaned`, `transfer_pass_timed_out`) and `trigger`, plus a consumer question. - Debug-log markers: `capture_start_skipped`, `capture_stopped_with_device_streaming`, `transfer_pass_stuck`, `ble_op_timeout`. **Flags:** none. These restore intended behaviour and ship on by default. Each new path is bounded (rate limits, retry cap, time limits) and fails toward recording. **Known trade-off:** on firmware that has opted into live persistence (draft #20450, not released), orphan audio is also on the ring. The pendant ring custody contract (`app/lib/services/wals/PENDANT_RING_CUSTODY.md`) prefers keeping both copies over losing one. ## Tests Run as targeted Flutter tests under `nice -n 19`. Results: - `test/services` + `test/providers`: 1638 passed. - `test/spine` (`OMI_DEV_CONTROLS=1`): 138 passed. - `test/unit` + `test/backend`: passed. New tests: - **`test/services/capture/capture_live_recovery_test.dart`**, through the real controller, socket service and WAL with a scripted transport. It covers: - a normal close reconnecting within 2 s; - repeated closes backing off but never stopping; - a network handover, and separately an app resume, re-arming a keep-alive that had cancelled itself; - terminal close codes not kicking a reconnect; - **a reconnect during a fenced pass still yielding capture once the pass ends**; - **a hung fenced pass aborted by its time limit, after which capture starts**; - reconnect passes not fencing at all; - orphan packets being persisted, while muted and caller-stopped pendants are left alone. - **`recording_transfer_coordinator_test.dart`** covers: - a hung pass being abandoned, releasing the fence and the joined wakes; - only `periodic` fencing; - a network handover waking a pass; - the watchdog waking only while work is pending; - background cooldown and bounded background retries. - **`native_ble_transport_test.dart`** covers read and write timeouts and orphan delivery. Updated tests (these encoded the old contract): - `periodic_recording_sync_test` now expects capture after the pass, and bounded background retries. - `tiered_capture_test` and `resume_sync_fence_test` now use the `periodic` fence. - `capture_recovery_replay_scenarios_test`: connectivity restore now reconnects immediately rather than at the next 15 s tick. **Not verified:** on-device behaviour (no physical pendant run), and the iOS native change. The Swift change was syntax-checked with `swiftc -parse` only and needs the iOS CI build. ## Regression guard for #20837 Fault-injection tests in `app/test/services/capture/capture_live_recovery_test.dart`, group "regression guard for #20837 (fault injection)". They run in CI through `flutter test`. **Each test asserts two things:** - live capture (a connected socket plus the pendant audio subscription) is running again within **3 s** of virtual time; - **no pendant packet is dropped:** every packet emitted while the pendant was connected is durable in the safety WAL. **Faults covered:** - **A Wi-Fi to cellular handover during an upload pass.** The socket dies on the old interface, a network change follows, and the reconnect pass is still running. - **A normal server close (1000) of the live socket.** - **A pendant BLE drop and reconnect in the middle of a fenced pass.** Packets arriving while capture is deferred reach the orphan route and are persisted, and capture starts when the fence drops. - **A hung pass that never finishes.** The hard time limit ends it, and capture starts. By construction, each of these fails on the pre-PR code (reasoned from the code paths; not executed against the old tree): either there is no capture restart, or the restart comes at the 15 s keep-alive, beyond the 3 s bound. ## Review round 1 (Grok) fixes - **FIX-FIRST, replay under phone or call ownership.** A start swallowed by a fence is now replayed unless the pendant already owns capture, is suspended, or was stopped by a caller. The reducer records the pendant as suspended while a phone recording or call holds capture, and resumes it afterwards. New test: "a start swallowed while a phone recording owns capture resumes the pendant after it". - **FIX-FIRST, orphan WAL priming race.** - The codec boundary is taken only while the transport still has no listener and no phone or call owns capture, and this is rechecked after the await. - No boundary is taken when the WAL already tracks the pendant codec (new `LocalWalSyncImpl.currentCodec`). - The backlog is written only while the WAL codec matches. Otherwise it is dropped rather than written under the wrong codec. - A full backlog drops the oldest packet. - **FIX-FIRST, an abandoned pass keeps running.** - A timed-out pass is marked stale by a pass generation and stops at its next stage boundary. - It holds an extra transfer keep-alive until it actually exits. - No later pass discovers or drains beside it. That block is bounded by a second time limit, after which the pass is presumed dead. - The test now asserts that there is no second discovery or drain while the body runs, and that the keep-alive is balanced. - **SHOULD-FIX, iOS GATT queue.** Only the queue head is issued to CoreBluetooth, which allows one outstanding read or write per characteristic. The next request is issued when the head completes or times out. - **Not changed:** - A timed-out Dart read still returns empty. That matches every other native read failure, which also maps to empty, and the watchdog and reconnect wakes retry. - Only Opus goes to the safety WAL. That matches the primary capture path's `checkWalSupported`. - Fenced foreground periodic windows are capped at 10 min, as noted in the review's NIT. - **Merge with main:** the change is merged with main (#22197 rewrote `ConnectivityService`). `onNetworkChange` is re-added on top of that version and has a unit test. ## Review round 2 (Grok) fixes - **FIX-FIRST, orphan priming race (supersedes the round-1 priming).** - Orphan audio is now written synchronously, and only while the WAL already tracks the pendant's codec. That holds in the incident shape, where the pendant was the last source. - The orphan path never calls `onAudioCodecChanged`, so it cannot race a live start or wipe a session that subscribed in the meantime. - When the codecs differ, packets are counted (`dropped`) and capture is restarted. - New test: "orphan packets never move the WAL off another source's codec". - **FIX-FIRST, gate on an abandoned pass.** - An abandoned pass now blocks discovery and drain until it actually exits. There is no time-based release any more. - Its sync is cancelled on timeout, and every BLE and HTTP await beneath it is now bounded, so it does exit. - Every stage returns once the pass is stale. That includes the tail after the drain (refresh and reconcile) and the `catch` path. - **SHOULD-FIX, iOS late GATT replies.** After a timeout, the next operation waits for CoreBluetooth's late reply, or a 5 s grace, before it is issued. The late reply is never handed to the next waiter. ## Review round 3 (Grok): mergeable - Grok's verdict: every FIX-FIRST from rounds 1 and 2 is resolved. - **SHOULD-FIX taken:** a deferred start that is swallowed again by a periodic fence raised in the same turn now re-arms and loops, instead of being stranded. - **Not taken in this PR (follow-ups):** - correlate a late iOS GATT reply by operation id on notifying characteristics; - make a timed-out Dart read throw instead of returning empty, so a storage list read that times out is retried rather than counted as "no files". ## Product invariants affected - INV-CAP-1: this extends it. A sync pass, a dead socket or a missing listener must not stop consumption of pendant audio while the connected firmware discards unconsumed frames. UI-Evidence: none -- no UI change; capture, sync and BLE plumbing only Failure-Class: FC-automatic-capture-pause-without-retention Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4520 -> 4531 | recovery hooks only (part directive, state field, resume/close/connectivity/stop hooks, sync dispose cancel); logic lives in the new capture_live_recovery.dart part Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2757 -> 2758 | one read-only currentCodec getter so orphan audio never forces a codec boundary on a WAL that already tracks the pendant codec 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A Wi-Fi probe could finish after a newer cellular result or interface loss and overwrite connectivity. Editing a Deepgram key could also retain the old generated Authorization header, while collapsing Advanced dropped customized request settings on save.
Keep reachability under one service-owned polling cadence with network/probe revisions and startup subscription ordering. Rotate only headers still bound to the previous generated credential, preserve explicit overrides and collapsed settings, include parser/audio-field edits in socket identity while preserving legacy IDs without overrides, and allow saving Omi/Parakeet when an inactive Whisper model is unavailable. Settings still dispatch the existing capture event; no recording, preference or account reset is introduced.
Refs #20482. The customer's exact network/provider cause and historical audio status are still unverified; this PR does not close the support case.
Validation:
app/scripts/visual_audit.sh --head WORKTREE --only settings-transcription(no physical-device claim).Release: merge and mobile store release required; no backend deployment. #21299 is already on main and its internet-detection improvement is listed in iOS 1.0.563 store notes. That release alone does not verify this customer's report. After a build containing this PR ships, verify short Wi-Fi/cellular clips and Offline Sync; privately collect versions and timestamps if failures continue. Keep apps installed and recording data intact.
Architecture and implementation/release checklist:
app/docs/transcription-connectivity-recovery.md.Failure-Class: FC-split-mutation-authority
Product invariants: INV-CAP-1 (retain pendant audio/session), INV-UI-1, INV-UI-3 (existing settings controls), INV-PERF-1 (no blocking UI work added).
UI-Evidence: none -- Behavior-only settings handlers; no layout, copy or styling changes. Production-widget interaction tests cover the saves; headless rendering is supplementary and does not replace physical network testing.
Line-Count-Exception: app/lib/pages/settings/transcription_settings_page.dart | 1572 -> 1583 | Keep the key-edit handler at its existing page owner; credential reconciliation is extracted into the shared model helper.
Merge with current main (f4ddf9c → this head)
Merged origin/main (a87589a, which includes #22088 and #22078) into the branch; no rebase, no force-push.
app/lib/pages/settings/transcription_settings_page.dartimports. Both are kept: main'spages/on_device/on_device_settings_page.dart(used by its newOnDeviceSettingsEntryrow) and this PR'smodels/stt_request_credentials.dart(updateSttRequestApiKey).nativeEngineNoDownloadhelp text and adding the on-device entry, sits beside this PR's credential, probe-fencing and Advanced-section code without overlap.Verification on this head:
flutter testoverusage_provider_paywall_pin_test.dart,test/services/capture/(incl.transcription_settings_retention_test.dart),connectivity_service_test.dart,custom_stt_config_test.dart,stt_request_credentials_test.dart,surface_timer_after_dispose_test.dart,transcription_settings_recovery_test.dartandlocal_wal_sync_test.dart: 527 passed, 14 skipped, 0 failed.flutter testover main's on-device settings renders (on_device_overflow_test.dart,on_device_copy_render_test.dart,storefront_l10n_render_test.dart): 183 passed.flutter analyzeon the four touched lib files: no issues.git diff --check origin/main...HEAD: clean.bash test.shapp suite is left to CI on this head.Still unverified: physical Wi-Fi ↔ cellular handover. No device was used, so live transcription and Offline Sync through real handovers have not been exercised. Keep the customer incident open.