Skip to content

feat(app): on-device live preview for batch-lane users (iOS + Android) - #23617

Merged
Git-on-my-level merged 23 commits into
mainfrom
odpreview/mobile-local-preview-ios
Oct 25, 2026
Merged

Git-on-my-level merged 23 commits into
mainfrom
odpreview/mobile-local-preview-ios

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Mobile half (iOS + Android) of the on-device live preview for batch-lane users
(David, 2026-10-25). Server half: #23610 (merged e09ce024), which must be serving on listen first; until it is, nothing here changes behaviour.

Gate (David, 2026-10-25 16:55Z): his TestFlight QA replaces the pre-merge screenshot OK; screenshots stay below.

  • Capability: iOS and Android clients send local_preview=enabled on /v4/listen (not for custom STT, onboarding or phone
    calls). PostHog kill flag mobile-local-preview-disabled (kill role; absent/false/offline = on) stops it.
  • Admission: only a ready/mobile_batch_admission carrying local_preview: true and
    mobile_standard_batch: true admits the session; same 2-minute lease as the Standard batch lane.
  • Routing (admitted): every pendant frame, visible or not and including voice-command frames, goes to the lossless
    mobile Standard batch journal → /v2/sync-local-files → batch record. Frames the journal refuses (low disk, journal
    failure, the existing realtime-consumer clauses) still go to WAL + socket, as today.
  • Before the verdict: pendant frames stay off the socket (they still go to the safety WAL) with a bounded in-memory
    copy (≤500 frames ≈ 10 s). A refusal or a 10 s timeout replays the copy to the socket in order before new frames,
    so sessions that are not admitted (every user while the batch percent is 0) keep their full live transcript.
  • Engine (lib/services/live_preview/, ios/Runner/LivePreviewPlugin.swift), chosen per session:
    SpeechTranscriber (iOS 26+, locale asset already installed; no downloads) → on-device SFSpeech (existing permission
    only, never prompts; rotated every 50 s) → none. Omi's Parakeet streaming engine is not built yet
    (bundled_not_built). Pendant audio is decoded from a copy on a separate Opus decoder through a bounded queue;
    overload drops preview audio, never capture audio. Phone mic feeds from the existing PCM tap (taps are now multicast,
    onboarding unchanged).
  • UX (live transcript surface only; no new Home rows or icons): "Live preview" caption with a one-line
    explanation; settled lines in primary text, the still-changing line in secondary text; "Starting live preview…" and
    listening states; a calm "Transcribing…" state for admitted sessions with no engine; the home capture card shows the
    newest preview line in its existing last-line slot. Preview text never enters capture segments, the local segment
    store or WAL-retention evidence.
  • Android engine (android/.../livepreview/): API 33+ createOnDeviceSpeechRecognizer fed through an
    EXTRA_AUDIO_SOURCE pipe (PCM16 16 kHz mono, segmented sessions), only when isOnDeviceRecognitionAvailable and
    checkRecognitionSupport show the language installed (never downloads) → the user's already-downloaded Whisper model
    as a windowed pseudo-stream (4 s windows, final lines only) → none. Android 11–12 report os_too_old.
  • Runtime failures: SpeechAnalyzer/SFSpeech/Android recognizer errors reach Dart as engine_error; the controller
    retries selection once without the failed engine, else shows "Transcribing…". iOS stop awaits analyzer
    cancellation; a new start waits for it.
  • Never blocks capture: preview Opus decode runs on timer turns, ≤8 packets per turn.
  • Continuity: frames held before a verdict survive socket replacement and resolve against the new socket's verdict;
    frames refused during journal warm-up (and held-then-granted frames) stay in the unconfirmed safety WAL, which the
    normal recovery drain uploads via /v2/sync-local-files (replay test covers it end to end on the client).
  • Telemetry (typed registry): Live Preview Engine (engine, closed reason, platform, OS major,
    bundled_installed), Live Preview First Word (latency ms), Live Preview Session Ended (word count, audio
    seconds). No text, audio or PII.

