Skip to content

fix(app): stop reporting a failed ring transfer to phone as complete - #22364

Merged
undivisible merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/ring-transfer-to-phone-failure
Oct 19, 2026
Merged

undivisible merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/ring-transfer-to-phone-failure

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #22363

On an Omi with firmware 3.0.20 or later (the ring-buffer storage protocol), pressing "Transfer to Phone" on a device recording shows "Transfer complete! You can now play this recording." and closes the page even when the transfer did not finish: the device ended the read with an error, the read went idle, the BLE link dropped, phone storage refused the audio, or the device refused the advance. The unread audio is still on the pendant and the recording is still listed as on the device, but nothing says the transfer failed.

WalSyncs.syncWal sends the ring's recording (fileNum == -1) to RingStorageSyncImpl.syncWal. When _syncRing returned false, that method skipped marking the recording synced but still reported 100% progress and returned the same empty SyncLocalFilesResponse as a finished transfer. Its catch also swallowed every exception from the transfer (no connection, a failed INFO or status read, a listener that could not be set up). SyncProvider.transferWalToPhone treats any normal return as success, and WalItemDetailPage._handleTransferToPhone then shows transferCompleteMessage and pops.

  • RingStorageSyncImpl.syncWal marks the recording synced and reports 100% only after a complete transfer. An incomplete transfer throws Device transfer incomplete; recording kept on device, and transfer errors are rethrown after the existing debug log, the way SDCardWalSyncImpl.syncWal already rethrows. The page shows "Transfer failed: …" through its existing error path.
  • listener.onWalUpdated() moved into finally, so listeners also hear about a failed transfer, after the download fraction is cleared.
  • The device side is unchanged: _syncRing still advances the ring only after a validated DONE whose records are durable on the phone, and an incomplete transfer keeps the unadvanced records for the next sync, as syncAll does. Audio that already arrived stays saved on the phone.

A cancelled transfer also throws now, as on the SD card path. The page's Cancel button shows "Transfer cancelled" and closes the page before the transfer ends, so no error appears there.

#22306 (open fix: #22307) has the same symptom on firmware 3.0.17 to 3.0.19, where the recording reached the wrong sync. Here the right sync drops its own result. The two PRs change different files.

