Skip to content

fix(app): transfer multi-file device recordings to the phone - #22307

Merged
kodjima33 merged 3 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/storage-sync-transfer-to-phone
Oct 19, 2026
Merged

kodjima33 merged 3 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/storage-sync-transfer-to-phone

Conversation

@apoorvdarshan

@apoorvdarshan apoorvdarshan commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #22306

On Omi firmware 3.0.17 to 3.0.19 (the multi-file storage protocol), pressing "Transfer to Phone" on a device recording reads nothing from the device, then shows "Transfer complete! You can now play this recording." and closes the page. The recording is still only on the pendant.

StorageSyncImpl lists these recordings as WalStorage.sdcard with a 0-based fileNum. WalSyncs.syncWal sent every sdcard recording except the ring's (fileNum == -1) to SDCardWalSyncImpl.syncWal. That method looks the recording up by identity in its own list and returns null when it isn't there, and a StorageSync recording never is. SyncProvider.transferWalToPhone treats the null as success. #6656 reported this path on 3.0.17 as a Bad state: No element crash, and #6803 turned the crash into today's silent return null. a1f18aa (#7218) fixed the same misroute for ring recordings only.

  • WalSyncs.syncWal now sends a recording that StorageSyncImpl listed to StorageSyncImpl.syncWal, through a new owns check. It matches by identity, the same rule as the SD card sync's own lookup. Ring and legacy SD card routing are unchanged.
  • StorageSyncImpl.syncWal was unreachable until now. It also dropped _syncSingleFile's completion result and swallowed errors. With the routing fix alone, a transfer would never be marked synced or removed from the device, so the next drain would download and upload the same audio again. It now:
    • marks the recording synced, then deletes the device file only after a complete, durable transfer. It uses the same same-source and connection-epoch guarded delete as syncAll, moved into _deleteTransferredFile (which now also returns whether the device deleted the file), and re-indexes the other listed files;
    • drops the recording from StorageSync's list once the device confirms the delete. The firmware moves the next file into that index, so leaving it listed would let a later "Clear synced" (deleteAllSyncedWals) delete a recording that was never transferred. syncAll still keeps synced recordings listed; that is a separate fix;
    • throws when the transfer is incomplete, so the page shows "Transfer failed". Whatever arrived stays saved on the phone and the file stays on the device, as with an interrupted syncAll;
    • sets wal.isSyncing while the transfer runs, so the page shows progress and Cancel, and passes progress through;
    • refuses to start while a device drain is reading, instead of resetting that drain's state. The page still offers the button during a drain, because syncAll never sets isSyncing.

sync_provider.dart and wal_item_detail_page.dart are unchanged: transferWalToPhone already rethrows, and the page already shows transferFailedMessage for an error.

Product invariants affected

  • INV-CAP-1: app/lib/services/wals/**. The device file is still deleted only after the audio is durably registered on the phone, through the same guarded delete as syncAll. An incomplete transfer keeps the file on the device.

How it was verified

  • Traced the path on origin/main (def12bf):
    • storage_sync.dart:214-229 builds the device recordings with fileNum: file.index, which is 0-based (omi_connection.dart:559).
    • wal_syncs.dart:373-379 sends them to SDCardWalSyncImpl.syncWal.
    • sdcard_wal_sync.dart:942-946 returns null for a recording it does not list. Wal has no == override, so this is an identity check.
    • sync_provider.dart:1177-1197 ignores the null, and wal_item_detail_page.dart:454-463 shows transferCompleteMessage and pops.
  • Checked that nothing else calls StorageSyncImpl.syncWal, and that isStorageSyncing (wal_syncs.dart:404) covers the new per-recording transfer, so drains back off while it runs.
  • dart format --line-length 120 on the changed Dart files made no changes. Checked the new failure-class file with validate_definition from scripts/failure-class.
  • I did not run tests locally. CI with ci:full runs the new tests and the full app suite. I wrote the new tests to fail without the fix: on main the call reaches SDCardWalSyncImpl.syncWal, which returns null with no device read, no deletion and no error.

Tests

app/test/unit/legacy_storage_limitless_seam_test.dart drives WalSyncs.syncWal with the file's existing fake device and fake local sync:

  • WalSyncs.syncWal transfers a listed multi-file recording and then deletes it on the device: one CMD_READ_FILE for file 1 and one durable phone chunk. The status becomes synced, isSyncing is cleared, file 1 is deleted, and the next file is re-indexed from 2 to 1. A following deleteAllSyncedWals sends no second delete, and the next recording stays listed.
  • WalSyncs.syncWal fails an incomplete multi-file transfer and keeps the file on the device: the call throws, nothing is deleted, and the status stays miss.
  • WalSyncs.syncWal refuses a multi-file recording while a device drain is running: the per-recording call throws while syncAll is saving. The drain keeps the only read and finishes normally.

The existing syncAll tests in the same file cover the moved delete, including delete only happens after the chunk is durably registered and a device switch during persistence never issues DELETE on either connection.

UI evidence

UI-Evidence: none -- no layout change: the page reuses its existing transfer progress, success and failure states, and no simulator or device is available here. The tests above cover the service path the page reads.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative

New class FC-per-wal-sync-routed-to-non-owner.

🤖 Generated with Claude Code

On firmware 3.0.17-3.0.19 the device recordings come from StorageSync and
use WalStorage.sdcard, but WalSyncs.syncWal sent every sdcard recording
except the ring's to the legacy SD card sync. That sync returns null for a
recording it does not list, so Transfer to Phone read nothing from the
device and the page still said the transfer was complete.

Route recordings that StorageSync listed to StorageSyncImpl.syncWal. That
method was unreachable and also dropped the transfer's completion result.
It now marks the recording synced and deletes the device file only after a
complete, durable transfer, using the guarded delete from syncAll (moved
into a shared helper). It throws when the transfer is incomplete, shows the
recording as transferring while it runs, and refuses to start while a
device drain is already reading.

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
apoorvdarshan and others added 2 commits October 19, 2026 07:44
Co-Authored-By: Claude Opus 5.5 <[email protected]>
After a per-recording transfer deletes the file, the firmware moves the next
file into its index. Keeping the synced recording listed under that index
let a later "Clear synced" (deleteAllSyncedWals) send CMD_DELETE_FILE for
it and delete a recording that was never transferred.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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.

Mobile bug fix for device-recording transfer, root cause stated, linked issue, CI green. Confidence 4-5/5.

@kodjima33
kodjima33 merged commit 32a0bdd 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transfer to Phone on firmware 3.0.17-3.0.19 reads nothing and reports 'Transfer complete'

2 participants