Known gaps

  • Android native background BLE streamer (Flutter engine absent/not foreground-ready) has no batch journal, so it never
    sends local_preview (pinned by a Kotlin test): while it owns pendant audio, batch-lane users get an ordinary cloud
    session. Native journaling is a follow-up.
  • Android RECORD_AUDIO: assumed required by the recognition service even with EXTRA_AUDIO_SOURCE; without it the
    engine reports speech_permission_denied and never prompts. Unverified on a device.
  • Phone-mic capture (PCM, not journaled) never asks for local preview and keeps today's cloud transcript; the same client gate covers non-Omi devices, non-Opus codecs, auto-sync off, Transcribe Later, custom STT, kept-on-phone and onboarding.
  • Preview-to-record word disagreement is not computed yet; the session-end event carries word count and duration.
  • Not run on a physical phone, simulator or emulator. The Swift plugin is type-checked against the iOS SDK only; Android lint not run. Battery and
    thermal are not measured: this needs a 30-minute physical-phone run, preview on vs kill switch.

Screenshots (widget renders, light and dark; 001–012 iOS look, 013–024 Android look — the Android set uses the SF Pro test font because the repo has no Roboto fixture)

001-mobile-ios-live-preview-streaming-dark.png
002-mobile-ios-live-preview-starting-dark.png
003-mobile-ios-live-preview-listening-dark.png
004-mobile-ios-live-preview-no-engine-dark.png
005-mobile-ios-cloud-transcript-unchanged-dark.png
006-mobile-ios-home-card-preview-line-dark.png
007-mobile-ios-live-preview-streaming-light.png
008-mobile-ios-live-preview-starting-light.png
009-mobile-ios-live-preview-listening-light.png
010-mobile-ios-live-preview-no-engine-light.png
011-mobile-ios-cloud-transcript-unchanged-light.png
012-mobile-ios-home-card-preview-line-light.png
013-mobile-android-live-preview-streaming-dark.png
014-mobile-android-live-preview-starting-dark.png
015-mobile-android-live-preview-listening-dark.png
016-mobile-android-live-preview-no-engine-dark.png
017-mobile-android-cloud-transcript-unchanged-dark.png
018-mobile-android-home-card-preview-line-dark.png
019-mobile-android-live-preview-streaming-light.png
020-mobile-android-live-preview-starting-light.png
021-mobile-android-live-preview-listening-light.png
022-mobile-android-live-preview-no-engine-light.png
023-mobile-android-cloud-transcript-unchanged-light.png
024-mobile-android-home-card-preview-line-light.png

Testing

All from app/ via bin/omi-heavy run --:

  • flutter test --no-pub test/services/live_preview: 53 passed (admission parsing, kill switch, reason codes, wire
    parsing, volatile/final, first-word latency, header strip + copy decode, overload drops, verdict hold/replay/
    overflow/ordering, routing end to end through the replay world).
  • TZ=UTC flutter test over live_preview, wals, capture, providers, spine plus the capture-home, empty-state,
    paused-warning, perf-tick and render tests: 1748 passed, 2 skipped; render test 24/24.
  • Kotlin :app:testDevDebugUnitTest for com.friend.ios.livepreview.* (8/8) and OmiBackgroundAudioStreamerTest (21/21).
  • Full hermetic TZ=UTC bash test.sh: 7459 passed (run at the first phase-1 commit, before the replay change).
  • ruby app/ios/test/live_preview_plugin_test.rb 3 runs/26 assertions; swiftlint 0 violations; flutter analyze no new issues;
    l10n, event-registry and feature-flag registry checks clean; make preflight 46 checks with this body.

Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4445 -> 4566 | local-preview hook points (admission, routing hold, tap multicast); state lives in lib/services/live_preview/local_preview_admission.dart
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2571 -> 2600 | report whether onFrameCaptured kept the frame (lastFrameAccepted, behaviour unchanged) plus a read-only strict durability probe and a test seam for the existing storage-blocked refusal; needed so local-preview routing holds only WAL-accepted frames and keeps copies until they are durable

