Repository navigation
fix(app): count union of audio intervals in recording blocks (#23561) - #23570
huynhnhatquandongnai-source wants to merge 2 commits into
Conversation
…rdware#23561) ## Summary Fix inflated offline sync duration by computing the union of positive audio intervals rather than span between earliest start and latest end (closes BasedHardware#23561). - In `app/lib/pages/conversations/recording_blocks.dart`: update `RecordingBlock.seconds` to collect positive audio intervals `[timerStart, timerStart + seconds]`, sort by start, and merge overlapping intervals to calculate the exact total audio duration. Gaps between non-consecutive WALs (e.g. 55s gaps within the 120s grouping window) are excluded from the reported duration. Overlapping phone/device copies are counted once. - Add regression tests in `app/test/pages/conversations/recording_blocks_test.dart` verifying gap exclusion, overlapping copy deduplication, and non-positive length filtering. ## Invariants affected - Counts union of positive audio intervals without reporting gap time as pending audio. - Overlapping phone/device copies count once. - Preserves recording grouping, source files, ownership, retry, and upload state. Failure-Class: none
Git-on-my-level
left a comment
There was a problem hiding this comment.
Verdict: the production fix is correct and nicely scoped, but one of the three new tests cannot pass as written, so this needs a small change before merge.
What's good (app/lib/pages/conversations/recording_blocks.dart):
- The new
secondsgetter is a correct interval union: it keeps only positive-length WALs, sorts[timerStart, timerStart + seconds]pairs, and merges overlaps with a standard sweep, so pauses shorter than the 120 s grouping tolerance are no longer reported as audio (recording_blocks.dart:23-52). A block whose WALs are all zero/negative length now returns 0 instead of a bogus span. O(n log n) over the handful of files in a block - no perf concern. - Consumers check out: auto_sync_page.dart:678 and on_the_way_page.dart:285/340 use
block.secondspurely for row durations and totals, which is exactly the display #23561 describes; sync_provider.dart:727 sums per-WAL seconds directly and is unaffected. Grouping, ownership, retry and upload state are untouched.
Blocking issue (app/test/pages/conversations/recording_blocks_test.dart):
- 'counts overlapping device and phone copies once in union (#23561)' cannot pass as written. With
joinDeviceCopies: true, a phone WAL joins the device block only when_copiedFromDeviceis true, i.e.originalStorageis sdcard/flashPage (recording_blocks.dart:76-79) - andoriginalStoragedefaults to null inWal. Your_wal(0, 75)has nooriginalStorage, so it groups under the phone key('pendant-a', false)together with_wal(100, 50), while_wal(0, 75, storage: WalStorage.sdcard)groups under('pendant-a', true). That is two blocks, andblocks.singlethrows. Suggested fix: model a real drained copy - add anoriginalStorageparameter to_waland stamp the phone copies asWalStorage.sdcard- then either assert the two blocks' durations sum to 125, or make_wal(100, 50)a drained copy too so all three land in one block.
The other two new tests trace correctly: three 5 s WALs with 55 s gaps -> 15 s, and zero/negative lengths -> 10 s.
USER IMPACT: Offline Sync and On the Way stop counting silent gaps between recording chunks as audio - a recording with pauses will now show its real listening time instead of an inflated duration.
To land this:
- Fix the union test as above and run
flutter test test/pages/conversations/recording_blocks_test.dartso all three new tests pass. - Optional: add an assertion that a fully contained overlapping interval (e.g. a 30 s WAL inside a 75 s one) is not double-counted - right now only exact duplicate overlaps are covered.
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 Thank you for the insightful review! Addressed the test issue in commit
Ready for re-review! |
|
Thanks for correcting the drained-device-copy fixture. I reviewed 4099173: all nine model tests pass locally, and an additional 2,000-case synthetic interval-union check passes without changing WAL metadata or order. The equivalent duration fix has now landed through #23566 (merge 18c4a38). That PR also includes the rendered summary/day/row regression and required changelog, so no additional implementation from this PR is needed for #23561. Keeping one landed implementation avoids duplicate work; this PR is superseded for that issue. The fix still needs a mobile release. It corrects displayed duration only; stalled transcription and customer audio recovery are separate. |
Dismissed: the blocking concern from this review (union test grouping phone copies without originalStorage into a separate block) is resolved on head 4099173 — _wal now stamps drained phone copies with originalStorage: sdcard, all four WALs group into one block under joinDeviceCopies, and the union assertion (125 s) traces correctly against groupRecordingBlocks. Dart tests are green on this head. Follow-up review tracks the remaining, unrelated Hygiene ui-evidence contract item.
Git-on-my-level
left a comment
There was a problem hiding this comment.
Since my last review: addressed (the union test now models drained device copies correctly — verified below) · still open (Hygiene fails the ui-evidence contract) · newly introduced (nothing).
Verdict: the code side is done — the test issue I blocked on is fixed and the optional contained-interval case is covered too; what remains is one line in the PR description, not code.
Verified on this head:
- app/test/pages/conversations/recording_blocks_test.dart —
_walnow takesoriginalStorageand the phone copies are stampedWalStorage.sdcard, so withjoinDeviceCopies: trueall four WALs group under the same device key (recording_blocks.dart:94) and join into one block (gaps/overlaps within the 120 s tolerance); the union 0–75 ∪ 20–50 ∪ 100–150 = 125 s matches the assertion. The_wal(20, 30, …)piece also covers the fully-contained-overlap case from my earlier review. Dart Analyze & Tests is green here. - app/lib/pages/conversations/recording_blocks.dart — unchanged since my last review; the interval-union
secondsgetter still reads correct.
Blocking (repo contract, not code): the Hygiene job fails its ui-evidence check. PRs touching app/lib/**/*.dart must either reference a tracked screenshot under .agent-artifacts/ui-evidence/… in the description, or add an exact line to the PR description, e.g.:
UI-Evidence: none -- duration numbers only, no layout or visual change
USER IMPACT: Offline Sync and On the Way will show real listening time for recordings with pauses, instead of an inflated duration that counted silent gaps as audio.
Remaining action item:
- Add the
UI-Evidence:line (or a screenshot) to the PR description so Hygiene goes green; after that this looks ready for a maintainer merge.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Thanks for this contribution! Our review requested some changes (see above) and we haven't heard back in a while. If you're still working on it, just push a commit or leave a comment within the next 7 days. To keep the queue healthy we'll close this PR in 14 days if it stays inactive — and it can always be reopened once updates land. Happy to re-review! |
|
Hey @huynhnhatquandongnai-source 👋 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:
Before your next PR, please skim:
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! |
Summary
Fix inflated offline sync duration by computing the union of positive audio intervals rather than span between earliest start and latest end (closes #23561).
Invariants affected
Failure-Class: none