Product invariants affected

  • INV-CAP-1: app/lib/services/wals/**. The ring is still advanced only for records that are durable on the phone, and an incomplete transfer keeps the rest on the device for the next sync. Only what the caller is told changes.

How it was verified

  • Traced the path on origin/main (9f6da67):
    • wal_item_detail_page.dart:454-470 shows transferCompleteMessage whenever transferWalToPhone returns, and transferFailedMessage when it throws.
    • sync_provider.dart:1177-1197 ignores the return value of syncWal and rethrows errors.
    • wal_syncs.dart:373-377 sends fileNum == -1 recordings to the ring sync.
    • ring_storage_sync.dart:373-394 returned an empty success when _syncRing returned false or threw.
  • Checked every return path of _syncRing: it returns true only after a successful advance or when the ring has nothing unread, which stays a success. Both callers of WalSyncs.syncWal handle a throw: transferWalToPhone rethrows to the page, and SyncProvider.syncWal sets its existing error state in _performSync.
  • Checked that the twelve existing tests that end a ring syncWal transfer incomplete now expect the throw, and that the tests for complete transfers still await normally.
  • dart format --language-version=3.0 --line-length 120 with the pinned Flutter SDK on the changed Dart files made no changes. .github/scripts/mobile-changelog.py validate passes. validate_definition from scripts/failure-class accepts the new class, and each of its scope hints matches a tracked file.
  • I did not run tests locally. CI with ci:full runs the new tests and the full app suite. I wrote the two new tests to fail on main, where syncWal returns an empty success in both cases.

Tests

app/test/unit/ring_storage_sync_no_advance_test.dart has two new tests. They call WalSyncs.syncWal, the entry point Transfer to Phone uses, with the ring's recording (fileNum: -1) and the file's existing fake device and local sync:

  • WalSyncs.syncWal fails a ring transfer that the device ends with an error: DONE carries an error status. The call throws, no advance is sent, the recording stays pending and the audio that arrived is saved on the phone.
  • WalSyncs.syncWal rethrows a ring transfer error instead of returning an empty success: the status read fails. The same error reaches the caller and no read command is sent.

The existing tests in that file and in app/test/unit/ring_custody_download_test.dart that end a syncWal transfer incomplete (idle timeout, failed read command, READ_BEGIN or DONE mismatch, DONE error, index save failure, reconnect, stale or mismatched ACK) now also expect the call to throw. The tests for complete transfers still expect it to return and mark the recording synced.

UI evidence

UI-Evidence: none -- no layout change: the page reuses its existing "Transfer failed" message, and no simulator or device is available here. The tests above cover the service result the page reads.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative

New class FC-device-transfer-failure-reported-as-complete.

  • Violated contract: a per-recording device-to-phone transfer must tell its caller when it did not finish. RingStorageSyncImpl.syncWal ignored _syncRing's result and caught every exception, so Transfer to Phone reported success.
  • Canonical guard: syncWal marks the recording synced only after a complete transfer and otherwise throws, rethrowing transfer errors, as SDCardWalSyncImpl.syncWal does. ring_storage_sync_no_advance_test.dart drives this through WalSyncs.syncWal, and both ring test files assert the throw for each incomplete outcome. The scope hints also cover the other sub-syncs' syncWal, which have the same contract.
  • Evidence: the method came in with feat(app): support ring-buffer offline sync for fw 3.0.20+ #7218, which made it mark a complete transfer synced but kept returning success for an incomplete one. fix(app): transfer multi-file device recordings to the phone #22307 (open) adds FC-per-wal-sync-routed-to-non-owner for the routing cause on the multi-file path; this class covers a sync that drops its own result. evidence_prs is empty because this PR is the first one filed under the class.

🤖 Generated with Claude Code

RingStorageSyncImpl.syncWal, which Transfer to Phone uses for recordings
on firmware 3.0.20 and later, ignored _syncRing's completion result and
caught every exception, returning the same empty response either way.
SyncProvider.transferWalToPhone treats any normal return as success, so a
transfer that the device ended with an error, that went idle, lost its
connection or was refused phone storage showed "Transfer complete" while
the unread audio stayed on the pendant.

syncWal now marks the recording synced only after a complete transfer and
otherwise throws, and it rethrows transfer errors as
SDCardWalSyncImpl.syncWal does, so the page shows "Transfer failed".
Unadvanced records stay on the device as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@apoorvdarshan apoorvdarshan added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The production change here is correct and nicely scoped — approving.

  • app/lib/services/wals/ring_storage_sync.dart — syncWal now marks WalStatus.synced and reports 100% progress only after _syncRing completes; an incomplete transfer throws before any success signal, and the catch rethrows after the debug log, matching how SDCardWalSyncImpl.syncWal already behaves. Moving listener.onWalUpdated() into finally means listeners also hear about failed transfers — verified it still fires exactly once on success and once on failure.
  • Caller safety — I checked every caller of the changed path: SyncProvider.transferWalToPhone (sync_provider.dart:1177) catches, refreshes, and rethrows; _performSync routes the error to SyncStatus.error; WalItemDetailPage._handleTransferToPhone then shows the existing transferFailedMessage. "Transfer complete!" can no longer appear for a transfer that did not finish.
  • Device side unchanged — _syncRing still advances the ring only after a validated DONE, so an incomplete transfer keeps the unread records on the pendant for the next sync, exactly as syncAll does.
  • app/test/unit/ring_storage_sync_no_advance_test.dart — two new tests drive the real Transfer-to-Phone entry point (WalSyncs.syncWal, fileNum -1) and assert the incomplete-DONE and GATT-error outcomes throw while WalStatus stays miss, no advance happens, and audio that already arrived stays saved; six existing expectations updated to match the new contract, including a receivedDone ? completes : throwsException split. app/test/unit/ring_custody_download_test.dart — three expectations tightened to throwsException. All green on this head (Dart Analyze & Tests, Android JVM Unit Tests, Android Emulator Acceptance).
  • .github/failure-classes/FC-device-transfer-failure-reported-as-complete.json follows the existing schema, describes this exact contract accurately, and points at the new tests as prevention artifacts. app/changelog/unreleased/20261019-ring-transfer-failure.json is user-facing and accurate.
  • Security: no new inputs, permissions, or data flows; blast radius is the Transfer-to-Phone flow for firmware 3.0.20+ ring recordings, where the previous behavior silently misrepresented data loss as success.

USER IMPACT: "Transfer to Phone" now tells you the transfer failed and keeps the recording listed as on the device when it doesn't finish, instead of showing "Transfer complete!" while your audio stays on the pendant.

Nothing blocking. If the phone-storage-refused path is reachable in the fake harness, a test for it would be a nice follow-up.


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 the flutter flutter work label Oct 19, 2026
@undivisible
undivisible merged commit abbbf8e into BasedHardware:main Oct 19, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR flutter flutter work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transfer to Phone on firmware 3.0.20+ reports 'Transfer complete' when the ring transfer fails

3 participants