Product invariants affected

  • INV-CAP-1: held pendant frames (verdict window, journal warm-up) still go to the durable safety WAL; journaled frames go to the batch journal; nothing is dropped.

Failure-Class: none

🤖 Generated with Claude Code

Git-on-my-level and others added 13 commits October 26, 2026 01:26
…ase 1)

Admitted local-preview sessions (server: local_preview + mobile_standard_batch)
show an on-device streaming preview on the live transcript surface while every
pendant frame is journaled through the mobile Standard batch route; the batch
transcript is the record.

- Client declares local_preview=enabled (iOS only; kill switch
  mobile-local-preview-disabled, registered ops_kill) through
  TranscriptSegmentSocketService/factory/pool incl. the reuse key; parses
  local_preview on service_status; socket-scoped admission.
- Routing: MobileStandardBatch ignores visibility for local-preview grants,
  voice commands keep journaling, refused frames still go WAL+socket; pendant
  frames stay WAL-only until the verdict (<=10 s) and during journal warm-up so
  they never open the deferred cloud stream.
- Multicast device/phone-mic taps (onboarding slot unchanged).
- LivePreviewController (separate from segments), bounded preview-only audio
  queue with a copy-decoded Opus feed, MethodChannel engine on
  com.omi/live_preview(+/events).
- iOS LivePreviewPlugin: SpeechAnalyzer/SpeechTranscriber (installed locale
  only, no downloads) -> on-device SFSpeech (existing permission, 50 s
  rotation) -> none; closed reason codes.
- UI: Live preview caption, provisional text in secondary colour, calm
  Transcribing state with no engine, home card last line; l10n (English
  fallback in all locales).
- Typed telemetry: Live Preview Engine / First Word / Session Ended.
- Tests: controller, routing (replay world), batch lane, native policy +
  SDK type-check; render evidence for every state, light and dark.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…of CaptureController

LocalPreviewAdmission owns the socket-scoped grant, the bounded verdict hold
and the journal warm-up hold; AudioTapListeners owns the extra tap listeners.
CaptureController keeps only the hook points. No behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rds only while at the bottom

INV-PERF-1: a plain lazy ListView with a follow-to-bottom controller replaces
the reversed shrink-wrapped list. Rendered evidence is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the local-preview verdict

Pendant frames on a socket that declared local_preview are still held off the
socket until the verdict (and still written to the safety WAL), but an
in-memory copy (<=10 s / 500 frames, oldest first) is kept. A refusal (verdict
without local_preview, or no verdict within 10 s) sends the held frames to the
socket in order before any newer frame; a grant drops the copy; overflow stops
holding, flushes and resumes streaming. Socket close/replacement drops the copy
(the WAL keeps it, as for any frame captured while the socket is down). The
journal warm-up hold applies only to admitted sockets and keeps no copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A socket that closes before its local-preview verdict no longer discards the
in-memory copy of held pendant frames. The queue (still <=500 frames) is
resolved against the replacement socket's verdict: a refusal, or a replacement
that did not declare local preview, sends them first, oldest first; a grant
drops them. Only capture end or an account change discards the queue. Keeps
live-transcript continuity across a reconnect for non-admitted sessions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…through sync

Warm-up frames refused by the batch journal, and frames held then granted, go
to the safety WAL and never to the socket. An admitted session receives no
ConversationEvent, so that WAL stays unconfirmed and the ordinary recovery
drain uploads it through /v2/sync-local-files to the batch record. The replay
test drives it end to end (journal warm-up, socket silence, finalize, getMissingWals,
coordinator wake, one upload, WAL synced). README documents both paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…turn

Opus decode and engine feed now run on timer turns, at most 8 packets per
turn, instead of draining the whole queue in one microtask. A burst never
delays the next capture callback by more than one bounded slice; the tap
itself only enqueues. Test uses a deliberately slow decoder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nswers

- SpeechAnalyzer: a results task that ends or throws while the session is
  live, and SFSpeech after 3 consecutive failed requests with no words
  ("no speech" 1110 is silence, not a failure), send
  {failure: engine_error, engine} on the events channel and the session is
  released.
