Skip to content

Episodes v1: live episodes over conversations (backend + mobile) - #22877

Merged
Git-on-my-level merged 15 commits into
mainfrom
lane/episodes
Oct 21, 2026
Merged

Git-on-my-level merged 15 commits into
mainfrom
lane/episodes

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What

Episodes v1: the day's conversations grouped into occasions (a lunch, a meeting, a work session), live while they happen and wrapped up when you move on. Backend plus the Flutter app, one themed PR, built to the approved boards D–I.

Architecture

An overlay, not a rewrite. An episode is a separate document (users/{uid}/episodes/{id}, speech-derived fields sealed through utils.encryption) that points at conversations. No conversation is changed by it. Per-conversation processing, smart merge, tasks and memories are untouched. Lookups are doc gets only (episode_links/current, episode_links/{conversation_id}), with no new queries or indexes. Writes are compare-and-set on state_version inside Firestore transactions.

  • Moments. The realtime fan-out (utils/app_integrations.py) cuts a moment on a ≥45s pause, at 600 words, or on a conversation change (utils/episodes/live.py, in-memory and bounded). Each moment runs on the postprocess executor, never on the socket path.
  • One cheap call per moment. episode_incremental (gpt-5-nano through the gateway, minimal reasoning) gets the previous state plus the new text only and returns a bounded delta: title, bullets, people, open questions, provisional items, and the moment heading. The prompt is a fixed prefix with the clock, state and new text last, so it is cache-friendly. The call is rate-limited per user (one per 60s; shorter moments merge), and a failed call keeps the previous state.
  • Close detection. Same-occasion is decided by the gap: under 2 min it continues; over 30 min it closes. An ambiguous gap asks Jev (episode_boundary lane, moved-on threshold 0.2, 2.5s timeout, fail-open to a 15 min fallback). There is a 3h hard cap. The POST /v1/episodes/{id}/wrap-up API closes the episode once that conversation's finalization lands.
  • Wrap-up is normal processing. "Wrap Up Now" is the existing CLIENT_FINALIZE of the in-progress conversation (process_conversation with its normal trigger), followed by the episode close. There is no second notes pass, and nothing in conversation_processing.py, the notes mount, the prompts or the conv-structure lane is touched.
  • Provisional tasks (INV-TASK-2). Items the incremental call hears are stored on the episode only. They are never written as action items or Candidates. At each conversation's finalization they are reconciled against the action items that conversation's own extraction saved: matched means kept, unmatched means dropped. This gives a shadow precision metric. In the app, Undo dismisses an item from the episode, which is optimistic and restored if the server refuses.
  • Mentor. Plumbing only: mentor_episode_state(uid) returns the live state, with a TODO in proactivity_producers.mentor_context. There are no extra reads on the mentor path.
  • Naming. The existing utils/conversations/episode_* and utils/llm/episode_* are the notes pipeline's "episodes". The new package is utils/episodes/, and utils/episodes/ARCHITECTURE.md spells out the difference.

App. EpisodeProvider is capability-gated: it starts off and stays off on a 404 or enabled: false, so an older or switched-off server keeps today's UI exactly.

  • Home (D/E). The live episode is the first row of Today: green pulsing tile, title, "Now · 24m · topics". It scrolls away with the list. A row being filled by offline sync shows a spinner and "adding 12m from your Omi" in place of the separate catching-up row. The quiet sync indicator is a thin ring around the header's device glyph; the filled row uses the same ring inline (a faint track with a turning arc), so both read as one indicator.

  • Device page (F). Status line, a stats row (battery, heard today, on device to sync), Right now (live episode link and catching-up progress), Recently (real disconnects from the native history), Controls (Pause/Resume) and a Transcription Language row.

  • Live episode (G/I). LiveEpisodePage replaces conversation_capturing/page.dart, and every entry point is repointed. It has two tabs:

    • Summary: So far with "updated N min ago · full notes when it wraps up", provisional tasks, a transcript preview, and Moments with "Now".
    • Transcript: the moved live transcript, adding moment dividers and captured items with Undo. Speaker naming, suggestion chips and photos are unchanged.
    • Header participants come from the transcript's own speaker resolution (EpisodePresentation.participants): the owner plus speakers resolved to the user's people, named exactly as the transcript names them. An unresolved "Speaker N" is never named in the header, and the model's mention list does not feed it.

    The page ends with "Wrap Up Now" and "Omi wraps this up when you move on". Pause moves to the ⋯ menu and the device page. With episodes off, the page is today's capture page unchanged (same keys, same Finish).

  • Finished conversation (H). Today's page with nothing removed, plus a collapsed Moments section when the episode had two or more moments. A one-moment episode looks exactly like today. Nested bullets render as before (see render 007).

  • There are no Live Activity or Dynamic Island changes. The new primitives OmiLiveDot and OmiActivityRing are added to app/docs/ux-contract.md.

