Skip to content

fix(live-preview): instant on-device words again; preview on the Home row; no tile dot - #23819

Merged
Git-on-my-level merged 4 commits into
mainfrom
lane/live-preview-hotfix
Oct 27, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
lane/live-preview-hotfix

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What David saw on TestFlight 1.0.579

Causes and fixes

  1. The iOS SpeechAnalyzer stalled or failed. feat(mobile): live preview polish — Home row line, Continues chip, on-device live notes, transcript divider #23805 gave every AnalyzerInput a wall-clock bufferStartTime, derived from when each BLE burst arrived. Those start times overlap or leave gaps between consecutive buffers. The analyzer then stalls, or its results stream fails. Once two engines fail, the controller settles in unavailable, and the transcript page falls back to the cloud-only view with the "Uploading Ns of audio" pill.
  2. The Home row hid the preview once any final line arrived. It was gated on capture.segments.isEmpty, and on a batch session the first final lines land within about a minute.
    • Fix: line two now shows the newest preview words not yet covered by the final transcript (LivePreviewCoverage.uncovered), for the whole session. It redraws as words arrive instead of on the 1 s clock tick.
  3. The tile showed a dot. It now shows the running length alone.

Verification

  • flutter test test/widgets/episodes_ui_test.dart test/widgets/live_preview_render_test.dart test/services/live_preview/: all 258 pass.
  • A new test checks that the row keeps the preview after final lines arrive and updates without waiting for a clock tick.
  • Not verified here: the SpeechAnalyzer behaviour on a physical phone. David's TestFlight QA is the gate for this lane, per the 10-25 on-device preview ruling.

UI evidence

Home row Largest text
Home live row Home live row, largest text

David's TestFlight QA is the gate for the on-device preview lane (ruling 10-25).

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Git-on-my-level and others added 3 commits October 27, 2026 23:49
…Home row; drop the tile dot

- iOS SpeechAnalyzer: feed buffers on the analyzer's own contiguous timeline and
  add the first sample's wall clock to result times. #23805 stamped each buffer
  with a wall-clock start; bursty BLE delivery makes those overlap or gap, and
  the analyzer stalls or fails, which drops the session to the no-engine view.
- Home live row: line two shows the newest preview words the final transcript
  does not yet cover for the whole session (it hid them once any final line
  arrived), and redraws as words land instead of on the 1 s clock.
- Home tile: the running length alone, no dot.

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

chatgpt-codex-connector Bot commented Oct 27, 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-27T17:07:55.260919Z 4d19a04 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: 61bcc9ad5b

ℹ️ 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 +275 to +276
if origin == nil { origin = startedAt }
if case .dropped = continuation.yield(AnalyzerInput(buffer: buffer)) { return false }

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 audio-time gaps when mapping analyzer results

When preview audio is dropped, a single origin plus the analyzer's contiguous timeline no longer represents the audio's wall-clock time. LivePreviewController._enqueue and _flush deliberately drop packets/chunks on overload, and the native input stream can also evict buffers. Ignoring every subsequent startedAt compresses those gaps permanently, so later words receive timestamps earlier than their actual audio. LivePreviewCoverage.uncovered can then hide those new words against final segments for older audio, on both Home and the transcript page. Keep analyzer input contiguous, but retain a piecewise mapping from accepted input offsets to capture timestamps (or restart/rebase after a discontinuity).

Useful? React with 👍 / 👎.

