Skip to content

fix(app): keep a Limitless recording's id when the pendant is listed again - #22417

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/limitless-stable-recording-id
Oct 19, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/limitless-stable-recording-id

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #22416

A Limitless pendant's flash backlog is listed on Offline Sync as one recording, and FlashPageWalSyncImpl._getMissingWals() estimated its start as now minus its duration every time it listed the pendant. The list is rebuilt on connect, on every transfer-coordinator pass while the app is in the foreground (and periodic or device-connected wakes in the background), and before and after each Sync pass. So the same recording's start time moved forward with the clock, and because Wal.id is <device>_<timerStart>, it got a new id each time. Whatever held it by id lost it: the recording's page (SyncProvider.getWalById) fell back to the copy it was opened with, deleteWal ignored it, and the Offline Sync row keys changed.

_getMissingWals() now reuses the timerStart of the listed recording with the same device and first page (storageOffset), so the start estimated at the first listing is kept for as long as the pendant reports the same first flash page. A transfer that stops part-way already moves the listed recording's storageOffset past the pages it saved and acknowledged, and keeps its timerStart, so the rest of the recording keeps its id too. A backlog with a different first page still gets a fresh estimate, and a disconnect still clears the list as before.

The listing's two device reads (_getStorageStatus and the device-info read) now use the existing testConnection seam, as _syncWal already does, so a unit test can drive the real listing. No production code sets testConnection.

#22370 (open) changes syncWal in the same file; the two diffs touch different lines.

Product invariants affected

  • INV-CAP-1: app/lib/services/wals/**. Only the listed recording's estimated start time and id change. What is read from the pendant, what is acknowledged, and when, are unchanged.

How it was verified

  • Traced the path on origin/main (c88d8b5):
    • flash_page_wal_sync.dart:178 sets timerStart to now minus estimatedSeconds on every listing, and wal.dart:269 builds id from it.
    • The list is rebuilt by setDevice (:808-821, called on connect from device_provider.dart:1096) and refreshWalsFromDevice (:217-228), which is called by the coordinator's discover pass (sync_provider.dart:544-548, run on every foreground pass at recording_transfer_coordinator.dart:351-353), by WalSyncs.syncAll before downloading flash pages (wal_syncs.dart:332) and by FlashPageWalSyncImpl.syncAll after each pass (:288).
    • Lookups by id: wal_item_detail_page.dart:140 and :494 (getWalById(widget.wal.id) ?? widget.wal), deleteWal (:140), and sync_page.dart:142 (Dismissible(key: Key(wal.id))).
    • _syncWal moves storageOffset in place after a cancel (:567) or a partial download (:684) and keeps timerStart, so the next listing matches it.
  • dart format --language-version=3.0 --line-length 120 made no changes to the two Dart files. The changelog fragment and the failure-class definition parse as JSON.
  • I did not run tests locally. CI with ci:full runs the new test and the full app suite. I wrote the test to fail without the fix: with only the timerStart line reverted, the second listing gets a different id.

Tests

app/test/unit/flash_page_wal_listing_test.dart (new) drives refreshWalsFromDevice() against a fake pendant that reports its flash pointers:

  • listing the same pendant backlog again keeps its recording id: lists the backlog, waits past a second boundary and lists it again: a new entry with the same id. Then the pendant reports more pages after the same first page: still the same id, with the longer duration.
  • a transfer that stopped part-way keeps the recording id when the pendant is listed again: moves the listed recording's first page as _syncWal does after a stall or cancel, and the pendant drops those pages: the rest keeps the id, with the new first page and duration.

UI evidence

UI-Evidence: none -- no layout change, and no simulator or device is available here. The Offline Sync rows and the recording page already show timerStart and look the recording up by id; the test checks the id, which is built from timerStart.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative (only when needed)

Adds FC-relisted-identity-derived-from-clock. Violated contract: a record that is rebuilt every time its source is listed again must keep the identity it was first listed with for as long as it is the same source. Here a Limitless backlog's Wal.id took its timerStart from the clock at listing time, so every re-read renamed it. Canonical guard: derive a relisted record's identity from what the source reports, or carry forward the identity from the first listing, and test it by listing the same source twice with the clock moved on (app/test/unit/flash_page_wal_listing_test.dart). No existing class fits: FC-import-unstable-identity is the same idea for backend imports, and the classes scoped to app/lib/services/wals/** cover drain stalls, deletes, wake cadence and durability, not listing identity. Evidence: this PR.

🤖 Generated with Claude Code

…again

FlashPageWalSyncImpl lists a Limitless pendant's flash backlog as one
recording and estimated its start as now minus its duration every time
it listed the pendant: on connect, on every discovery wake and after
every sync pass. Wal.id is device_timerStart, so the same recording got
a new id each time, and whatever held it by id lost it: the recording
details page (SyncProvider.getWalById) kept showing a stale copy, and
deleteWal ignored a delete for it.

Keep the start estimated when the backlog was listed for as long as it
still starts at the same page of the same pendant. A transfer that
stopped part-way moves the listed recording's start page in place, so
it keeps its id too. The two device reads of the listing now use the
existing testConnection seam, as _syncWal already does, so the test can
drive the real listing.

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, tightly scoped, and well tested.

  • app/lib/services/wals/flash_page_wal_sync.dart:182-183 — the core fix reuses the timerStart of the listed recording matching device + storageOffset == oldest_flash_page, so a relisted backlog keeps its device_timerStart-derived id. I traced both resume paths: a longer backlog with the same first page keeps the id and grows seconds/storageTotalBytes, and a partial transfer advances wal.storageOffset past acknowledged pages while keeping timerStart, so the remainder keeps its id too — both are asserted in the new tests.
  • The testConnection seam (lines 102, 185) mirrors the existing @VisibleForTesting pattern in storage_sync.dart / sdcard_wal_sync.dart / ring_storage_sync.dart; no production call site sets it.
  • app/test/unit/flash_page_wal_listing_test.dart — drives the real listing path via refreshWalsFromDevice with the clock moved on between listings, plus growth and partial-transfer-resume cases; hermetic (mock SharedPreferences, fake pendant).
  • .github/failure-classes/FC-relisted-identity-derived-from-clock.json — schema-valid, and the canonical prevention artifact points at the new test (scripts/test_failure_class.py passes with it).
  • app/changelog/unreleased/20261019-limitless-recording-start-time.json — matches the existing fragment format.

Performance: one in-memory list scan per listing — negligible. UX: Offline Sync rows stop churning on every reconnect/wake, and open/delete on a pending recording now target the right entry. Blast radius: Limitless pendants with >30 pending flash pages outside Transcribe Later mode.

USER IMPACT: A pending Limitless (Offline Sync) recording now keeps its start time and identity across reconnects and sync passes, so opening or deleting it works reliably instead of acting on a stale copy.

Non-blocking follow-ups I'd still want someday: id stability is session-scoped (_wals is in-memory, so an app restart still re-estimates from the clock — same as before this PR; persisting a first-page-to-timerStart mapping would be the next step if cross-launch stability matters), and nothing yet covers the relist-after-delete path.


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

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

Fixes a real bug (Limitless recording re-listed with a new id each pass, losing tombstone/delete tracking). Scoped diff, root cause explained, regression test added, CI green. Confidence 5/5.

@kodjima33
kodjima33 merged commit fa92ca5 into BasedHardware:main Oct 19, 2026
39 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limitless: an offline recording gets a new start time and id every time the app re-reads the pendant

3 participants