- start accepts `exclude` (engines that already failed this session).
- stop awaits SpeechAnalyzer.cancelAndFinishNow() before replying, and a new
  start waits for the previous session's cleanup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Runtime failures arrive as a typed LivePreviewRuntimeFailure (closed reason
engine_error) on the engine's results stream, from native failure events or a
broken event channel. The controller closes that engine's run, retries the
selection once excluding it, and otherwise settles in the calm no-engine
"Transcribing…" state; lines already shown stay. Each engine run is one
Live Preview Engine + one Session Ended event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e 2)

- LivePreviewPlugin.kt on com.omi/live_preview (+ /events), same Dart contract
  and closed reasons: API 33+ createOnDeviceSpeechRecognizer fed through an
  EXTRA_AUDIO_SOURCE pipe (PCM16 16 kHz mono extras, EXTRA_SEGMENTED_SESSION),
  only when isOnDeviceRecognitionAvailable and checkRecognitionSupport list
  the language as installed (never triggerModelDownload). Recognizer calls on
  the main looper; PCM written on one background thread behind a bounded
  queue. os_too_old (<33), speech_permission_denied (the recognition service
  checks RECORD_AUDIO even for an app audio source; never prompted),
  os_engine_unavailable, locale_unsupported, locale_asset_missing,
  engine_error. Runtime failures (repeated non-silence errors) reach Dart as
  {failure: engine_error}; `exclude` honoured.
- Fallback: Omi's already-downloaded Whisper model as a windowed
  pseudo-stream (4 s windows, one at a time, 30 s bounded buffer); else none.
- Android installs the preview controller, so it declares local_preview (same
  kill switch). The native background streamer never declares it (no batch
  journal there; pinned by OmiBackgroundAudioStreamerTest).
- Android-look renders of every state, light and dark; README, changelog
  fragment and kill-switch summary cover both platforms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level Git-on-my-level changed the title feat(app): on-device live preview for batch-lane users (iOS) feat(app): on-device live preview for batch-lane users (iOS + Android) Oct 25, 2026
Git-on-my-level and others added 3 commits October 26, 2026 02:21
…al for that socket

When the pre-verdict hold times out (10 s) or overflows (500 frames), the held
frames are already streamed to the socket. That socket is now settled as
refused: a later positive verdict on it never sets admitted, so an already
cloud-streamed session cannot look admitted. A replacement socket starts clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dant audio

The client declares local_preview only for an Omi pendant on an Opus codec
with auto-sync on, no Transcribe Later, no custom STT, audio not kept on the
phone, no onboarding and a batch journal installed (MobileStandardBatch's
per-session refusals). Otherwise it does not ask and emits
`Live Preview Not Requested` with a closed reason (also kill_switch). Phone-mic
capture therefore keeps today's cloud transcript. If one of these flips while
admitted, the grant is dropped for the rest of that socket: the preview hides,
the batch lane returns to its ordinary visibility rule, and no later grant on
that socket re-admits it. Transient refusals (disk, journal failure) keep the
WAL+socket carve-out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s its pipe and reports engine_error

begin() now opens the recognizer through LivePreviewPolicy.startOnPipe: if
setRecognitionListener/startListening throws, both pipe descriptors are closed
and the error rethrown. A failed segment restart reports a runtime failure
({failure: engine_error}) so Dart falls back instead of treating a dead engine
as running; a failed first start releases the session and answers
engine_error. A support-check answer that arrives after the timeout no longer
starts a session.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T21:22:57.026216Z b4ee109 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.

@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: 2533034dbb

ℹ️ 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".

runCatching { write.close() }
throw error
}
runCatching { read.close() }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the pipe's read end open until recognition has started

On Android 13+ devices eligible for the native preview, start(read) calls SpeechRecognizer.startListening, which only queues the intent; it does not synchronously transfer the descriptor to the recognition service. The Android framework implementation queues MSG_START and performs the service call later in handleStartListening. Closing read here therefore leaves EXTRA_AUDIO_SOURCE holding a closed descriptor when the intent is marshalled, preventing recognition from starting and potentially throwing on the main thread. Retain the read descriptor until a recognition callback confirms startup, and close it during failure/stop cleanup.