… has no dot; drop dead liveTile

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 5f2caea into main Oct 27, 2026
44 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/live-preview-hotfix branch October 27, 2026 17:35
Git-on-my-level added a commit that referenced this pull request Oct 28, 2026
…rst build, device perf harness (#23859)

* fix(mobile-perf): physical iOS batches die on macOS bash 3.2 before launch

HOST_GUARD is empty on every physical-device run, and macOS /usr/bin/env bash
(3.2) treats "${HOST_GUARD[@]}" of an empty array as unbound under set -u, so
every physical iPhone batch failed before receipt 1. Expand it only when set.

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

* fix(mobile-perf): frame total spans go negative on iOS 27 devices

On an iPhone 15 Pro Max (iOS 27.0.1) about one frame in seven starts building
~0.85 ms before its recorded vsync, so FrameTiming.totalSpan (raster finish -
vsync) is negative. Total p50/p90 were contaminated in every window, and
cold_start's p50 went negative, failing report validation for every batch.
Measure total from the earlier of vsync and build start. This changes the total
metric: earlier total percentiles are not comparable; qualify a new baseline.

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

* test(mobile-perf): live preview, live episode, Device Settings and On the Way windows

Three heavy-profile windows after the unchanged five, for the changes in
#23819, #23822 and #23853:

- home_live_preview: Home with the live episode row while a scripted on-device
  preview revises its newest line every 200 ms over a ~1,000-segment session
  (LivePreviewCoverage on every update and clock tick).
- live_episode_page: LiveEpisodePage on the transcript tab over the same
  session, scrolled while words arrive.
- device_settings_on_the_way: Device Settings (Catching up) and On the Way
  (day-grouped) over the 6,500-WAL backlog, each opened and scrolled.

The preview controller is installed through CaptureController.installLivePreview
and admitted through LivePreviewController.admit; only the socket admission flag
is asserted, since the fixture runs no listen socket. Device Settings gets an
interface fake: the production DeviceProvider subscribes to ServiceManager,
which this harness never initializes. Reports now require the eight windows;
comparisons list windows absent from the reference instead of failing.

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

* chore(changelog): heavy perf harness windows (internal only)

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

* test(mobile-perf): main-isolate stalls, field-shaped WAL index and an idle sync window

The field lag log that matters (iPhone 15 Pro Max, 10-26) is 133 main-isolate
stalls, mostly on idle Home and around sync phases, with a 71,536-record WAL
index. Drawn-frame timings could not see any of it.

- HeavyStallProbe: every window reports stalls over 50/100 ms, blocked time and
  the worst stall from a 20 ms timer's late ticks; reported, never variance-gated.
- --synced-wals N (0..80000): adds synced history on top of the pending
  backlog; such a batch changes the dataset and is never baseline-eligible.
- home_idle_sync_refresh: Home left alone while SyncProvider refreshes the
  inventory five times, as sync phase ends and upload callbacks do.
- Runner preflight: refuses a phone that is not on a wired USB connection
  before the multi-minute build.

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

* perf(home): live row computes uncovered preview once per clock tick

The Semantics label called previewText() twice per 1 s rebuild; each call runs
LivePreviewCoverage.uncovered over every final segment.

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

* perf(mobile): live transcript opens at the newest rows; Tasks first frame stays cheap

Measured on an iPhone 15 Pro Max (heavy profile harness):
- Opening LiveEpisodePage on the transcript tab took one 153 ms layout with
  1,775 builds (140-157 ms every run) and peaked RSS at 612 MB: following the
  latest jumped to maxScrollExtent on a variable-height lazy list, laying out
  every row. TranscriptWidget now anchors layout at the newest segment; a
  1,000-segment open builds 9 rows and lands on the newest.
- Preview revisions (every ~200 ms) no longer rebuild the transcript or rescan
  final history: LivePreviewCoverage prepares merged final spans once per
  transcript snapshot and answers each line by binary search, same results.
- The first Tasks tab switch spent 128 ms in one build (240-319 ms frame):
  ActionItemsPage now uses one lazy delegate across date sections, deferring
  offscreen sorting, headers and rows.

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

* perf(sync): WAL index work scales with what changed, not with every record ever kept

A heavy phone's index held 71,536 records (66,222 synced). Its lag watchdog
logged 133 main-isolate stalls over ~10 h (24 s blocked, worst 1.6 s), mostly
on idle Home and ~20x more often right after sync phases and uploads. Every
index save copied, keyed and fingerprinted every record on the main isolate
and copied the full List<Wal> into an encoding isolate; sync screens rescanned
the inventory on every notify; reconcile polled ~2/s after a reconnect.

- Saves: Wal persisted-field setters mark dirty identities; a long-lived index
  worker owns the serialized rows and receives only changed JSON maps and
  removed tokens. Durable is acknowledged only after flush + atomic rename;
  failed deltas are retained and retried. No whole-index fingerprint.
- Load: decode and Wal construction run off-isolate; the worker seeds
  unchanged rows from disk, so the first save sends zero unchanged records.
- Format: unchanged version-1 wals.json, backup and quarantine recovery;
  retired/foreign/synced records and upload-order tie-breaks preserved.
- Views: SyncProvider derives pending/uploaded/attention/refusal lists and
  per-day totals incrementally (WalDerivedViews); Home, On the Way and Device
  Settings read them. Integration and widget fakes derive the same views from
  their raw inventory (WalDerivedSyncViews).
- Reconcile: visits uploaded rows only, joins an active pass, spaces passes by
  20 s; job backoff, fairness and acknowledgement unchanged.

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

* perf(mobile): newest-anchored transcript renders short lists on the first frame

The newest-anchored layout needed extra frames for its anchor correction, so a
short live transcript (even one segment) was blank on its first frame;
capturing_empty_state_test failed 20 of 23. The viewport now measures its anchor
and initial latest position during layout, before paint. Short transcripts show
immediately; a 1,000-segment open still builds about one screen of rows. The
extra pumps added to episodes_ui_test are removed.

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

* fix(mobile): live transcript keeps the reader's row fixed when rows above grow

Review finding (GLM): on a short scrollable live transcript, a photo group or
an older row growing during a drag or fling changed the newest-anchored
viewport's anchor with pixels unchanged, moving every visible row by the
inserted height under the reader's finger, and the correction bailed for the
whole gesture. The viewport now compensates the leading-edge shift with
offset.correctBy in the same layout pass. Regression tests cover short and
long histories, photo insertion/growth and older-row growth across drag, fling
and idle; first-frame rendering and 1,000-segment laziness still hold.

Failure-Class: none

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

* fix(sync): WAL index worker death, backup seeding and repair writes recover in-session

Review findings (GLM) on the delta index worker:
- A dead worker isolate (OOM/VM kill) left apply() awaiting forever, wedging
  every later save and the capture flush queue. Exit/error listeners now fail
  pending requests and release the queue; the replacement worker is seeded from
  a full snapshot of the in-memory index, preserving tokens, admitted deltas
  and every custody bucket.
- After loading from the backup because wals.json was corrupt and could not be
  quarantined, the worker seeded from the corrupt main file and every save
  failed for the session. Workers now receive the exact source the loader
  validated; a failed startup retries from memory.
- The load-time invalid-entry repair used the legacy whole-file writer on the
  same wals.json(.tmp) as the live worker with no shared lock. Loading,
  quarantine/repair, worker seeding and writes now share one lock.

Every failure fails closed: no durable acknowledgement before flush + rename.

Failure-Class: none

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

* test(mobile-perf): field-shaped synced WALs survive the startup retention sweep

Dated syncedAt stamps were older than the synced-copy retention cutoff, so the
startup sweep removed all seeded synced records and Home saw only the pending
backlog. Legacy syncedAt 0 is never auto-removed, matching a long-lived phone.

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

* refactor(mobile): move transcript row highlight and live viewport into a part file

Keeps transcript.dart under its line-count ratchet (1590) after the
newest-anchored viewport landed; no behavior change.

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

* chore(dead-code): allowlist the derived sync views shared by SyncProvider stand-ins

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

* test(mobile-perf): timeline runs name each widget build

Attribution-only runs (never baselines) enable debugProfileBuildsEnabled so a
slow first build, such as the first Tasks switch, names its widget in the trace.

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

* fix(mobile): transcript scroll reporting stays bounded by the visible rows

Device regression (iPhone 15 Pro Max, 3 runs before/after): opening a saved
conversation's transcript and flinging it went from 0/101/100 ms of main-isolate
stalls per run to 223/257/116 ms. The trace put ~15% of samples in
_TranscriptPlaybackScrolling._reportTopVisibleSegment, which walked the sliver
tree on every scroll notification. Sliver discovery is now cached, each sliver
needs one reveal calculation, and remaining row positions use existing layout
offsets; first-frame layouts and reveal calls per frame are unchanged from 120
to 1,200 rows (test).

Failure-Class: none

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

* feat(mobile): kill switch for the delta WAL index writer

PostHog mobile-wal-delta-index-off (ops_kill, default false). True makes
the next launch save every index change through the pre-delta
full-snapshot writer; both writers produce the same version-1 file, so
flipping either way needs no migration. Read once per process with a 1 s
bound; offline or failed reads keep the delta writer on.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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