Skip to content

fix(app): rehydrate waiting recordings after app update and same-account sign-in (#24777) - #24845

Closed
cocvn157 wants to merge 2 commits into
BasedHardware:mainfrom
cocvn157:fix/rehydrate-waiting-recordings-after-signin-24777
Closed

cocvn157 wants to merge 2 commits into
BasedHardware:mainfrom
cocvn157:fix/rehydrate-waiting-recordings-after-signin-24777

Conversation

@cocvn157

@cocvn157 cocvn157 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #24777
/claim #24777

Addresses the issue where local waiting recordings ("Transcribe Later" / pending WALs) disappear from Home after an app update and subsequent sign-in to the same account.

Root Cause & Changes

  1. Singleton Ledger Rehydration After Signed-Out Cold Start or Re-Authentication (wal_account_purge.dart, local_wal_sync.dart, wal_interfaces.dart, wal_syncs.dart):

    • LocalWalSyncImpl, LocalRecordingsProvider, and SyncProvider are singletons created at app startup before OnboardingWrapper or AppShell completes authentication.
    • When the app cold-starts while signed out (or when the user signs out via clearUserData() and signs back in with the same account), _admitLoadedWals() parks account-stamped WALs in _foreignWals (or clearUserData() moves them to _retiredWals), and NativeRecordingIntake.scan() returns early while uid is empty.
    • Added _reconcileCurrentOwnerSync() and rehydrateForCurrentUser() so once the user is signed in, active (_wals), foreign (_foreignWals), and retired (_retiredWals) buckets are reconciled for the current account while foreign accounts' WALs remain isolated.
  2. Pre-Upgrade Unstamped Index Entries in Native Intake (native_recording_intake.dart, on_device_overflow_intake.dart, local_recordings_provider.dart):

    • Previously, when NativeRecordingIntake._scan() encountered a .bin file already indexed in wals.json from before the owner-stamping upgrade (existing != null with existing.ownerUid == null), it skipped owner resolution (continue;) and deleted omibatch_owners.json, while LocalRecordingsProvider._readLedger() skipped any WAL with wal.ownerUid == null.
    • Updated NativeRecordingIntake._scan() and intakeOnDeviceOverflow() to resolve and persist existing.ownerUid when existing.ownerUid == null || existing.ownerUid == 'legacy' before retiring omibatch_owners.json.
    • Updated LocalRecordingsProvider._readLedger() to guard against foreign owners while allowing non-batch legacy records when signed in.
  3. Post-Auth Provider Refresh & Sign-Out Preference Retention (wrapper.dart, app_shell.dart, home/page.dart, sign_out.dart):

    • Triggered LocalRecordingsProvider.refresh() and SyncProvider.refreshWals() on sign-in in OnboardingWrapper, AppShell._initializeProviders(), and HomePage.initState().
    • Retained batchAudioDir, localRecordingJobs, and localRecordingJobsCorrupt across clearPreferencesForSignOut() so un-migrated local recording job receipts on disk are not lost on sign-out.
  4. Tests & Changelog:

    • Added regression tests in app/test/unit/local_wal_sync_owner_uid_test.dart and app/test/unit/local_recordings_owner_test.dart.
    • Added mobile changelog fragment app/changelog/unreleased/20261107-rehydrate-waiting-recordings-after-signin.json.

Product invariants affected

  • INV-CAP-1

UI-Evidence: none -- Custody rehydration and provider refresh fix; no visual UI design changes.

View guided diff

@cocvn157
cocvn157 requested a review from mdmohsin7 as a code owner November 7, 2026 07:48

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 14 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread app/lib/pages/settings/sign_out.dart Resolved
Comment thread app/lib/core/app_shell.dart Resolved
@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: this is a correct, well-scoped fix for #24777 — waiting recordings reappear for the same account after an app update or sign-out/sign-in — and the root-cause analysis matches the code. Before merge it needs CI green on this head and a maintainer sign-off on the custody semantics (end of comment).

What I verified across the 14 files:

  • wal_account_purge.dart — _reconcileCurrentOwnerSync() moves foreign-owner WALs out of the active list and restores current-owner WALs from _foreignWals/_retiredWals, resetting in-flight sync state and deduping by (id, codec, seconds, totalFrames, filePath). Crucially, belongsToCurrent (owner == uid || null || 'legacy') exactly mirrors the existing _walAdmittedAtLoad admission rule in local_wal_sync.dart, so rehydration introduces no new cross-account exposure class.
  • local_wal_sync.dart — rehydrateForCurrentUser() runs after nativeIntake.scan(); getAllWals()/getMissingWals() now reconcile-and-persist first, which is what lets the already-constructed singletons pick up the signed-in user without an app restart. Persist only happens when something actually moved, so reads don't amplify writes.
  • native_recording_intake.dart — for pre-upgrade entries with ownerUid null or 'legacy', the scan now resolves and stamps the owner, and overflow entries with unresolved/undurable ownership set complete = false, so omibatch_owners.json is no longer deleted while ownership is still ambiguous. This is the core data-loss fix and it is right.
  • legacy_recording_owners.dart — unstamped + missing file now defers (returns null) instead of claiming the current uid, and a stamped-but-empty owner defers too. Safer than the old stamps[name] ?? uid.
  • local_recordings_provider.dart — the _readLedger filter follows the same ownership rules; deferred batch files (audio_omibatch*) stay hidden until intake resolves their owner, so an unresolved recording can't surface under the wrong account.
  • on_device_overflow_intake.dart — re-stamps existing unstamped overflow entries, with session-generation/uid re-checks after each await before persisting; race hygiene matches the surrounding code.
  • home/page.dart and wrapper.dart — the refresh hooks sit on the post-auth paths (post-frame callback after Home mounts; onboarding auth success), the right trigger points since the singleton providers exist by then; both are unawaited and mounted-guarded.
  • sign_out.dart — keeping batchAudioDir is required so re-login can still find pre-sign-out batch audio; it is a device-level path preference, not account data.
  • wal_interfaces.dart / wal_syncs.dart — pure interface plumbing for rehydrateForCurrentUser(), no behavior change.
  • changelog fragment — accurate user-facing description.
  • Both unit tests cover the real regression scenarios: cold-start signed out, same-account re-login, in-session sign-out/sign-in, and foreign-account WALs staying parked.

Notes:

  • Security/privacy: cross-account isolation is preserved — account-B WALs remain parked (local_wal_sync_owner_uid_test.dart asserts this). Legacy/unstamped WALs reattach to whichever account signs in, but that is the pre-existing load-admission semantics, not new behavior.
  • Performance: the reconcile is O(n) over in-memory lists on getAllWals(); no new I/O per call.
  • Blast radius: users on multi-account devices and anyone re-logging in after an app update. Wrong behavior here means invisible recordings or the wrong account's recordings surfacing; the guards look correct.

USER IMPACT: recordings waiting to be transcribed no longer vanish from Home after an app update or after signing back into the same account.

What I'd still want:

  1. CI has produced no check runs at all on this head at review time — please make sure the app unit lane runs and local_recordings_owner_test.dart / local_wal_sync_owner_uid_test.dart pass on CI.
  2. Minor: unawaited(syncProvider.initialized.then(...)) in home/page.dart has no error path; if initialized can complete with an error it would surface as an unhandled async error — a catchError guard would be tidier.
  3. A test where a different second account signs in and asserts the legacy/unstamped WALs reattach to it would make that pre-existing custody contract explicit.

Human maintainer sign-off needed before merge: this changes multi-account recording custody on the WAL ledger, and there is no CI evidence on this head yet.


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 positive-signal Automation verified a genuine fix/quality contribution needs-maintainer-review Needs a human maintainer to sign off before merge flutter flutter work labels Nov 7, 2026
@cocvn157 cocvn157 closed this Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Hey @cocvn157 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

sauranshbhardwaj pushed a commit to sauranshbhardwaj/omi that referenced this pull request Nov 13, 2026
Builds on the closed, unmerged BasedHardware#24845 and adds sign-out read fencing, retained job receipts and persistence verification.

Co-authored-by: cocvn157 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Waiting recordings disappear after app update and same-account sign-in

2 participants