Useful? React with 👍 / 👎.

_lastResultAt = now;
_noteFirstWord(now);
}
final index = _lines.indexWhere((line) => line.id == result.segmentId);

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 Namespace preview segment IDs by engine run

After a quick socket reconnect and re-admission, revoke() intentionally preserves _lines, but each newly created native recognizer restarts its segment counter (a0 for SpeechAnalyzer, s1 for SFSpeech, or g0 for Android). Looking up results solely by that counter makes the new session overwrite earlier settled lines instead of appending: new speech appears near the beginning of the transcript, and the home card can keep showing an old last line. Include a unique engine-run prefix in the stored IDs and result lookup so hypotheses only replace lines from their own run.

Useful? React with 👍 / 👎.

Git-on-my-level and others added 5 commits October 26, 2026 03:20
… Preview Verdict)

Lead ruling d14718; observational only, no routing change. Each socket that
declared local_preview emits one typed `Live Preview Verdict`: verdict
(granted, refused, timeout, overflow, socket_closed), platform,
verdict_latency_ms (socket published to settlement), hold_duration_ms,
held_frames and hold_timeout_replayed. Renewal verdicts never emit again; a
replacement socket emits its own row; capture end settles an open socket as
socket_closed. Consumer gains live-preview-verdict.sql for p50/p95 latency by
verdict and platform and the timeout-replay rate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…WAL accepted them

LocalWalSyncImpl now reports whether the last onFrameCaptured kept the frame
(lastFrameAccepted; reporting only, its behaviour is unchanged). The capture
path passes that custody to the local-preview router: the pre-verdict hold and
the journal warm-up hold apply only to WAL-accepted frames. A frame the WAL
refused (storage blocked, 2000-frame buffer full) and the journal did not take
goes to the socket at once, after any held frames. On a grant, only
WAL-accepted held frames are dropped; any other would be sent. Replay tests
drive a storage-blocked WAL during the hold and during warm-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…still-open socket

LocalWalSyncImpl.clearUserData drops the safety WAL's in-memory tail on an
account change (pre-existing on main, unchanged here), so held pre-verdict
frames cannot rely on it. Before the admission state is cleared (account
change, capture stop, session roll), frames held for a socket that is still
connected and was not granted are sent to it in order, as on a refusal.
Granted sockets never receive them; without an open socket they are dropped
like any frame captured while the socket is down.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h, no safety WAL)

On main (86fcbcc) a BleDeviceSource exists only for Omi/OpenGlass
(capture_controller.dart:2341-2344), batch routing needs that source (:2089,
:2106), the safety WAL needs Omi/OpenGlass + Opus (:2132-2134), and a
connected socket gets the raw packet (:2148-2165). #23617 never declares
local_preview for this device and its router sends such a frame unchanged:
the test asserts the packet bytes on the socket, an empty safety WAL, no
journal file, and nothing retained without a socket, as on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The 10 s verdict deadline no longer depends on a frame arriving: a timer
(capture scheduling seam) latches it, reports the timeout and replays any held
frames to the socket at that moment; verdict() also checks expiry, so a grant
after the deadline in a quiet interval is a refusal for that socket. An
in-time verdict, close, capture end, overflow or mid-session refusal cancels
the timer.

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

@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: 58d45f6ac5

