Skip to content

fix: make sync backlog and Bluetooth drop counts truthful - #25582

Merged
Git-on-my-level merged 9 commits into
mainfrom
lane/sync-display-truth
Nov 17, 2026
Merged

Git-on-my-level merged 9 commits into
mainfrom
lane/sync-display-truth

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fix the conflicting pending-audio amounts and disconnect diagnostics. One pending WAL display view applies the existing stale-handle deadline and device-copy folding across On the Way, Sync details, Offline Sync and the device Catching up contribution. Server-reported work has a separate On the Way section. Uploaded audio is labelled "Uploaded, awaiting server" rather than inferred to be transcribing.

Expired upload handles show "Transcription unavailable" in both Offline Sync implementations, with a direct details route that remains reachable from Device Settings even when nothing active remains. The provider schedules an expiry notification for mounted screens and cancels it on disposal. This includes over-window captures, while preserving every WAL status, file, retry and audio custody decision. Recent server confirmation can restore the pending display. The banner keeps its documented active-run progress snapshot.

Diagnostics count every non-manual disconnect within the retained window, including rows without a reconnect time or a native window anchor. UI and export share the window predicate, including the future-row exclusion; lifetime reconnections remain separate. Reconnect latency excludes manual, failed-connect and audio-recovery events. iOS reads the disconnect clock once and both platforms persist the event timestamp separately from audio-outage accounting and retain connection history across restart. Lifetime history is correctly labelled reconnections. The bounded seven-day native ring grows from 500 to 4096 rows. Dated synthetic macOS serialization evidence is in app/docs/evidence/2026-11-17-sync-ring-serialization.json; phone event-loop latency is not measured.

Failure-Class: FC-same-subject-counted-once-per-evidence-source
UI-Evidence: .agent-artifacts/ui-evidence/sync-display-truth/evidence.json

Product invariants affected

  • INV-CAP-1: derived display expiry never mutates WAL/audio custody or deletion rights.
  • INV-UI-1: shared neutral UI primitives and existing attention styling.
  • INV-UI-3: existing settings groups, rows, sheet and navigation primitives.
  • INV-PERF-1: pending inventory is memoized with mutation and deadline invalidation.

Validation

Local verification: the 186-test/17-file focused suite passed at the full product-review head; the final follow-up passes 46 tests across four files. Analyzer is clean on the latest four affected Dart files and the two fixture files. The render tests, 10-test expiry rollback run, native Swift harnesses, localization check, and 17 Android diagnostics tests pass. The final Android key-retirement rerun reports zero failures/errors/skips.

  • Failing-first: focused regressions run with original production Dart files at 695bf22. Stale pending inventory, over-window upload presentation and unrecovered drop expectations fail; the same focused tests pass with the fix.
  • omi-heavy run -- flutter analyze --no-pub <touched Dart files>: clean.
  • omi-heavy run -- dart format -l 120 <touched Dart files>.
  • omi-heavy run -- flutter test --no-pub --timeout 90s test/unit/wal_derived_views_test.dart test/unit/catch_up_seconds_test.dart test/widgets/on_the_way_days_test.dart test/widgets/device_diagnostics_window_test.dart test/widgets/device_catching_up_test.dart test/widgets/sync_completion_truth_test.dart.
  • omi-heavy run -- flutter test --no-pub test/widgets/home_pending_row_test.dart test/pages/conversations/offline_sync_recording_blocks_test.dart test/widgets/offline_sync_storage_contrast_test.dart test/widgets/sync_edge_throttle_render_test.dart.
  • omi-heavy run -- flutter test --no-pub --dart-define=OMI_CATCH_UP_STALE_HANDLE_OFF=true test/unit/catch_up_seconds_test.dart: rollback behavior.
  • omi-heavy run -- flutter test --no-pub --timeout 90s --dart-define=OMI_SYNC_UI_EVIDENCE_DIR=../.agent-artifacts/ui-evidence/sync-display-truth test/widgets/sync_display_truth_render_test.dart: real widgets, SF Pro fonts, iOS metrics, synthetic data; screenshots visually inspected.
  • omi-heavy run -- ruby app/ios/test/device_health_store_test.rb: compiled Swift assertions exercise persisted connection history, the row timestamp differing from the audio marker, exact backfill and retirement. omi-heavy run -- ruby app/ios/test/omi_ble_energy_policy_test.rb: 6 runs, 12 assertions, zero failures. No Xcode unit-test target is present in app/ios/Runner.xcodeproj/project.pbxproj; these regressions use the existing Ruby-to-swiftc native test harnesses.
  • omi-heavy run -- <cached Gradle 8.14.2>/bin/gradle -p app/android :app:testDevDebugUnitTest --tests '*DeviceDiagnosticsContractTest' --tests '*FeedbackDiagnosticsServiceParityTest': BUILD SUCCESSFUL; 17 tests, zero failures/skips. The fresh worktree has no gradlew, so this uses the cached exact version in gradle-wrapper.properties. The corrected consent-scope tests were rerun with --no-daemon: BUILD SUCCESSFUL.
  • python3 app/scripts/l10n.py check: all locale translations and generated freshness checked through the app localization workflow.
  • OMI_PR_BODY_FILE=/tmp/lane-g-body.md omi-heavy run -- make preflight: 38 selected checks passed. The normal bounded pre-push gate also passed on the pushed head, including formatting and generated localization output.
  • omi-heavy run -- flutter test --no-pub test/unit/offline_processing_display_test.dart test/providers/sync_provider_derived_views_test.dart test/perf/sync_indicator_isolation_test.dart test/pages/conversations/sync_attention_evidence_test.dart: 27 tests passed. Active upload fixtures explicitly stamp uploadedAt; stale unstamped handles are covered separately.

