Repository navigation
fix(app): honest sync attention for bad device timestamps and refused rows - #23750
Conversation
… rows
David's dogfooding (iOS 1.0.578): 6,387 one-second SD fragments rejected
400 invalid timestamp in 24h, filename dates 2030-2035; On the Way showed
bare "Failed" rows; Heard today read 0s during a 33-minute live episode;
On Device read 0s with 7h45m queued on the phone; dispatch_hold read
"Omi servers are busy".
- SD-card parser: a timestamp marker must land in 2024-01-01..now+1d
(the server's own filename window); implausible markers are ignored so
the recording keeps the estimated clock instead of splitting. The
storage-listing start gets the same gate.
- Upload 400s: the body's bounded code is parsed. invalid_capture_time
quietly discards sub-1.5s splice wreckage (counter event, no Failed
row), re-stamps longer fragments once from plausible neighbours or
file mtime (never in the future, latched so it cannot loop) and
requeues them; other 400s stay terminal with the server's reason kept
as a bounded token on the WAL.
- On the Way: every row opens Sync Details, rows show length and a short
reason (Invalid recording date / Rejected by server / Too large), and
attention rows get the Offline Sync page's own Retry and Delete
actions. Sync Details rows name the same reasons.
- Heard today: transcript time inside today's local day across loaded
conversations (a midnight-crossing conversation counts its after-
midnight half; a never-set session origin no longer hides today's
speech) plus the live episode since local midnight.
- On Device tile names the phone queue ("7h 45m on phone") beside
on-device audio.
- dispatch_hold gets its own honest copy: uploads paused for a moment,
resuming automatically - no longer server-capacity text.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25ca68aeec
ℹ️ 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".
| if (syncUploadErrorCode(response) == 'invalid_capture_time') { | ||
| throw SyncInvalidCaptureTimeException(serverReason: syncUploadErrorReason(response)); |
There was a problem hiding this comment.
Add the server error code required by capture-time recovery
For uploads with future or pre-2024 timestamps, the checked-in backend's _retrieve_file_paths_v2 (backend/utils/sync/pipeline.py:2181–2189) raises HTTP 400 with only detail: 'Invalid sync file format: invalid timestamp'; it does not return an invalid_capture_time code. Consequently, real timestamp refusals always fall through to the terminal SyncUploadHttpException, and none of the new restamping or fragment-recovery logic runs. Add the bounded code to the backend response alongside this consumer and test the actual response contract rather than only injecting the new exception.
Useful? React with 👍 / 👎.
| now: DateTime.now(), | ||
| ); | ||
| }); | ||
| return fromConversations + _liveEpisodeSecondsToday(context); |
There was a problem hiding this comment.
Exclude already-counted conversations from the live contribution
When a pendant remains connected across multiple conversations, CaptureProvider.liveCaptureStartedAt is the capture-session start, not the current episode's start (capture_controller.dart:1135–1137). Adding its entire elapsed duration to the saved and processing conversations counts those conversations twice and also counts intervening silence as speech. For example, a session running for two hours with ten minutes of completed speech reports at least two hours and ten minutes heard. Derive the live contribution from the current episode or transcript and exclude intervals already included in fromConversations.
Useful? React with 👍 / 👎.
| _PendingItem.block(RecordingBlock block, {required this.label, required this.step}) | ||
| : start = _blockStart(block), | ||
| seconds = block.seconds; | ||
| seconds = block.seconds, | ||
| wal = block.representative; |
There was a problem hiding this comment.
Apply recording-row actions to all represented fragments
When adjacent WALs form one recording block, the row displays block.seconds but retains only block.representative for its new Retry and Delete actions. Both callbacks operate on a single WAL, so deleting a displayed multi-file recording removes only one fragment, and retrying a failed recording leaves its other exhausted fragments untouched. Preserve the block's members and apply the action to the eligible members, or expose individual files explicitly rather than presenting a whole-recording action.
Useful? React with 👍 / 👎.
| if (item.seconds > 0) OmiDuration.compact(item.seconds, l), | ||
| item.label, | ||
| ].join(', '), | ||
| excludeSemantics: true, |
There was a problem hiding this comment.
Preserve accessibility semantics for the new row actions
For VoiceOver and TalkBack users, the new Try Again and Delete buttons are hidden because _Row wraps its entire subtree in Semantics(excludeSemantics: true) at line 546. That replaces all descendant semantics with the row's time/duration/status label, removing both buttons' labels and tap actions from the accessibility tree. Restrict semantic exclusion to the descriptive text, or place the action buttons outside that excluded subtree, so each action remains independently discoverable and operable.
Useful? React with 👍 / 👎.
… retry scope Review fixes for PR #23750, one behavior change per finding, each with a test: - invalid_capture_time never deletes audio: the quiet discard of <=1s fragments is gone. A fragment that cannot be re-dated stays as an attention row with the reason kept, Delete left to the user. - A capture time is re-stamped only from audio proven contiguous: a neighbour that is frame-adjacent on the source's own clock (same captureRoot + sourceClockEpoch, ending exactly where this WAL begins in frame positions), or shares this WAL's clock run / recording session with its end within one 120 s pause of the WAL's position in that run's clock — and whose end the server itself accepts. The latest-plausible-end-on-device guess and the file-mtime fallback are dropped: mtime is the copy time, not the capture time. - The re-stamp move is crash-safe: copy to the new name, durably save the WAL index pointing there, only then delete the old file; a failed or interrupted index save rolls the row back to the old name and never unlinks the last reachable copy. - A 400 counts as invalid capture time by bounded code (server #23746) or by the deployed route's exact detail line "Invalid sync file format: invalid timestamp". - too_large (413) rows offer Delete only — the same bytes are the same size — on On the Way, in Sync Details rows, and in the Needs Attention retry-all. Invalid-date rows keep a Retry that resends unchanged. - On the Way row actions cover the whole recording: Retry and Delete go over every member WAL of the grouped block, like the Offline Sync block action. - Heard today counts only the active live episode's own interval since its start or anchor (never liveCaptureStartedAt, which an all-day pendant stream never resets), and every contribution is clipped to the local day and merged before summing, so overlaps between the episode interval and already-counted transcript segments are counted once. - The stats tile column no longer stretches to the leftover viewport height; evidence captures the tiles' real height. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4161657ea8
ℹ️ 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".
| } on SyncInvalidCaptureTimeException catch (e) { | ||
| await handleSingleInvalidCaptureTime(walToSync, generation, e); | ||
| return resp; |
There was a problem hiding this comment.
Report terminal capture-time refusals in the sync result
When a timestamp refusal cannot be repaired, or the restamped recording is refused again, this handler marks the WAL uploadRejected but returns a response with both failure counters still zero. The batch handler likewise bypasses failure accounting. Consequently, SyncProvider._performSync treats the refused upload as successfully completed instead of surfacing its permanent failure, and the coordinated drain reports failed: false. Propagate terminal repair outcomes into localUploadFailures, localUploadPermanentFailures, and the permanent error field in both paths, while excluding batch isolation and successful repairs from failure accounting.
Useful? React with 👍 / 👎.
…large retry scope, equal stat tiles Owner decision: automatic re-stamping leaves this PR entirely. The SD-card marker plausibility window stops new bad dates at the source, server PR #23746 accepts clocks ahead by up to 600 s so a plain resend now succeeds for those, and the remaining re-stamp edges (day misfiling from the gap estimate, chained estimates, a collision pushing the time into the future, duplicate files after a crash) are not worth their custody risk. - invalid_capture_time: the neighbour-estimate, copy-save-delete move and capture_time_restamped latch are deleted, with their tests. A refusal — by bounded body code or the deployed detail line, both still parsed — parks the WAL on attention with "Invalid recording date", never deletes or renames audio; Retry resends the same file unchanged; Delete still confirms first. Multi-file refusals keep the batch isolation so only the refused file is marked. - P1: a block Delete re-checks every member at delete time and skips any that is syncing or not terminal/attention (walDeletionAllowed, one shared attention-state set with SyncPendingWork), toasting "Some parts are still uploading and were kept" when something was skipped; LocalWalSyncImpl.deleteWal refuses a mid-upload target as the last line of defense. - too_large shows no Retry anywhere: the failed-sync banner state (failedWal/hasError) no longer puts a Retry back on a too-large row — the row shows its refusal label and Delete — the error card's retrySync skips a too-large failedWal, and the Auto Sync file/block rows use the same walRetryCanHelp scope. - Device stats tiles share one row height via IntrinsicHeight + CrossAxisAlignment.stretch: the On Device captions raise the whole row, 84 pt minimum kept, no stretch to the viewport. Evidence 004 regenerated; the On the Way rows image is byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What changed and why
Sync attention became honest after David's dogfooding of iOS 1.0.578: the server rejected 6,387 one-second SD-card fragments in 24h with 400
invalid timestamp(filename dates 2030–2035), On the Way answered with rows that only said "Failed", Device Settings showed "Heard today 0s" during a 33-minute live episode and "On Device 0s" with 7h45m queued on the phone, and a per-accountdispatch_holdcooldown read "Omi servers are busy".sdcard_wal_sync.dart): a0xFFtimestamp marker is accepted only inside 2024-01-01..now+1 day — the same window the backend's filename gate enforces. Implausible markers (audio bytes the desynchronized packet walk decoded as a clock) are ignored, so the recording keeps the app-estimated clock instead of splitting into garbage-dated fragments. The storage-listing start timestamp gets the same gate.conversations.dart,wal_policy.dart): a 400 counts asinvalid_capture_timewhen the body carries the boundedcode(server PR fix(sync): keep real skewed-capture audio admissible; typed invalid_capture_time 400 #23746) or the exact detail line the deployed route still returns (Invalid sync file format: invalid timestamp). The audio is never deleted for its claimed time, however short: a fragment whose capture time cannot be proven stays as an attention row with the reason kept ("Invalid recording date"), Delete left to the user, and a Retry that resends unchanged. When contiguous audio of the same source run proves when the fragment began, the file is re-stamped once with that time, crash-safely (see the review-round section), and re-offered; the re-stamp is latched so it cannot loop. Other 400s stay terminal, with the server's reason kept as a bounded token on the WAL (invalid_capture_time/too_large/server_refused).wal.dart,sync_provider.dart,sync_page.dart,on_the_way_page.dart): atoo_largerefusal (413) is deterministic — the same bytes are the same size — so its rows offer Delete only, on On the Way, in Sync Details, and the Offline Sync Needs-Attention retry-all skips it. Every other retryable state keeps its Retry.heard_today.dart,device_settings.dart): speech is measured on the transcript clock — the segment time that falls inside today's local day across the loaded conversations (a conversation crossing midnight counts its after-midnight half; a session-originstartedAtno longer hides today's speech). The active live episode contributes its own interval since its start or anchor — neverliveCaptureStartedAt, which a pendant that streams without a break never resets. Every contribution is an interval on one clock, clipped to today and merged before summing, so audio the episode's own transcript segments already counted is not counted again from the running interval. Without segment data (list responses may omit it) a conversation keeps its length on its reported day.backendBusycapacity text.Review round (this push)
Eight review findings, each fixed with a test:
invalid_capture_timerefusal never deletes audio. Short fragments follow the same rules as long ones and stay as attention rows when they cannot be re-dated.codeor the deployed route's exact detail line; both body shapes are tested, including the real current body.captureRoot+sourceClockEpoch, ending exactly where this WAL begins in frame positions —walExtendsRun's own idiom), or shares this WAL's clock run / recording session with its end within one 120 s pause of the WAL's position in that run's clock — and its end is a time the server itself accepts (≥ 2024-01-01, ≤ now, so a run sharing one wrong clock cannot chain a second refusal). Without such a neighbour, no date is invented. The file-mtime fallback is dropped: mtime names when the phone wrote its copy (every SD drain re-writes chunks as they arrive), not when the pendant sampled the audio, so it is not the capture time for any source here.walRetryCanHelpgates Retry on the refusal reason;too_largeshows Delete only in On the Way rows, Sync Details rows, and the Needs-Attention retry-all.startedAtkept stable by the sharedLiveStartAnchor, restart-aware), not the capture session's origin; it merges with transcript intervals instead of adding on top.Product invariants affected
INV-CAP-1 (pendant audio retention) —
app/lib/services/wals/**changed. No change drops sampled audio: the parser fix keeps recordings whole instead of splitting them, and the repair path re-offers refused audio or parks it honestly for the user's own Delete. There is no deletion anywhere in theinvalid_capture_timepath. Capture, ring retention, and drain scheduling are untouched.How it was verified
flutter teston the touched suites (169 tests across 14 files: sdcard custody/packet, invalid-capture-time recovery incl. crash-safety, heard-today, On the Way days + attention, sync row recovery window, needs-attention retry, recording blocks, episodes UI, home pending row, device catching-up, evidence render, sync-indicator isolation, background admission) — all green.bash app/scripts/analyze_ratchet.sh— passed, no new analyzer issues.make preflight— 28 checks passed.Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2636 -> 2653 | two
on SyncInvalidCaptureTimeExceptionclauses (drain + single retry), one import, and the delete-time isSyncing guard in deleteWal; all repair logic lives in wal_policy.dart, and the batch-isolation duplication moved out with itTests
sdcard_custody_sync_test.dart— future (2035) and pre-2024 markers no longer split a recording; plausible markers still do; window boundary unit-tested.invalid_capture_time_recovery_test.dart— a 1 s fragment stays a row and keeps its file; no proven neighbour keeps the claimed time (a same-device plausible bystander never qualifies); a shared-clock-run fragment is re-stamped at its run predecessor's end and re-offered once; one-restamp cap terminal with reason; other 400s terminal with reason;contiguousCaptureStartSecondsunit tests (frame-adjacent predecessor, run predecessor within the pause gap, over-gap silence, wrong-clock future end, no run identity); crash-safety (failed index save rollback with the audio reachable under its old name, interrupted save after the durable write leaves a restart-reachable name, completed move deletes the old file); both 400 body shapes including the deployed detail line.sync_row_recovery_window_test.dart— too-large row offers Delete only; invalid-date keeps its Retry.sync_provider_needs_attention_retry_test.dart— the retry-all skips too-large refusals and re-offers the rest.on_the_way_attention_test.dart— a three-WAL recording reads as one row of 3m 45s; Retry covers every member; one confirmation deletes every member; too-large row offers Delete only.heard_today_test.dart— midnight-crossing conversation, misfiled session day, overlapping segments counted once (10:00–10:30 + 10:20–10:40 = 40 min), live-episode interval clipped to midnight, earlier same-day segments plus an active episode counted as a union, segmentless fallback, discarded exclusion.sync_attention_evidence_test.dart— layout assertions for both surfaces and the real-tile-height bound (writes the PR evidence PNGs on demand).UI evidence
Before/after Flutter widget screenshots, dark theme, 390×844 viewport, captured by the same fixture harness (before at
origin/main):Manifest:
.agent-artifacts/ui-evidence/lane-sync-attention-honesty/evidence.json. David must approve these before merge.Failure class (fixes)
Failure-Class: new
Failure-class transition narrative
Violated contract: a client that turns device-supplied bytes into recording times must only accept a timestamp it can prove is a clock, not merely a positive number — and when the server refuses a recording, the app must show which refusal it was, never destroy the audio for it, and only offer actions that can change the outcome. The SD-card packet walk accepted any
0xFFbyte plus four bytes decoding above zero as a timestamp marker, so desynchronized audio split real recordings into ~1 s fragments dated 2030–2035 (6,387 rejected uploads in 24h), the 400 body was discarded, each fragment parked terminally as a bare "Failed" row, and the surrounding stats (Heard today, On Device, dispatch_hold copy) hid where the work actually was.Canonical guard:
markerEpochPlausiblegates every device timestamp — packet markers and storage-listing starts — on the server's own filename window (≥ 2024-01-01, ≤ now + 1 day), keeping the estimated clock when it fails.isInvalidCaptureTimeResponserecognises the refusal by bounded code or the deployed detail line;contiguousCaptureStartSecondsis the only source of a replacement capture time — a frame-adjacent or same-run neighbour whose end the server accepts — and the re-stamp move is copy → durable index save → delete, so audio stays reachable across a crash.walRetryCanHelpkeeps guaranteed-fail uploads off every Retry surface. Guard artifacts:app/lib/services/wals/sdcard_wal_sync.dart,app/lib/services/wals/wal_policy.dart,app/lib/services/wals/wal.dart,app/lib/backend/http/api/conversations.dartand their tests.Evidence: this PR is the evidence (dogfooding iOS 1.0.578, 2026-10-26);
evidence_prsis[].Scoped cleanups (optional)
The standing visual-audit
on-the-wayscenario now also shows refused rows with reason tokens, so future audits capture this surface.sync_attention_evidence_test.dartdoubles as a render/evidence test (PNG output only with--dart-define=SYNC_ATTENTION_EVIDENCE_OUTPUT=<dir>), followingopen_loop_evidence_test.dart's pattern.🤖 Generated with Claude Code