Kill switch and ramp

  • EPISODES_ENABLED is a kill switch, on unless set off, and it is read on every request and every moment. Off means the routes answer enabled: false, no moments are recorded, the finalizer hook no-ops, and the app falls back to today's UI.

  • EPISODES_PERCENT (default 100) and EPISODES_UID_ALLOWLIST define the cohort (stable uid bucket, salt episodes-v1). The cohort is registered in config/feature-flags.yaml.

  • Ramp plan (cost risk: one nano call per moment, about 1–4 per active hour):

    1. David's account via the allowlist with EPISODES_PERCENT=0.
    2. Then 5% for 3h.
    3. Then 100%.

    Whoever runs the deploy expands it, in one config change per step. Watch:

    • per-moment calls, tokens and cost: omi_episode_moment_updates_total, omi_episode_moment_tokens_total, omi_episode_moment_cost_usd_total
    • close-reason mix: omi_episode_closed_total{reason}
    • provisional precision, kept vs dropped: omi_episode_provisional_items_total{outcome}
    • wrap-up latency: omi_episode_wrapup_latency_seconds
    • mobile crash-free sessions

    Hold if the 5% cost per active user projects above budget, if the close mix is dominated by hard_cap or fallback, or if crash-free sessions drop.

Deferred (follow-ups)

  • Interim grey words in the live transcript: the app has no interim words to show.
  • Gap markers in the transcript: no gap data reaches the app yet.
  • The Today timeline bar and the battery time-left estimate on the device page: no measured source.
  • Quiet hours: not built.
  • Find My Omi stays where it is (in Customization).
  • Immediate commit of explicit or near-time reminders. This needs the wake-word path and an INV-TASK-2 review; today they stay provisional until wrap-up.
  • Passing provisional items into the notes pass as open_tasks. That is the notes lane, owned by another agent.
  • One wrap-up notes pass over a multi-conversation episode, which would defer per-moment conversation processing.
  • The mentor prompt consuming mentor_episode_state (Episodes: mentor prompt reads the live episode state instead of the buffered transcript #22870).
  • "N moments" on finished Home rows.
  • Named people chips on H. The existing people chip is kept.
  • Jev boundary calibration: the question is uncalibrated, and the decisions are logged for it.
  • A filled-row target exists only for server sync jobs that name exactly one conversation.

Tests

  • Backend (BACKEND_UNIT_TEST_FILE_LIST + ./test.sh):
    • test_episodes_policy_state (21)
    • test_episodes_service (StrictFirestore, CAS and conflict retry, idle/hard-cap/wrap-up close, dedupe, reconcile kept/dropped, smart-merge repoint)
    • test_episodes_incremental_live (11)
    • test_episodes_router (3)
    • test_episodes_finalizer_hook (5)
    • The related suites were rerun: gateway coverage, route policy, generated compute inventory, smart-merge finalizer, realtime integrations and openapi.
  • App:
    • episode_provider_test (9)
    • episodes_ui_test (11): page with episodes on and off, the transcript tab, the Home row, Moments, device sections and the filled row
    • All existing capturing, process-now, home, pending-row and device tests pass against LiveEpisodePage.

Renders (synthetic data, widget-test renders at 393pt @3x)

Home dark
Home light
Home scrolled
Device page
Live episode
Live transcript
Finished dark
Finished light
Moments open
One moment

Renders use a fixed clock (13:30) and precached asset images. In G and I the transcript has one speaker resolved to Maya and one unresolved ("Speaker 2"); the header names only You and Maya.

Product invariants affected

  • INV-TASK-2: provisional episode items are never action items or Candidates. Only the conversation's own extraction writes tasks, and reconciliation only reads them.
  • INV-DATA-1: no routing authority changed. The new /v1/episodes calls use the existing app API client and base URL.
  • INV-UI-1 / INV-UI-3: shared primitives and tokens only. The UX contract ratchet passes, and the new primitives are documented.
  • INV-PERF-1: no frame-rate timers. The live surfaces tick every 30s, and episode polling runs only while a live surface is on screen.
  • INV-CAP-1: merged in from test: make flaky Dart, backend, and desktop Swift tests deterministic #22987, whose only production-file change is an optional, default-off scheduleTimeout seam in recording_transfer_coordinator.dart. With no scheduler injected, pendant frame delivery, retention and resume behavior are unchanged; the capture_live_recovery_test guards pass 20/20.

Failure-Class: none

Line-Count-Exception: app/lib/providers/device_provider.dart | 1615 -> 1624 | disconnectHistory() reuses the provider's injected BLE diagnostics seam for the device page's Recently section; moving it out would duplicate that seam

🤖 Generated with Claude Code

Loading
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