ℹ️ 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 +3761 to +3763
final localPreview = _localPreview.verdict(
granted: event.localPreview,
socketDeclared: _socket?.localPreview == true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Implement the server-side local-preview admission contract

With the backend shipped in this repository, event.localPreview is always false, so neither platform ever starts the new preview. A repo-wide search for local_preview found no serving backend implementation: /v4/listen in backend/routers/transcribe.py does not consume the query parameter, backend/models/message_event.py has no corresponding response field, and both backend/routers/listen/runtime.py::_ready_event and the renewal response in backend/routers/listen/receiver.py emit only mobile_standard_batch. Consequently, every socket is treated as refused and retains the existing cloud behavior; the routing tests conceal this by injecting local_preview: true. Add the server admission/deferred-stream implementation and an integration-level contract test before relying on this grant.

Useful? React with 👍 / 👎.

Comment on lines +233 to +234
// Queue/decoder drops are counted per packet (20 ms Opus frames).
droppedAudioMs: _droppedBytes ~/ 32 + _droppedPackets * 20,

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 Count dropped audio using the actual frame duration

For admitted pendants using BleAudioCodec.opus, queue overflows and decoder failures report twice the actual dropped audio duration. BleAudioCodec.getFramesPerSecond() specifies 100 frames/second for this codec, and getFrameSize() specifies 160 samples at 16 kHz, so each packet represents 10 ms, not 20 ms; only opusFS320 uses 20 ms frames. For example, dropping 50 ordinary Opus packets reports 1,000 ms instead of 500 ms, corrupting the session's drop-rate telemetry and comparisons between codecs. Preserve the packet's duration when enqueuing and accumulate dropped samples or milliseconds rather than multiplying every dropped packet by 20.

Useful? React with 👍 / 👎.

Git-on-my-level and others added 2 commits October 26, 2026 03:56
… at account change

- Journal warm-up no longer suppresses socket delivery for an admitted
  session: a frame the warming journal refuses goes to WAL and socket (the
  never-lose carve-out; the deferred stream it opens is counted server-side).
- Granted held frames (kept off the socket, custody = safety WAL) are copied
  (bounded, 3000) until the WAL reports them durable
  (LocalWalSyncImpl.mayHoldOnlyInMemory: still buffered or in an unflushed
  WAL; read-only).
- At capture end the copies, then any held frames of an ungranted socket, go
  to an open socket in order. On an account change with no open socket they
  are written synchronously to the batch journal for the OLD owner
  (MobileStandardBatch.preserveForOwner, used only by this path; needs only
  the journal files, not the VAD) before the account cleanup, unchanged from
  main, clears the WAL's in-memory tail. A plain stop leaves them to the WAL.
- Replay tests: account change during admitted warm-up with the socket open
  (frames reach the socket) and closed (frames journaled for the old owner).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ict a non-durable copy

- LocalWalSyncImpl.isFrameDurable (read-only) replaces mayHoldOnlyInMemory:
  a frame is durable only when a flush of the CURRENT generation wrote it to
  a disk WAL and that flush's index save completed (recorded per payload in
  an Expando just before the WAL releases its in-memory data). A WAL marked
  disk with the index still pending, or a generation superseded by account
  cleanup, is not durable. No behaviour change for other callers.
- The router never drops a copy before that. The cap is 18000 frames (2x the
  WAL's ~3 min worst-case in-memory window at 50 frames/s); at the cap it
  stops suppressing instead (a hold at the cap latches like an overflow and
  streams; granted frames past the cap go to the socket), so no flush request
  and no journal double-count are needed.
- Prune and account change filter every copy through the strict probe;
  account change with no socket preserves exactly the non-durable ones.
- Tests: strict probe across a gated index save and a cleared generation;
  cap pressure without eviction; a flush in progress treated as non-durable
  and preserved at account change; durable copies not preserved.

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

@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: b4ee109967

ℹ️ 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 +91 to +95
void initState() {
super.initState();
_scroll.addListener(() {
final position = _scroll.position;
_following = position.pixels >= position.maxScrollExtent - 48;

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 Scroll to the newest preview line on initial presentation

When the user opens the live transcript after enough preview lines have accumulated to exceed the viewport, this controller starts at offset zero. The only jump to the newest line is in didUpdateWidget, which does not run on initial mounting, so the surface displays the oldest speech until another recognition result triggers a rebuild. During silence, it remains there indefinitely, unlike the existing cloud transcript's followLatest: true behavior. Schedule an initial post-layout scroll as well as the update-time follow.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 528f97f into main Oct 25, 2026
61 checks passed
@Git-on-my-level
Git-on-my-level deleted the odpreview/mobile-local-preview-ios branch October 25, 2026 22:32
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