Scope and remaining limits

Re-read PR #25500's current diff without modifying it or its branch. Overlap is limited to localization ARBs and generated localizations; only the stage label, lifetime footer and one server-work section label change there. No backend source changed. No production account data was read or changed. GCP tier: none.

Backend follow-up: pending_conversations has no general capture-age bound; the optional Home projection applies separate deadlines. Server-only rows can still be old until the backend owner settles them. Existing lost lifetime reconnects/evicted rows cannot be reconstructed, and event storms beyond 4096 retained rows can still truncate the week. The first three-member panel review at 5e1763c returned 19 findings; all were accepted and triaged with omi-panel, and the corrections are included for re-review. This PR establishes local automated and render evidence; physical iOS/Android pendant acceptance and production telemetry reconciliation remain unverified.

Render evidence

Synthetic widget captures use SF Pro and iOS metrics. In the Device Settings capture, the widget engine leaves the device illustration area blank; the changed details row is visible.

On the Way

Sync details

Offline Sync

Stalled upload details

Review disposition

Correction panel review-20261117t090048-8c0b: Luna, DeepSeek and GLM Flash all returned SHIP at c5b499af466f02e0a104fd777731a8fc6edb64c0; no blocking findings. Every finding was triaged through omi-panel triage. The stale-body statement identified in the review packet has been removed from this PR body.

Nonblocking follow-ups remain: the legacy zero-duration stage label; upper bounds for future-dated failed-connection verdict rows; test-only mixed-clock API consistency; one iOS test assertion and one stale field comment. The support bundle retains the legacy reconnection_count_window name while its value follows the window's drop predicate; lifetime reconnection_count is a separate reconnect counter. Phone-side ring latency remains an explicit qualification gap. The suggestion to add uncertain server durations back into the WAL tile was rejected because this lane requires one WAL amount and separately labelled server work.

Final validation target: f2a34d8f3a4c7a198cedd8bbbf736d1651d3c75d. Ready recordings retain their primary Sync action when expired uploads coexist; the stale rows remain visible and unchanged in custody. Both new regressions fail before the banner reorder and pass afterward. Android identity retirement now directly asserts deletion of both persisted keys. Support export tests pin null window anchors while counting retained unrecovered drops. The original uploadedAt and Home Transcript fixture corrections remain minimal.

Follow-up commands: omi-heavy run -- flutter test --no-pub test/widgets/sync_completion_truth_test.dart test/widgets/device_diagnostics_send_support_test.dart test/widgets/home_row_contract_render_test.dart test/providers/sync_provider_background_admission_test.dart (46 passed); omi-heavy run -- flutter analyze --no-pub lib/pages/conversations/auto_sync_page.dart lib/pages/conversations/sync_page.dart test/widgets/sync_completion_truth_test.dart test/widgets/device_diagnostics_send_support_test.dart (clean); dart format -l 120 on those files. The selected Android17 diagnostics tests pass with the stronger key-retirement checks. New real-widget renders were visually inspected on both Offline Sync implementations.

The c5 full correction panel returned three SHIP reviews. The intermediate test-only c0d panel returned two SHIP reviews and no findings; its third reviewer failed before launch with journal_busy, which is not counted as a review. All six findings from the intervening panel were triaged: the midnight fixture variants were removed, retirement/unknown-anchor assertions strengthened and ready-action priority corrected; the restoration overcount and vanished-legacy-row claims were rejected with current code/test evidence. The final priority follow-up is awaiting its exact-head panel and technical CI. The PR remains unmerged; UI author approval awaits David or Nik.

