Repository navigation
Conversation
…e socket The session window starts only when a socket opens, and the server closing a conversation clears it. On a pendant socket that stays open, every later conversation's WALs were never stamped or confirmed: they stayed on the phone and were later uploaded without a conversation, which the server turns into a duplicate. When processing starts and capture continues, start the next conversation's window, so its backup is stamped and released like the first. Closes BasedHardware#20365
|
@cubic-dev-ai review |
@Itaxh1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Reviewed the original implementation at The combined 23-test later-conversation/recovery run exposed a fixture wait race: the healthy confirmation was still releasing WALs when an unchanged index was treated as completion. The same case passed alone. Test-only follow-up Itaxh1#4 waits for an empty WAL list with a bounded timeout; all 23 tests then passed together, focused analysis was clean and 14 local preflight checks passed. No runtime change or hardware acceptance is claimed. #20376 must precede this PR. |
A pendant muted across a conversation close, or a phone call that interrupts the mic, resumes on the same socket. The window guard admitted only record and deviceRecord, so the audio after the resume stayed unstamped. Skip only a stopped or failed capture. The scenario tests now wait for the expected WAL state, in memory and in the saved index, instead of a quiet moment, and fail with the WAL state if it never arrives.
|
@cubic-dev-ai review |
@Itaxh1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…ess now A pendant recording runs on into the next conversation, and the stamp matches WALs by recording id, so a chunk of the next conversation that landed while the closing one was still being stamped could be claimed by it. Both stamps, on a server close and on Process now, now take only the WALs that start before the close. Process now resets the session like a server close but never reopened the window, so the audio after it stayed unstamped while the pendant kept streaming. It now opens the next window at the close too.
|
@cubic-dev-ai review |
@Itaxh1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
… before releases The stamp leaves WALs that start at or after the close to the next conversation. A tail drained with under a second of audio started at the drain's own second, so the fence could leave it to the next conversation. The close is now read after the drain, and a sub-second tail starts at least a second before it. The window scenarios now check that the streamed audio is in a copy before each close, so a release can't pass on no copies at all. A new scenario shows that a Process now which made no conversation leaves its audio to the conversation the server kept open: the next close in the same recording stamps it.
|
@cubic-dev-ai review |
@Itaxh1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…ALs at the close - The close state (session start, socket-repair flag, 30 s fallback) was one slot. A conversation event that arrived after the next close took that close's state, and the later event found none. Closes are now kept by conversation id, and an event only finishes its own. - The stamp fence now takes the WALs that exist right after the close's drain, instead of a time cutoff. A sub-second tail keeps its real start and duration, and a WAL created after the close stays with the next conversation even when its start is backdated. - Windows opened after the first one get a counter in their capture id, so two that open in the same second still name different conversations.
|
@cubic-dev-ai review |
@Itaxh1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…n between paths - Two tails drained in the same second get the same Wal.id, so a fence on ids could admit a WAL created after the close. The fence now holds the WAL objects that existed right after the close's drain. - Both closing paths drain, fence and take the close time through one helper, _drainClosingConversation(), so the two can't drift apart. - The late-event scenario now checks that c2's copies survive c1's event before c2's own event releases them.
|
@cubic-dev-ai review |
@Itaxh1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…audio goes A close's WALs include an earlier conversation's that are still unstamped, under the same recording id. When a close's drain finished first (an empty tail, or a server close during Process now's request), its stamp claimed the earlier conversation's audio. Each close now chains its stamp after the earlier ones, Process now included, and the waiters no longer clear the chain, so a close during a wait keeps its stamp in later waits. The phone-mic call scenario now streams resumed audio and checks it goes out on the same socket while the window opened at the close is active.
|
@cubic-dev-ai review |
@Itaxh1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…indow The location snapshot belongs to the recording, but each close cleared it, so from the second conversation on, the safety WALs carried no location. A close where capture goes on into the next conversation now keeps it; one after the user stopped still clears it. The scenarios' transcript fixture now covers each conversation end to end, so the release they expect doesn't lean on a coverage slack.
|
@cubic-dev-ai review |
@Itaxh1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Reviewed the diff against main at 172f4d6 — this is a well-shaped fix for #20365; the per-close state map, close-ordered stamp chain, and WAL-identity fence are the right design. Per-file notes:
One process note: Dart Analyze & Tests was skipped by path filtering on this head, so the new test files haven't run in CI on 172f4d6 — worth forcing the full app lane before flipping out of draft. No blocking concerns; leaving for normal maintainer review since this sits in the capture/WAL durability core. AI-generated maintainer feedback on behalf of the Omi maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Reviewed the diff at 172f4d6 — the approach looks right, and the tricky invariants hold together. Per-file notes:
One verification note: since this is a draft, CI skipped the Dart suite, so the new tests haven't run there yet — worth marking ready (or a Nice work on the fence design — leaving for maintainer review once it's out of draft. |
|
Hey @Itaxh1 👋 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! |
…#26035) Fixes #20365. After the first conversation closes on a continuing pendant socket, capture currently clears its WAL window and never rearms it. Later saved conversations leave their backups unlinked and eligible for duplicate upload. A single pending-close slot also loses earlier evidence when results arrive out of order. This change rotates a distinct conversation window without reconnecting, seals an exclusive WAL cut before any queued I/O, and retains per-close transcript/interruption/socket-mode evidence. Saved transcript coverage and existing committed-receipt rules still control retention. Partial, interrupted, held and uncertain audio remains recoverable, and upload preferences remain authoritative. Process Now reserves its own cut and resolves overlapping server events against every relevant outstanding response ID; ambiguous audio is never guessed into another conversation. Account retirement fences the writes and cancels pending timers. A failed disk snapshot still waits for its predecessor, so errors cannot detach the ordered tail. The close lifecycle is isolated in a small capture part, and exact WAL cut ownership lives beside the ledger. Existing lifecycle/checkpoint finalization remains separate. Architecture, custody documentation and the implementation checklist are updated. Credit: this builds on Ashwin's #20380 and cocvn157's #24846 rollover/snapshot work, adapted to current custody and typed Process Now contracts. Validation: - Original main controller fails the new three-conversation replay: c2 backups remain unlinked. - 16 new production-controller/ledger/disk/recovery replays cover sequential closes, reverse confirmations, partial coverage, duplicate events, queued disk barriers, delayed/failed and overlapping Process Now, account retirement, stop/dispose, restart and both Custom STT raw-audio settings. - 10 new snapshot ownership tests and 40 existing WAL regressions passed. The failed-middle-drain regression fails with the predecessor wait removed and passes with it restored. Caption-store/provider/coalescing consumers pass 115 tests using the authoritative window key. - All 31 hermetic mobile journeys passed (0 failed/skipped); analyzer ratchet, generated-output checks and all 27 preflight checks passed locally. - Full Flutter and Android CI on the final immutable head remain merge gates (see Checks). An initial broad local run overlapped final edits and is not claimed as frozen-head evidence. - Replay substitutes socket/native/device boundaries; no physical pendant, live provider, production recordings or store release is claimed. INV-CAP-1: Every admitted frame stays in the owner-scoped ledger; exact sealed cuts establish lineage only. Unconfirmed or partial audio stays readable/recoverable and existing policy alone releases confirmed copies into synced retention. Failure-Class: none The existing buffer-clear-after-async-flush and cross-device duplicate-capture classes have different failure mechanisms/prevention: this defect is a missing conversation-window rollover plus overwritten close evidence, resolved with per-close snapshots rather than content dedupe or cleanup policy changes. UI-Evidence: none -- capture and ledger behavior only; no Flutter view or user-facing layout changed. Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 3155 -> 3196 | Keep admission sealing beside the existing frame buffer and extension paths; token handling is extracted into conversation_wal_snapshot.dart and the capture controller shrinks.
…rdware#20365) Rotate conversation windows on continuing sockets and retain per-close evidence. Reserve exact WAL identities before queued persistence; keep uncertain Process Now audio recoverable and fence account changes. Based on prior work in BasedHardware#20380 and BasedHardware#24846. Co-authored-by: Ashwin <[email protected]> Co-authored-by: cocvn157 <[email protected]>
TL;DR: On a pendant connection that stays open, the app tagged and released the backup audio of only the first conversation. Every later conversation's backup stayed on the phone and was uploaded again without a conversation, and the server turned it into a duplicate (#20365). Now each conversation the server closes starts a fresh backup window while recording continues, so later conversations are tagged and released exactly like the first. App only, no backend change. Last week this pattern affected up to about 8,500 conversations across about 585 users on the builds that include #19199.
What changed and why
Closes #20365
_sessionStartSeconds) is set only when a socket is published, and_resetStateVariables()clears it when the server starts processing a conversation. A pendant socket stays open across conversations, so from the second conversation on:_finalizeAndStampSessionskipped stamping (sessionStartSeconds > 0);memory_createdhandler skipped confirmation._startNextConversationWindow()runs right after that reset in thememory_processing_startedhandler. If a socket is still open and capture hasn't stopped, it starts the next conversation's window at that moment. This includes a capture that is paused (pendant mute, or a call suspending the pendant) or interrupted (a phone call, Siri, a mic stall), because it resumes on the same socket.stop) or capture has failed (error): no new window is opened.POST /v1/conversations, not the listen session's finalization, so nomemory_processing_startedfor it arrives to re-stamp the new window.walsNow()). These are the WAL objects, not their ids, because two tails drained in the same second share an id. A WAL created later is the next conversation's, even when its start is backdated. Both paths drain, fence and read the close time through one helper,_drainClosingConversation(), so they can't drift apart.prepareConversationStamp(…, walsAtClose:), sostampConversationIdkeeps its signature for the session spies that call it dynamically.ConversationEvent. They used to share one slot: an event that arrived after the next close took that close's state, and the later event found none. Flutter transcription: a partial transcript deletes the pendant's whole audio backup #20364 (fix(app): release the pendant backup only for audio the saved transcript covers #20376) keys its segment-arrival snapshot the same way.after:), Process now included, and the release paths wait on that chain. They no longer clear it, so a close that happens during a wait keeps its stamp in later waits._captureOutlivesClose). A close after the user stopped still clears it.activeCaptureSessionId(live-<start>-<n>, where the counter separates windows opened in the same second, found by cubic's review), as the first conversation already did withlive-<start>. Before, it was null and callers fell back to the recording id. The live-transcript store and the capture page's scroll state are therefore keyed per conversation from the second one on.Order: land #20364 (#20376) first. Today these later conversations escape the all-or-nothing release that #20364 fixes, because they are never confirmed. Once this PR stamps and confirms them, they need #20364's coverage check so that a partial transcript can't delete their audio. The two PRs merge cleanly in either order.
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 3799 -> 3862 | the conversation-processing handler must reopen the safety-WAL window at the existing socket/event owner
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 1815 -> 1830 | the WAL owner must fence each conversation stamp at its close at the existing stamp boundary
Product invariants affected
none
How it was verified
flutter test test/services/capture/capture_next_conversation_window_test.dart test/unit/wal_stamp_fence_test.dart: 16 passed. Onmainwithout the fix:recordanddeviceRecord(found by cubic's review).live-<second>.test/unit/*wal*|*capture*|*sync*|*transcri*|*recording*|*segment*,test/services/capture,test/services/wals,test/spine,test/providers/capture_provider_test.dart): 959 passed.bash app/test.sh: 3,914 passed, 5 skipped, 0 failed.bash app/test.shreports 3,942 passed, 5 skipped, 0 failed.flutter analyzeon the changed files: no issues.Tests
app/test/services/capture/capture_next_conversation_window_test.dart(new) uses the replay world: the realCaptureController,LocalWalSyncImplandRecordingTransferCoordinator, a scripted socket and a scripted Opus pendant.locationFix), with the compatibility upload stubbed.processResponse).test/spine/c1_location_completion_test.dart, the Process-now and backlog widget tests) still pass, withstampConversationIdunchanged.app/test/unit/wal_stamp_fence_test.dart(new): a fenced stamp claims the WALs that existed at the close, including a backdated one. It leaves WALs created after the close for the next conversation, including one whose start is backdated. Two WALs that share an id are told apart. The fence holds for one stamp only, and half a second of audio drained at the close still goes to the closing conversation.Failure class (fixes)
Failure-Class: none