Skip to content

fix(app): stop silently skipping SD card transfers after a reconnect - #22414

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/sdcard-transfer-after-reconnect
Oct 19, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/sdcard-transfer-after-reconnect

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #22412

On a device that uses the legacy SD card sync (firmware before 3.0.17), if the device disconnects and reconnects while an SD card recording's page is open, Transfer to Phone reads nothing from the card, then shows "Transfer complete! You can now play this recording." and closes the page. The audio is still only on the SD card.

SDCardWalSyncImpl.syncWal looked the recording up with ==, and Wal has no == override, so the lookup was by object. setDevice() rebuilds _wals with new Wal objects on every connect, while the page keeps the Wal it was opened with. After a reconnect the lookup found nothing and syncWal returned null. SyncProvider.transferWalToPhone ignores the result, and the page shows its success message whenever that call returns.

  • syncWal now matches by id and storage. deleteWal in the same class and the syncing-entry re-add in start()/setDevice() already match by id. The storage check keeps a phone copy of the recording, which can share its id, away from the SD card.
  • The download, the synced status and the final reset now use the listed entry (walToSync). Before, they used the caller's object while the progress fields used the listed one. That was harmless while the two were always the same object, but with an id match the listed entry would stay pending after the card was cleared.
  • A recording that is no longer listed now throws Device recording list changed; go back and try again, the wording fix(app): stop showing a failed Limitless transfer as complete #22370 uses for the same case on the Limitless sync. The page then shows "Transfer failed: …" instead of reporting a transfer that never happened. This covers a disconnected device (the list is empty). It also covers a listing whose start time is estimated: without a device timestamp (firmware before 3.0.16, or no known firmware version on the connect object), _getMissingWals sets timerStart to now minus the duration, so the same recording gets a new id on every connection and can't be matched. Going back and opening the refreshed recording transfers it.

