Skip to content

fix(app): show ring transfers as running in the recording page - #22790

Merged
undivisible merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/ring-transfer-syncing-state
Oct 22, 2026
Merged

undivisible merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/ring-transfer-syncing-state

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #22789.

RingStorageSync.syncWal read the ring without setting wal.isSyncing, syncStartedAt, or syncMethod. The recording detail page renders Transfer to Phone until isSyncing is true, and only then shows progress, speed, ETA, and a Cancel button. During a ring transfer the page therefore looked idle, and the transfer could not be cancelled from it.

syncAll had no per-recording UI state either, but this change covers the explicit Transfer to Phone path. syncWal now marks the recording the sync UI reads (matched by storage and id, so a page opened before a relist still sees the update), sets the start time, publishes speed and ETA with progress, and clears every marker in finally on success or failure.

Product invariants affected

INV-CAP-1

The path glob matches app/lib/services/wals/**. This change does not drop pendant audio. It only publishes transfer state so the user can see and cancel a ring transfer.

How it was verified

  • Traced on current origin/main (31a07230bb): RingStorageSyncImpl.syncWal sets only the private _isSyncing, while SDCardWalSyncImpl.syncWal also sets isSyncing, syncStartedAt, syncMethod, syncSpeedKBps, and syncEtaSeconds on the matched Wal.
  • app/lib/pages/conversations/wal_item_detail/wal_item_detail_page.dart reads currentWal.isSyncing for the Cancel button and syncSpeedKBps/syncEtaSeconds for progress.
  • No open issue or PR covers this state.
  • dart format --language-version=3.0 --line-length 120 on the changed Dart files. The regression tests run in Omi CI (flutter test) with ci:full. They have not been run locally.

Tests

app/test/unit/ring_storage_sync_no_advance_test.dart:

  • a transfer marks the listed recording as syncing for the whole read: starts a transfer from a stale Wal instance with the same id and storage, asserts the listed instance is syncing with a start time while the read is in flight, and asserts it is synced with every transfer marker cleared afterwards. On main the listed instance never becomes syncing, so the first assertion fails.
  • The existing read-failure test now also asserts the recording is not left syncing.

UI evidence

UI-Evidence: none -- state publication fix; the regression test covers the fields the page renders. The running app was not exercised locally.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative

New class FC-device-transfer-state-unpublished.

  • Violated contract: a device transfer must publish its running state on the recording the sync UI reads.
  • Canonical guard: syncWal marks the listed recording before reading and clears it in finally; the regression test asserts both edges.
  • Evidence: RingStorageSyncImpl.syncWal on origin/main before this change set no Wal field. evidence_prs is empty because this PR is the first instance.

🤖 Generated with Claude Code

RingStorageSync.syncWal read the device without marking the recording as
syncing, so the detail page kept showing Transfer to Phone with no progress
or Cancel while bytes were arriving. It also looked the recording up nowhere,
leaving a page opened before a relist with an instance the UI never updates.
The listed instance is now marked for the read and cleared in finally.

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 20, 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 — this fixes the reported bug with a regression test and matches the pattern already proven in the SD-card sync path.

Verified per file:

  • app/lib/services/wals/ring_storage_sync.dart — syncWal now resolves the listed instance (_wals.where((w) => w.storage == wal.storage && w.id == wal.id).firstOrNull ?? wal) exactly like SDCardWalSyncImpl.syncWal (sdcard_wal_sync.dart:940-960), sets isSyncing/syncStartedAt/syncMethod before the read, and clears every marker in finally on success and failure — so the recording page (wal_item_detail_page.dart:140-146, 494) now sees progress, speed, ETA, and the Cancel button during a ring transfer, and can never get stuck on a stale marker after an error. The added speed/ETA/listener.onWalUpdated() lines in the throttled progress block sit under the same guards (storageTotalBytes > 0, throttled interval) that already gated deviceDownloadFraction, and the remaining-bytes ETA formula matches the SD-card implementation. Two consciously-checked details: the syncMethod = SyncMethod.ble in finally is a no-op reset (it equals Wal's default, wal.dart:209, and matches sdcard_wal_sync.dart:1012), and the finally covers the incomplete-transfer throw path too.
  • app/test/unit/ring_storage_sync_no_advance_test.dart — the new test genuinely reproduces the bug's shape: it calls syncWal with a stale Wal copy while asserting the LISTED instance flips isSyncing during the read and that all markers clear after; assertions were also added to an existing error-path test. Good coverage of the actual failure mode (page holding a pre-relist instance).
  • .github/failure-classes/FC-device-transfer-state-unpublished.json — follows the existing failure-class schema and points canonical_prevention at the new test.
  • app/changelog/unreleased/20261020-ring-transfer-syncing-state.json — user-facing changelog fragment in the established format.

The syncAll path still publishes no per-recording state (acknowledged in the PR description; out of scope here).

USER IMPACT: During a ring recording transfer, the recording page now shows live progress, speed, and ETA with a working Cancel button, instead of an idle 'Transfer to Phone' button while the transfer quietly runs.

What I'd still want as a reviewer: nothing blocking. If you follow up on syncAll, the same listed-instance marker treatment would be the natural next step.

@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 — this is correct and tightly scoped, and it mirrors the state publishing the SD-card syncWal already does.

Verified per file:

  • app/lib/services/wals/ring_storage_sync.dart — syncWal now resolves the listed instance (storage+id match, so a recording page opened before setDevice() rebuilt _wals still sees updates), sets isSyncing/syncStartedAt/syncMethod before the read, and the _syncRing progress block publishes syncSpeedKBps/syncEtaSeconds with onWalUpdated() — exactly what wal_item_detail_page.dart reads (lines 141–144, 495) for progress and the Cancel button. finally clears every marker on both success and failure, matching SDCardWalSyncImpl.syncWal. The ?? wal fallback (vs sdcard's throw when unlisted) is safe here since _syncRing doesn't depend on listed-instance state.
  • app/test/unit/ring_storage_sync_no_advance_test.dart — the new regression test drives a stale Wal instance through the real fake-device read path, asserts syncing-during-read and markers-cleared-after, and marker-clear asserts were added to the existing incomplete-transfer case.
  • .github/failure-classes/FC-device-transfer-state-unpublished.json — validated clean against scripts/failure-class (declaration new, artifact path exists).
  • app/changelog/unreleased/20261020-ring-transfer-syncing-state.json — accurate user-facing description.

One nit, no action needed: resetting syncMethod to ble in finally is a no-op since it's never changed off ble (sdcard does the same).

USER IMPACT: during a ring "Transfer to Phone", the recording page now shows live progress, speed, ETA, and a working Cancel button instead of looking idle.

Optional follow-up (non-blocking): a test that cancels mid-transfer from the detail-page path and asserts the markers clear.


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 20, 2026
@undivisible
undivisible merged commit 18558ea into BasedHardware:main Oct 22, 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.

Ring transfer shows Transfer to Phone with no progress while it is running

3 participants