Automatic ready action with a stalled upload

Legacy ready action with a stalled upload

Final panel follow-up (aca1fea)

Panel review-20261117t104923-1d55 at f2a34d8f3a returned SHIP (DeepSeek, GLM Flash; Luna failed to launch). All 12 findings were triaged:

  • Accepted and fixed:
    • legacy banner zero-length title (F1);
    • native disconnect history capped at 1024 rows, about one week at p90 fleet drop rates, which bounds the synchronous per-disconnect rewrite (F2/F3);
    • Android test renamed to what it actually pins (F4);
    • Catching up doc (F5);
    • manual disconnects no longer seed reconnect markers on iOS/Android (F6);
    • stalled uploads no longer also listed as server work (F7);
    • pending-work expiry scheduled in the caller's timebase with a 1 s floor (F9);
    • portable benchmark path (F10);
    • two unused strings removed from 49 locales (F11);
    • comment (F12).
  • Rejected: F8. The backend validator branches on schema_version == 3, and the window field's meaning is documented.
  • Tests:
    • New regression: an injected past clock never re-arms a zero-delay expiry loop fails on the old code (3 notifications vs 0) and passes.
    • Focused suite: 84 passed, including local_wal_live_custody_test.dart. That test failed once in CI on f2a34d8 (fix(app): release the pendant backup only for audio the saved transcript covers #20376); it is known-flaky and untouched here.
    • flutter analyze is clean, and l10n.py check reports 49 locales OK.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T11:39:31.273190Z aca1fea New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui 5e1763c420582bf720aa7e35584f6c18797b7aba. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e1763c420

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

key: const Key('on_the_way_stalled_details'),
title: l.syncCardNeedsAttention(groupRecordingBlocks(stalled).length),
subtitle: l.transcriptionUnavailable,
onTap: () => openOfflineSyncDetails(context, p, multiFileSync: widget.multiFileSync),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bypass the wearable gate for stalled-upload details

When an expired uploaded WAL coexists with unrelated pending device recordings and DeviceProvider.isDeviceStorageSupport is false, tapping this new Needs attention row shows the device-undetected alert instead of opening Offline Sync. openOfflineSyncDetails applies that gate whenever device work exists unless phoneLocal: true is supplied. Since this action concerns audio already uploaded from the phone, it should use that bypass, as the phone-local Activity actions do; otherwise inspecting the stalled upload unnecessarily requires reconnecting a storage-capable wearable.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui b59de35b4bcb9b5b7bc54513775cfc8520d0b4ee. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@github-actions

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui c5b499af466f02e0a104fd777731a8fc6edb64c0. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@github-actions

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui 85c51a6a01a09e8731577f86b108500e3fc9883e. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85c51a6a01

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +241 to +245
} else if (p.derivedWals.stalledUploadsAt().isNotEmpty) {
title = l.transcriptionUnavailable;
titleColor = Colors.orangeAccent;
action = statusActionPill(l.syncDetailsTitle, OmiColors.accent,
() => showSyncDetailsSheet(context, onHowSyncingWorks: () => _showInfoSheet(context)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the Sync action when stalled and ready recordings coexist

When an idle inventory contains both an expired uploaded WAL and recordings ready to upload, this branch takes precedence over readyWals and replaces the bulk Sync action with Sync Details. The details sheet only provides diagnostics, copying, and an explainer, so an unrelated retained upload prevents users from starting the queued backlog through the status card. The same ordering occurs in sync_page.dart. Keep the Sync action available whenever ready recordings exist, while displaying stalled-upload information separately.

Useful? React with 👍 / 👎.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

/approve-ui 85c51a6

@github-actions

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui c0dce6f40069979b436c142fbd1968ffe4cda705. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@github-actions

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui f2a34d8f3a4c7a198cedd8bbbf736d1651d3c75d. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

/approve-ui f2a34d8

Guard the legacy banner's zero-length processing title, schedule pending-work
expiry in the caller's timebase (no zero-delay re-arm loop), keep stalled
uploads out of the server-work group, skip reconnect markers for manual
disconnects, cap native disconnect history at 1024 rows, drop two unused
strings, and correct docs, comments and a test name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui aca1feac9d55ccc2ea73d2325f3b22dcf065e99b. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

/approve-ui aca1fea

@Git-on-my-level
Git-on-my-level merged commit 859ecc4 into main Nov 17, 2026
51 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/sync-display-truth branch November 17, 2026 12:16
Git-on-my-level added a commit that referenced this pull request Nov 18, 2026
## Problem

A field phone holding **92,763 WAL rows** (90,889 synced history, ~3.6k
pending) froze for 1.2–2.3 s every few seconds and hit "stopped
responding", even in airplane mode with the pendant off. Its debug log
shows `mobile_render_diagnostic` worst frames of 1.2–2.3 s alongside a
WAL flush every ~5–10 s.

Each flush publishes a new inventory list. `SyncProvider.derivedWals`
(and the `WalDerivedSyncViews` stand-in mixin) then disposed and
reconstructed `WalDerivedViews` over every row. That is a 10-bucket
`_apply`, a `HashSet` per id and a listener registration for each of
~92k rows, all on the UI isolate.

## Fix

- `WalDerivedViews.sync(rows)` adopts a new snapshot in place:
- Append-only change (the capture case): recognised with pointer
comparisons; only the appended rows are derived.
- General case: an identity pass. Added rows are derived and removed
rows unwound (listener, dirty set, counts, hidden twins, buckets, id
index, cached selectors). A relative reorder renumbers and invalidates
the order-sorted lists.
- The fast path compares against a private pointer copy of the last
snapshot, so a caller editing a list it passed earlier cannot fake an
unchanged prefix.
- Construction is cheaper:
  - Bucket hash work is skipped where membership didn't change.
  - Single-row ids are stored without a per-row `HashSet`.
- `_ViewEntry` reuses one `syncDisplayState` read for both the display
state and the attention bucket.
- Newest-first lists break `timerStart` ties by source order, so
selectors never depend on update history. Dart's sort is not stable, and
tie order was already history-dependent before this change.
- `Wal.id` is cached and cleared by the `device` / `timerStart` setters,
its only inputs.
- `LocalWalSyncImpl`:
- Counts pending disk WALs without copying the inventory on every flush.
- Skips the live-proof key pass when `_liveProofPendingWalIds` is empty.
  - Skips the loaded-key set at startup when no capture rows wait.

These are loop guards only: no change to which rows are written,
retained or counted.

## Measurements

Benchmark: 89k synced + 3.6k pending rows, real `LocalWalSyncImpl` with
the delta index, flutter test debug JIT on a host at load average ~300.
Absolute numbers are inflated; compare the ratios.

| Path | Before | After |
|---|---|---|
| Derived views per inventory update, longest synchronous block |
1.0–3.0 s | 11–14 ms |
| `WalDerivedViews` construction, 92.6k rows (once per session) | ~1.4 s
| ~0.33 s |
| Dispose on every update | 0.1–0.6 s | none |

## Tests

- New `test/unit/wal_derived_views_sync_test.dart`:
- 20 seeded random walks of 300 steps each: append, remove, device-row
insert, shuffle, same-id replacement, in-place status, id and sort-key
edits, and duplicate listing. Every selector, count, day total, refusal
summary and `rowsForIds` result is compared against a fresh
`WalDerivedViews` over the same list.
- Plus cases for in-place list edits, listener teardown of removed rows,
and "appending to a 20k synced history reads no retained row and keeps
the unchanged bucket's sorted list".
- Existing suites: 98 WAL / sync / perf test files, 1,011 tests pass.
`bash test.sh test/perf/production_shell_gate_test.dart
test/perf/global_sync_inventory_test.dart
test/unit/wal_derived_views_sync_test.dart` passes.

## Not in this PR (measured, disclosed)

- `WalIndexWorker` index saves still take seconds per added row on a 92k
index. They run off the UI isolate but compete for background CPU.
- Some UI paths still scan the full list while their screen is open:
  - `SyncDetailsSheet` (`SyncPipelineAmounts.of(allWals)`)
  - the Auto Sync run tracker
  - `displaySortedWals` re-sort after a membership change
  - `openOfflineSyncDetails` twin set, built per tap
- Synced-copy retention: existing installs have `autoRemoveSyncedCopies`
pinned off by migration, and `syncedAt == 0` rows are never swept. That
is how phones reach ~100k rows. This is a product decision and is not
changed here.
- Overlaps #25582 (`WalDerivedViews` constructor / `pendingWork`), which
changes the same file without semantic overlap. Whichever lands second
rebases.

## Product invariants affected

- INV-CAP-1 (path match only): display derivation and lookup caching. No
WAL status, file, retry, deletion or upload decision changes.

Failure-Class: none
UI-Evidence: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant