Skip to content

perf(episodes): keep the live-episode surfaces O(1) per capture notify - #23278

Merged
Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/lag-hillclimb
Oct 22, 2026
Merged

Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/lag-hillclimb

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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:

  • The live episode page rebuilt its whole tree through a page-root 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 a SpeakerNames resolver for the three-line preview.
  • The live transcript rebuilt its timeline from scratch on every notify (live_transcript_view.dart): a fresh copy of every segment, a SpeakerNames resolver 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):

  1. 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) and tab_switch (Home↔Tasks IndexedStack round trips). Lines arrive through the production CaptureProvider.onSegmentReceived seam; the live episode is served behind the real episodes API client by the loopback proxy; test_driver/integration_test_driver.dart allows the same harness on a device via flutter drive --profile for genuine build/raster splits.
  2. 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 shared SpeakerNames resolver are memoized on (transcript version, people list identity). _legacyPage (episodes off) is untouched.
  3. 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.
  4. perf(episodes): deterministic notify guards — test/perf/live_episode_notify_perf_test.dart pins all of the above; also scopes the live-dot isolation test's finders to the dot.

Merged current main (931fb56's LiveStartAnchor) 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 + SpeakerNames resolver + 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):

per 20 notifies Before (d98c95d) After
page-shell widget rebuilds — notifies that change nothing 12,280 0
page-shell widget rebuilds — 20 arriving lines 12,280 900 (header + 3-line preview only)
ConversationDetailTabs / _LiveSummaryTab 20 / 20 0 / 0
_MomentRow (24 moments) 480 / 480 0 / 0
_ItemRow (8 captured items) 160 / 160 0 / 0
_SoFarCard 20 / 20 0 / 0
_TranscriptPreview 20 / 20 0 / 20 (the preview follows the transcript)
Text widgets 2,180 / 2,180 0 / 180
whole-transcript derivation runs — 20 no-op capture notifies 20 0
whole-transcript derivation runs — 20 device notifies 20 0
whole-transcript derivation runs — 20 arriving lines 20 20 (once per line: its own row)

On the base, each of those shell rebuilds also walked the whole transcript once for EpisodePresentation.participants and once for the preview's SpeakerNames (1:1 with the _LiveSummaryTab counts); 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 and capture suites (episodes_ui_test, capturing_*, capture_*, first_capture, needs_attention) — 119 pass, 2 skipped by design.
  • Home suites (test/widgets/home/ + Home widget tests) — 108 pass. Device suites — 47 pass.
  • The guard test run against d98c95d prints the before column above and fails its pins (expected: the fixes are what it guards).
  • flutter analyze clean on the changed files; INV-PERF-1 ratchet (check_mobile_ui_isolate.py --base origin/main) clean across both changed app/lib files.

Tests

test/perf/live_episode_notify_perf_test.dart is the regression test for both defects: it fails on the pre-fix code with the before counts above. The harness scenarios extend integration_test/perf for 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

View guided diff

Git-on-my-level and others added 5 commits October 22, 2026 13:13
…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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-22T09:40:20.616813Z d4f15ce PR opened
ℹ️ 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: 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);

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 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 👍 / 👎.

Comment on lines +435 to +438
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>[],

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 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 👍 / 👎.

Comment on lines +15 to +17
Future<void> main() => integrationDriver(
timeout: const Duration(minutes: 40),
writeResponseOnFailure: 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 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 👍 / 👎.

Comment on lines +3 to +4
/// Drives the perf harness on a real device or simulator so `engine_frame_timing`
/// carries genuine build/raster splits (host flutter-tester cannot raster):

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 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 👍 / 👎.

Comment on lines +162 to +166
final key = Object.hash(
provider.segmentsPhotosVersion,
provider.segments.length,
identityHashCode(provider.segments),
identityHashCode(provider.photos),

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 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 12dafd8 into BasedHardware:main Oct 22, 2026
40 checks passed
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