Repository navigation
perf(episodes): keep the live-episode surfaces O(1) per capture notify - #23278
Conversation
…ames Stage 2 of the interaction harness: home_live_scroll (Home under a live episode — episodes on, a streaming capture with a long transcript, the pulsing row and the 1-second clock while flinging), episode_page (the live episode page, summary and transcript tabs, lines still arriving), device_page (Device settings with a connected pendant and a sync in progress) and tab_switch (the shell's Home↔Tasks IndexedStack switch). Transcript lines arrive through the production onSegmentReceived seam; the live episode is served behind the real episodes API client by the loopback proxy. Budgets for the new scenarios start at the bootstrap gate (100 ms p90) like Stage 1's did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The live episode page rebuilt its whole tree through a page-root Consumer<CaptureProvider>: every transcript line, photo, metric sample or progress notify rebuilt the header, both tabs and the wrap-up bar, and each rebuild re-walked every transcript line to name participants and resolve speaker names. A capture notifies several times a minute while live, so the cost grew with the transcript length for as long as the page was open. The shell now selects only what it derives (listening, anything capturing, pausability); the transcript keeps subscribing itself; the summary's notes, tasks and moments rebuild on episode changes (the 30-second poll), and only the three-line preview selects the transcript version. The header and preview share a memoized SpeakerNames and participant list keyed on the transcript version and the people list. Interaction harness (integration_test/perf, LIVE_SEGMENTS=600, host flutter-tester, median of 3): ConversationDetailTabs 33->2, _MomentRow 48->24, OmiButton 59->29, OmiIconButton 59->24, p90 32.5-38.9 -> 26.8-29.0 ms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every capture notify rebuilt the live transcript's timeline from scratch: a copy of every segment, a speaker resolver over the whole conversation, the episode's moment/item decoration scan (moments x segments), a photo re-sort and re-group — all on the UI isolate, again and again for as long as the capture ran and the transcript grew. The state now memoizes the snapshot, resolver, decorations and photo groups behind one key (transcript version, list identities and lengths, people identity, episode instance, conversation id), so a notify that changes none of them rebuilds nothing and a new line costs only its own row. Session resets that swap the segment list without a version bump are covered by the list identity in the key. Interaction harness (integration_test/perf, LIVE_SEGMENTS=600, host flutter-tester, median of 3, on top of the live-page notify fix): episode_page jank 227-253 -> 58-209 frames over 16.67 ms, p90 26.8-29.0 -> 12.6-25.0 ms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds test/perf/live_episode_notify_perf_test.dart, the deterministic proof for the two notify fixes: with a 600-line transcript, a 24-moment episode and 8 captured items (20 notifies per phase, rebuild counts via debugOnRebuildDirtyWidget, derivation runs counted by the timeline snapshot's list identity): - capture notifies that change nothing shown: 0 shell widget rebuilds and 0 whole-transcript derivation runs (12,280 rebuilds and 20 derivation runs on the pre-fix base, d98c95d) - arriving lines: the header and the three-line preview rebuild (900 widget rebuilds for 20 lines) and the timeline re-derives once per line; the shell (tabs, running notes, tasks, moments, wrap-up bar) rebuilds 0 (12,280 before) - a device notify, the transcript's other subscription, re-derives nothing (20 full derivation runs before) Also scopes the live-dot isolation test's FadeTransition finders to the dot so any future surrounding fade cannot mask a regression, and adds the mobile changelog fragment for the two fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's 931fb56 gave the running length a stable LiveStartAnchor; that landed on the pre-fix header. The merge keeps our Builder-scoped, memoized header and threads the anchor through both elapsed() calls, so the anchor change and the notify-scope fix compose. 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: d4f15ce2da
ℹ️ 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".
| // transcript (or the people list) actually changes, not on every capture notify. | ||
| return Builder( | ||
| builder: (context) { | ||
| context.select<CaptureProvider, int>((c) => c.segmentsPhotosVersion); |
There was a problem hiding this comment.
Invalidate the summary when the segment list is reset
When a still-streaming capture receives ConversationProcessingStartedEvent, CaptureController._resetStateVariables() replaces segments with [] and notifies without advancing segmentsPhotosVersion (capture_controller.dart:1240-1254 and 3641-3645). Because source, listening state, and pausability stay unchanged, neither the page-root selector nor this selector (nor the preview selector at line 463) rebuilds, so Summary can keep old participants and the last three lines after the transcript timeline has cleared. Include segment-list identity/length in the selectors and memo keys, or bump the version whenever these lists are replaced.
Useful? React with 👍 / 👎.
| List<SingleChildWidget> providersFor(String name, PerfWorld world) => switch (name) { | ||
| 'home_live_scroll' || 'episode_page' => liveEpisodeProviders(world), | ||
| 'device_page' => [ChangeNotifierProvider<SyncProvider>.value(value: _PerfSyncProvider())], | ||
| _ => const <SingleChildWidget>[], |
There was a problem hiding this comment.
Include live providers in the tab-switch scenario
For tab_switch, this switch selects the empty-provider branch, so boot installs the unrelated empty CaptureProvider from PerfWorld.boot and no EpisodeProvider. However, runLiveScenario later calls deliverLiveSegments(world) around every switch; those notifications hit world.capture, which no rendered widget listens to, and ConversationsPage has no live row. The scorecard therefore measures plain tab switching rather than tab switching under the claimed live-capture notification load; include tab_switch in liveEpisodeProviders and assert that the live row is present.
Useful? React with 👍 / 👎.
| Future<void> main() => integrationDriver( | ||
| timeout: const Duration(minutes: 40), | ||
| writeResponseOnFailure: true, |
There was a problem hiding this comment.
Remove host-filesystem assumptions from the device driver
Under the documented physical-device invocation, the test target runs in the app sandbox, but perf_main immediately calls indexWidgetSources(), which executes Directory('lib').listSync() in perf_scorecard.dart, and each gate later reads the unbundled relative file integration_test/perf/budgets.json. Neither path is declared as an app asset, so this new driver fails before it can populate reportData; writeResponseOnFailure cannot preserve a scorecard that was never emitted. Skip the source scan on device and bundle/load the budget data through a device-safe mechanism.
Useful? React with 👍 / 👎.
| /// Drives the perf harness on a real device or simulator so `engine_frame_timing` | ||
| /// carries genuine build/raster splits (host flutter-tester cannot raster): |
There was a problem hiding this comment.
Mark device scorecards as device measurements
When this new driver is used, perf_main.dart still hardcodes the scorecard lane to host_flutter_tester, while perf_scorecard.dart labels the top-level measurement host_ui_pipeline_wall_clock and leaves top-level raster data null. Thus any physical-device artifact is indistinguishable from a host run to aggregators and comparisons even though engine_frame_timing now contains genuine device data. Pass a device lane/measurement mode into the target and label the scorecard accordingly.
Useful? React with 👍 / 👎.
| final key = Object.hash( | ||
| provider.segmentsPhotosVersion, | ||
| provider.segments.length, | ||
| identityHashCode(provider.segments), | ||
| identityHashCode(provider.photos), |
There was a problem hiding this comment.
Invalidate speaker-name caches on locale changes
If the app locale changes while this state remains mounted, this key is unchanged because it only includes transcript/provider identities, so _timelineNames keeps the old AppLocalizations captured by SpeakerNames.forSegments; owner and anonymous-speaker labels remain in the previous language until another transcript change. The same dependency is omitted from _speakerNames and _participantsMemo on the live page, leaving its preview/header stale too. Include the current locale or AppLocalizations identity in all three cache keys so these user-facing labels continue to follow context.l10n.
AGENTS.md reference: app/AGENTS.md:L116-L118
Useful? React with 👍 / 👎.
What changed and why
David's October 2026 lag report (TestFlight 1.0.571+, episodes on) names the surfaces episodes added, but the interaction harness only measured the four Stage-1 surfaces, and the two live-episode surfaces paid O(transcript) work on every capture notify — several times a minute, for as long as a capture ran and the transcript grew:
Consumer<CaptureProvider>(live_episode_page.dart): every transcript line, photo, metric sample or progress notify rebuilt the header, both tabs' scaffolding and the wrap-up bar, and each rebuild re-walked the entire transcript to name participants (EpisodePresentation.participants) and to build aSpeakerNamesresolver for the three-line preview.live_transcript_view.dart): a fresh copy of every segment, aSpeakerNamesresolver over the whole conversation,LiveTranscriptDecorations.of(a segments scan per episode moment and per captured item), and a photo re-sort/re-group into 30-second buckets — all on the UI isolate, again on every notify from either provider it subscribes to.This PR (harness + both fixes + deterministic guards, four commits):
perf(harness)— Stage-2 scenarios for the reported surfaces:home_live_scroll(Home with the episodes overlay on, a streaming capture and the pulsing live row while flinging),episode_page(Summary and Transcript tabs with lines arriving),device_page(a connected pendant mid-sync) andtab_switch(Home↔Tasks IndexedStack round trips). Lines arrive through the productionCaptureProvider.onSegmentReceivedseam; the live episode is served behind the real episodes API client by the loopback proxy;test_driver/integration_test_driver.dartallows the same harness on a device viaflutter drive --profilefor genuine build/raster splits.perf(episodes): stop rebuilding the live page on every capture notify— the shell selects only what it derives (listening state, anything capturing, pausability); the transcript keeps subscribing itself; the summary's notes, tasks and moments follow episode changes (the 30-second poll), not transcript lines; only the three-line preview and the header select the transcript version, and the header's participant list and the sharedSpeakerNamesresolver are memoized on (transcript version, people list identity)._legacyPage(episodes off) is untouched.perf(episodes): memoize the live transcript's per-notify derivations— the membership snapshot, speaker resolver, decorations and photo groups are computed behind one key (transcript version, segment/photo list identity and length, people identity, episode instance, conversation id), so a notify that changes none of them re-derives nothing, and a new line costs only its own row.perf(episodes): deterministic notify guards—test/perf/live_episode_notify_perf_test.dartpins all of the above; also scopes the live-dot isolation test's finders to the dot.Merged current
main(931fb56'sLiveStartAnchor) into the fixed header so the anchor change and the notify-scope fix compose. Visual design, text, layout and behavior are unchanged.Before and after (deterministic counts)
test/perf/live_episode_notify_perf_test.dart: a 600-line transcript, a 24-moment episode and 8 captured items; 20 notifies per phase. Rebuild counts are exact widget-rebuild counts (debugOnRebuildDirtyWidget); one derivation run = one pass of the timeline block (segment snapshot copy +SpeakerNamesresolver + moments×segments decoration scan + photo regroup), counted by the snapshot's list identity. The same test file was run against the pre-fix base (d98c95d, harness only; it fails its guards there, after printing the before column):On the base, each of those shell rebuilds also walked the whole transcript once for
EpisodePresentation.participantsand once for the preview'sSpeakerNames(1:1 with the_LiveSummaryTabcounts); after, they run only when the transcript version changes. Idle notifies now dirty nothing but the provider's own_InheritedProviderScope.Honest wall-clock note: three interleaved A/B rounds of the interaction harness on this shared host were noise-dominated (untouched scenarios swung 5–10× round to round; untouched journeys' p95s crossed between arms), so no frame-time improvement is claimed from host timing — the deterministic counts above are the evidence, and they are exact. On-device timing remains available through the Stage-2 scenarios via
flutter drive --profile.How it was verified
flutter test test/perf/— 23 tests, including the new guard and the live-dot isolation (all pass).episodes_ui_test,capturing_*,capture_*,first_capture,needs_attention) — 119 pass, 2 skipped by design.test/widgets/home/+ Home widget tests) — 108 pass. Device suites — 47 pass.flutter analyzeclean on the changed files; INV-PERF-1 ratchet (check_mobile_ui_isolate.py --base origin/main) clean across both changedapp/libfiles.Tests
test/perf/live_episode_notify_perf_test.dartis the regression test for both defects: it fails on the pre-fix code with the before counts above. The harness scenarios extendintegration_test/perffor the reported surfaces.UI-Evidence: none -- no visual change; identical widget content and layout, only rebuild scope and memoization.
Store source and release
Present in current TestFlight (1.0.571+): both derivation paths predate the episodes overlay rollout. Includes the mobile unreleased changelog fragment. No merge, deploy or release dispatch performed.
Product invariants affected
INV-PERF-1: listeners that run on every notify must be O(1) when nothing relevant changed; this moves the live page's and the live transcript's per-notify cost from O(transcript) to O(1) until the transcript actually changes, and extends the harness to the surfaces where notification amplification actually reproduces.
Failure-Class: none
🤖 Generated with Claude Code