sync_provider.dart and wal_item_detail_page.dart are unchanged: transferWalToPhone already rethrows, the page already shows transferFailedMessage for an error, and SyncProvider.syncWal (a row's Sync or Try again) already turns an error into its error state.

Issues #22306, #22363 and #22369 report the same "Transfer complete" symptom in the other device syncs, with fixes in PRs #22307, #22364 and #22370. The four PRs change different files. Until #22307 lands, multi-file recordings also reach this method, and they now show the failure instead of "Transfer complete".

Product invariants affected

  • INV-CAP-1: app/lib/services/wals/**. The SD card is still cleared only after a complete transfer whose chunks are durable on the phone. The change decides which listed recording is transferred; a recording that isn't listed, or a phone copy, never reaches the device.

How it was verified

  • Traced the path on origin/main (501f906; none of these files changed up to 64b082e):
    • wal_item_detail_page.dart:454-470: _handleTransferToPhone passes widget.wal, the object the page was opened with, and shows transferCompleteMessage and pops whenever transferWalToPhone returns.
    • sync_provider.dart:1177-1197: transferWalToPhone ignores what syncWal returns.
    • wal_syncs.dart:373-379 sends SD card recordings other than the ring's to SDCardWalSyncImpl.syncWal.
    • sdcard_wal_sync.dart:943-947 matched with == and returned null. setDevice (:1014-1024, called on connect from device_provider.dart:1095 and with null on disconnect from :930) and start (:232-241) replace _wals with new objects.
    • sdcard_wal_sync.dart:187-193 estimates timerStart from the clock when it doesn't use the device timestamp.
  • Checked that nothing else calls SDCardWalSyncImpl.syncWal and that no existing test relies on its null return.
  • dart format --language-version=3.0 --line-length 120 on the changed Dart files made no changes. mobile-changelog.py validate, check-mobile-changelog.py --base origin/main and check_mobile_ux_contract.py pass. validate_definition from scripts/failure-class accepts the new class, and its scope hint matches tracked files.
  • I did not run tests locally. CI with ci:full runs the new tests and the full app suite. I wrote both tests to fail on main, where syncWal returns null for an object it doesn't hold, without reading the card or throwing.

Tests

app/test/unit/sdcard_custody_sync_test.dart, using the file's existing fake SD card and fake local sync:

  • a recording opened before a reconnect still transfers the relisted recording: the sync's list is replaced with a new Wal for the same recording, as setDevice() does on reconnect, and syncWal gets the old object. The audio is saved on the phone, the card is cleared, and the listed entry ends synced and no longer syncing.
  • a recording the sync does not list fails the transfer and leaves the card untouched: a recording with another id and a phone copy with the same id both throw, and nothing is written to the card or saved.

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-wal-lookup-by-object-misses-rebuilt-list.

  • Violated contract: a per-recording action must find the recording by its id and storage in the owning sync's current list. Device syncs rebuild that list with new Wal objects on connect while a recording page keeps its own, so a lookup by object misses after a reconnect, and SDCardWalSyncImpl.syncWal reported the miss as a null that the caller reads as success.
  • Canonical guard: match by id and storage, as deleteWal does, act on the listed entry, and throw when the recording isn't listed. app/test/unit/sdcard_custody_sync_test.dart relists the recording before the transfer, and checks that an unlisted recording or a phone copy never touches the card.
  • Evidence: fix(app) prevent Bad state: No element crash in SD card WAL sync #6803 turned a .first crash on the unlisted case into the silent return null. fix(app): stop showing a failed Limitless transfer as complete #22370 (open) handles the unlisted case on the Limitless sync under FC-drain-stall-completes-silently, whose contract covers protocol stalls rather than this lookup. evidence_prs is empty because this PR is the first one filed under the class.

🤖 Generated with Claude Code

SDCardWalSyncImpl.syncWal looked the recording up by object in its list,
but setDevice() rebuilds that list with new Wal objects every time the
device connects. A recording page opened before a reconnect passes the
old object, so the lookup found nothing and syncWal returned null.
SyncProvider.transferWalToPhone treats any normal return as success, so
the page said "Transfer complete" and closed while the audio stayed on
the SD card.

syncWal now matches by id and storage, as deleteWal does, and runs the
transfer and its state changes on the listed entry, which is the one the
sync pages read. A recording that is no longer listed throws, so the
page shows "Transfer failed" instead of a transfer that never happened.
That includes a listing whose start time is estimated from the clock,
which gets a new id on every connection.

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.

Approving — the production change is correct and tightly scoped, and it converts a silent false-success into an explicit failure.

  • app/lib/services/wals/sdcard_wal_sync.dart — syncWal now resolves the target from _wals by id + storage instead of object identity. Wal has no == override, and setDevice()/start() rebuild _wals with new Wal objects on every connect, so a recording page opened before a reconnect held an object the old lookup could never find; syncWal then returned null and SyncProvider.transferWalToPhone treated the normal return as a completed transfer. The new resolution matches how deleteWal and the setDevice() syncing-re-add already identify wals. The not-found path now throws 'Device recording list changed; go back and try again', and the storage offset, synced status, and final reset consistently use the listed entry (walToSync). I verified both call paths handle the throw: transferWalToPhone (app/lib/providers/sync_provider.dart:1187) rethrows after resetting sync state and releasing the keepAlive, and the row-Sync path goes through _performSync, which surfaces the error state instead of a success.
  • app/test/unit/sdcard_custody_sync_test.dart — the two new tests cover exactly the two ends of the contract: a relisted recording (new object, same id) transfers and marks the listed entry synced, and an unlisted recording or a same-id phone copy throws with no card writes and no local adds. The storage discriminator is exercised by the phoneCopy case, which is the subtle half.
  • .github/failure-classes/FC-wal-lookup-by-object-misses-rebuilt-list.json — accurate contract write-up that matches the code and points at the new tests as the prevention artifact.
  • app/changelog/unreleased/20261019-sd-card-transfer-after-reconnect.json — right user-facing wording for the fixed behavior.

Non-blocking follow-up: ring_storage_sync.dart syncWal (the fileNum == -1 branch of the same dispatcher in wal_syncs.dart) still catches errors, logs, and returns an empty response — the same false-success shape this PR removes on the SD card path. Pre-existing and on a separate storage surface, so better as its own issue/PR than an expansion here.

USER IMPACT: After the device reconnects, Transfer to Phone on an SD card recording actually moves the audio; if the recording is no longer listed, the user now sees a transfer failure instead of a 'Transfer complete' message for a transfer that never happened.

What I'd still want as a reviewer: nothing blocking for this diff; the ring-storage follow-up above is the one open thread.

Automated maintainer review on the maintainers' behalf; the merge decision remains human.


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 flutter flutter work positive-signal Automation verified a genuine fix/quality contribution labels Oct 19, 2026

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

Confirmed bug (SD card transfer silently no-ops after reconnect because lookup used object identity instead of id+storage match, fixes #22412); scoped fix + regression tests, CI green, CLEAN.

@kodjima33
kodjima33 merged commit 17ea5b5 into BasedHardware:main Oct 19, 2026
42 of 43 checks passed
kodjima33 pushed a commit that referenced this pull request Oct 21, 2026
…pendant is listed again (#22895)

FlashPageWalSyncImpl.syncWal looked the recording up by object in its list.
That list is rebuilt with new Wal objects when the pendant connects, on
every discovery wake and after each sync pass, while the recording page
keeps the Wal it was opened with. Since #22417 the relisted recording keeps
its id, but the lookup by object still found nothing, so Transfer to Phone
failed with "Device recording list changed; go back and try again" for a
recording that was still listed.

Match by id and storage, as deleteWal and the SD card sync (#22414) do, and
run the transfer on the listed entry. A recording that is no longer listed
still fails without asking the pendant for audio.
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 positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transfer to Phone on an SD card recording says 'Transfer complete' without transferring after the device reconnects

3 participants