Skip to content

fix(app): skip legacy SD card sync on ring-buffer firmware and fail fast on ACK rejection (#24663) - #24820

Closed
cocvn157 wants to merge 1 commit into
BasedHardware:mainfrom
cocvn157:fix/sdcard-ring-buffer-firmware-phantom-sync-24663
Closed

cocvn157 wants to merge 1 commit into
BasedHardware:mainfrom
cocvn157:fix/sdcard-ring-buffer-firmware-phantom-sync-24663

Conversation

@cocvn157

@cocvn157 cocvn157 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Skip legacy SD-card listing (SDCardWalSync) and legacy storage commands (0/1) when connected to a ring-buffer firmware device (>= 3.0.20), while preserving cached SD recordings when the device detaches.

Root Cause

  1. On ring-buffer firmware (>= 3.0.20), storageReadControlCharacteristicUuid (0x30231002-...) returns the 16-byte ring status [used_bytes, unread_packets, free_bytes, rtc_valid] rather than legacy SD-card [totalBytes, storageOffset, listedStart]. When SDCardWalSync._getMissingWals() ran against a raw 'Unknown' connect object before firmware resolution, it could interpret used_bytes and unread_packets as a legacy fileNum: 1 SD-card recording (WalStorage.sdcard).
  2. OmiDeviceConnection.performWriteToStorage could still send legacy SD-card read/delete commands (command == 0 || command == 1) when the connection was initialized with a raw 'Unknown' firmware revision.

Changes

  • app/lib/services/wals/wal_syncs.dart & app/lib/services/wals/sdcard_wal_sync.dart:
    • Propagate resolved firmware version to _sdcardSync.setFirmwareVersion(...) in setDevice() and refreshWalsFromDevice(), while resetting _firmwareVersion on detach so cached legacy SD recordings stay visible when disconnected.
    • Gate _getMissingWals(), deleteWal(), syncAll(), and syncWal() on ring-buffer firmware (both via setFirmwareVersion / device.firmwareRevision and after getDeviceInfo / connection.lastRingInfo resolution when raw discovery firmwareRevision is 'Unknown').
  • app/lib/services/devices/connectors/omi_connection.dart:
    • Guard performWriteToStorage against sending legacy SD-card read/delete commands (command == 0 || command == 1) when connected to a ring-buffer device, resolving firmwareRevision from DIS when the connection object still holds 'Unknown'.
  • app/test/unit/sdcard_legacy_sync_test.dart:
    • Add unit test coverage for ring-buffer SD-card skip (including fallback lastRingInfo discovery on 'Unknown' devices) and OmiDeviceConnection.performWriteToStorage command 0/1 refusal on ring-buffer firmware.
  • app/changelog/unreleased/fix-sdcard-ring-buffer-phantom-sync-24663.json:
    • Add mobile changelog entry.

Product invariants affected

  • INV-CAP-1

UI-Evidence: none

Fixes #24663

@cocvn157
cocvn157 requested a review from mdmohsin7 as a code owner November 7, 2026 04:08

@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 6 files

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

View guided diff | Re-trigger cubic

@cocvn157
cocvn157 force-pushed the fix/sdcard-ring-buffer-firmware-phantom-sync-24663 branch from e311a43 to 3e44d22 Compare November 7, 2026 06:59
@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: this correctly implements the skip suggested in #24663 and I found no blocking issues; two follow-ups below.

Findings:

  • omi_connection.dart - the new guard in performWriteToStorage refuses legacy SD read/delete commands (0/1) when lastRingInfo is present or a DIS-resolved firmware says ring-buffer. _resolveFirmwareForStorageGuard fails open on a DIS read error, so legacy devices keep today's behavior, and _resolvedFirmwareRevision caching keeps the extra BLE read to at most once per connection. Nicely done.
  • sdcard_wal_sync.dart - _usesLegacySdcard now refuses when either _firmwareVersion or device.firmwareRevision reports ring firmware: the conservative direction. The post-getDeviceInfo skip in _getMissingWals covers exactly the raw-'Unknown' connect path from the issue; setDevice(null) resetting _firmwareVersion preserves cached recordings while detached; deleteWal on ring removes the phantom entry locally without sending a legacy opcode. The new StateError thrown by syncWal on ring firmware is safe: SyncProvider._performSync catches it and marks the WAL failed, same handling as the pre-existing read-rejection error.
  • wal_syncs.dart - propagating the resolved firmware in both setDevice (null on detach) and refreshWalsFromDevice is consistent with the impl-side reset.
  • sdcard_legacy_sync_test.dart - the two new tests reproduce the reported scenario (ring-status bytes as a listing, firmwareRevision 'Unknown') and assert no legacy command is sent. Good coverage.
  • Changelog fragment present and accurate.

Blast radius: if firmware detection ever misidentified a legacy-SD device as ring, its SD sync would be silently skipped; in practice both gates require a confirmed >= 3.0.20 revision and the DIS fallback fails open, so legacy devices are not at risk.

USER IMPACT: on ring-buffer firmware (3.0.20+), the app no longer queues a phantom "legacy SD" recording that could never download and was retried on every connect; ring storage sync itself is unchanged.

Follow-ups:

  1. No Dart test lane has run on this head yet (only the AI reviewer check). Please confirm flutter test test/unit/sdcard_legacy_sync_test.dart passes on your side, or ping a maintainer to approve the workflow run so the suite executes.
  2. Cosmetic: the title's "fail fast on ACK rejection" describes pre-existing behavior (_readRejectedStatus terminality); this PR's new work is the skip-before-send. A retitle would avoid confusion, purely optional.

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 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

iOS/app: legacy SD-card sync runs on ring-buffer firmware, lists a phantom recording from the ring status, and retries it forever

2 participants