Repository navigation
feat(app): batch speaker labeling session with deferred summary reprocess - #21121
Conversation
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: 7d4da9750b
ℹ️ 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".
| segments: provider.conversation.transcriptSegments, | ||
| unresolvedSpeakers: provider.conversation.speakerResolution?.status == 'unavailable', | ||
| // The name heads a turn; naming it names that voice's lines, which the sheet lists to uncheck. | ||
| defaultApplyToSpeaker: true, |
There was a problem hiding this comment.
Avoid grouping unresolved voices by raw speaker ID
When speakerResolution.status == 'unavailable', equal raw speaker IDs from different recordings are explicitly not comparable, but this default preselects every segment with the same ID and saves them through the bulk speakerId path unless the user manually unchecks them. Naming one turn can therefore relabel unrelated voices in a merged conversation; keep bulk-by-voice off for unresolved conversations.
AGENTS.md reference: app/AGENTS.md:L3-L4
Useful? React with 👍 / 👎.
| } else if (target.status == ConversationStatus.completed && target.structured.overview.trim().isNotEmpty) { | ||
| _automaticSpeakerSummaryRefreshIds.add(target.id); | ||
| if (!_isDisposed && identical(conversationOrNull, target)) _speakerSummaryConversationId = target.id; |
There was a problem hiding this comment.
Clear pending refresh when undo removes every edit
When the user labels a line and then undoes the only action, the undo stack and displayed count become empty, but the original assignment's _automaticSpeakerSummaryRefreshIds entry remains and this successful restore adds/retains it. Pressing Done consequently reprocesses the conversation even though the transcript is back to its original state, recreating the unnecessary summary churn this session is intended to avoid.
Useful? React with 👍 / 👎.
| Future<void> _undoLabel(ConversationDetailProvider provider) async { | ||
| OmiHaptics.light(); | ||
| final undone = await provider.undoLastSpeakerLabel(); | ||
| if (!undone && mounted) OmiFeedback.error(context, context.l10n.failedToSaveCheckConnection); |
There was a problem hiding this comment.
Rewind deferred outcome when undo succeeds
After a person assignment saves, _deferredOutcome records that assignment, but a successful Undo only restores the provider state and leaves this value unchanged. Pressing Done after undoing the last assignment—or undoing Jordan after an earlier Maya assignment—therefore shows an outcome card for a label that no longer exists; update or clear the deferred outcome along with the undo.
Useful? React with 👍 / 👎.
| TextField( | ||
| controller: _search, | ||
| onChanged: (_) => setState(() {}), | ||
| decoration: InputDecoration(hintText: l10n.searchPeople, prefixIcon: const Icon(Icons.search, size: 18)), |
There was a problem hiding this comment.
Replace the picker search with OmiSearchField
The app UI contract requires searches to use OmiSearchField, but the new people search introduces a locally configured TextField. This bypasses the repository's shared search behavior and styling, including the standard clear affordance; use the shared primitive as other people/contact pickers do.
AGENTS.md reference: app/AGENTS.md:L3-L4
Useful? React with 👍 / 👎.
| void beginSpeakerLabelingSession() { | ||
| final target = conversationOrNull; | ||
| if (target == null || _labelingSessionId == target.id) return; | ||
| _labelingSessionId = target.id; | ||
| _labelingUndo.clear(); | ||
| _endedSpeakerLabelingSessionIds.remove(target.id); | ||
| _confirmedSpeakerLabelingSessionIds.remove(target.id); |
There was a problem hiding this comment.
Carry labeling state across sync bridge redirects
For a sync-donor conversation, a successful speaker save calls refreshConversation(), which can replace the donor ID with its bridged survivor and migrates the existing summary-refresh IDs, but not the new _labelingSessionId or confirmed-session state. Once the cached conversation has the survivor ID, speakerLabelingSessionActive becomes false, the bar disappears, and neither Done nor page exit regenerates the summary for the saved labels; migrate the labeling session and its undo/confirmation state when adopting the survivor.
Useful? React with 👍 / 👎.
| for (final MapEntry(key: (isUser, personId), value: ids) in groups.entries) { | ||
| final saved = await _assignSpeaker(target.id, ids, isUser: isUser, personId: personId); | ||
| if (!saved) { | ||
| _rollbackSpeakerAssignment(target, restore.keys.toList(), current, generation, null); | ||
| return false; |
There was a problem hiding this comment.
Handle partial failures while restoring mixed labels
An undo covering lines with different previous labels sends one restore request per group. If an earlier group succeeds and a later group returns false or throws, this path rolls every local line forward to current, even though the server has already restored the successful group, leaving the UI inconsistent with persisted data and discarding the undo entry; either compensate the completed groups or preserve the per-group server result and retry state.
Useful? React with 👍 / 👎.
| if (selected != null && toggle != null) { | ||
| final isSelected = selected.contains(data.id); | ||
| // The line's own targets (the name, the words) stand down: a tap anywhere toggles the check. | ||
| line = Semantics( | ||
| button: true, | ||
| selected: isSelected, | ||
| child: GestureDetector( | ||
| key: ValueKey('transcript_select_${data.id}'), | ||
| behavior: HitTestBehavior.opaque, | ||
| onTap: () { | ||
| OmiHaptics.selection(); | ||
| toggle(data); |
There was a problem hiding this comment.
Exclude Omi speech from line-selection labeling
Selection mode adds a labeling toggle to every detail line, including segments whose speakerId is omiSpeakerId; the normal speaker target deliberately disables naming those segments. A user can now select Omi speech and choose “You,” which sets isUser and persists the assistant's words as the owner's speech, violating the transcript's fixed Omi attribution; omit these segments from selection or disable their toggles.
AGENTS.md reference: app/AGENTS.md:L3-L4
Useful? React with 👍 / 👎.
| try { | ||
| await previousSave; | ||
| if (_speakerEditGenerationByConversation[target.id] != generation) return false; |
There was a problem hiding this comment.
Roll back an undo superseded by a newer label
Undo applies the restored values optimistically before awaiting the save queue. If another label is started while that queue is still blocked, it advances the conversation generation, causing this early return; any restored lines not touched by the newer label remain reverted locally even though no restore request reached the server, and the popped undo entry is no longer retryable. Serialize edits during undo or roll those optimistic values forward before returning false.
Useful? React with 👍 / 👎.
| for (final person in visible) | ||
| OmiFilterChip( | ||
| key: Key('speaker_quick_picker_person_${person.id}'), | ||
| label: person.name, | ||
| selected: false, | ||
| onSelected: () => _pick(person.id, person.name), | ||
| ), |
There was a problem hiding this comment.
Bound the people rendered by the quick picker
When the account has many saved people, the initial empty-query state puts every person into a Wrap inside a SingleChildScrollView, so opening the picker eagerly builds and lays out the entire collection even though a search field is available. Unlike the existing name-speaker picker, which caps its initial grid, this can make the sheet noticeably slow or unusable for large people lists; cap the unfiltered chips or use a lazy list.
Useful? React with 👍 / 👎.
…ke undo roll-forward match server
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2dbc7d1db7
ℹ️ 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".
| child: Row( | ||
| children: [ | ||
| Expanded( |
There was a problem hiding this comment.
Make the labeling bar responsive to text scaling
At 200% text scale or on narrow devices with longer localized labels, this single Row cannot fit its fixed-size Undo/Select/Done controls—or Cancel/Name Speaker controls—even after the title collapses, producing a RenderFlex overflow and clipped actions. The app UI contract explicitly requires text containers to support 200% scaling, so let the actions wrap or switch to an adaptive multi-row layout.
AGENTS.md reference: app/AGENTS.md:L3-L4
Useful? React with 👍 / 👎.
| return showOmiSheet<void>( | ||
| context: context, | ||
| title: context.l10n.nameSpeakerTitle, | ||
| builder: (_) => SpeakerQuickPicker(segments: segments, onPicked: onPicked), |
There was a problem hiding this comment.
Guard dismissal after entering a new person name
When the user taps Add Person and types a name, this remains a freely dismissible showOmiSheet, so a swipe-down, system back, or scrim tap silently discards the dirty input. The app UI contract requires sheets that edit something to use showOmiEditSheet/OmiEditSheet and confirm before dismissing dirty state; route the add-person form through that guarded behavior.
AGENTS.md reference: app/AGENTS.md:L3-L4
Useful? React with 👍 / 👎.
| if (provider.speakerLabelingSessionActive || selection != null) | ||
| SpeakerLabelingSessionBar( | ||
| linesRelabeled: provider.speakerLabelingSessionLineCount, | ||
| selectedCount: selection?.length, | ||
| onDone: () => _finishLabeling(provider), |
There was a problem hiding this comment.
Keep the pending labeling action visible on Summary
After a label is saved, switching from Transcript to Summary leaves the labeling session active but moves this bar—and its only Done action—off-screen inside the inactive transcript tab. Automatic regeneration remains suppressed for the active session, so the Summary tab can display stale speaker names indefinitely with no visible indication or way to apply the pending update unless the user knows to return to Transcript; either finish the pass on tab change or surface its pending action outside the transcript-only subtree.
Useful? React with 👍 / 👎.
Problem
Design
Labeling pass (draft session), in
ConversationDetailProviderbeginSpeakerLabelingSession). A bar above the transcript shows "Labeled N lines" with Undo, Select and Done._scheduleAutomaticSpeakerSummaryRefreshreturns early for the pass's conversation, so pauses between labels no longer trigger a reprocess. The "Update summary with new names" action is hidden while the pass is open, because Done does the same job._confirmedSpeakerLabelingSessionIds)._finishSpeakerLabelingSession→_regenerateSpeakerSummaryAfterExit).AppLifecycleState.paused) is treated like Done, so the result lands on the page if the reader returns.person_id: null). It runs on the same save queue and generation/rollback machinery. If the restore save fails, the lines roll forward to what the server still has.Persistence is unchanged
Every label still saves immediately through
assignBulkConversationTranscriptSegments, with the existing optimistic edit, save queue, generation checks and rollback. The pass only controls when the summary regenerates and how much feedback appears. No backend or API changes.Centered-line fix (
app/lib/widgets/transcript.dart)transcript.dart:876, defaultColumncentering):ListView.builderwrapped every segment after the first inColumn(mainAxisSize: min, children: [SizedBox(height: 4), child]). AColumncenters its children by default and gives them loose width. A detail line that starts a turn contains the full-width nameRow, so it filled the width and looked left-aligned. A line that does not start a turn (no name row) and is shorter than the viewport shrank to its text width and was centered.textAlignwas alreadyleft; the problem was the wrapper's alignment, not the text's._buildDetailLinelines; bubble lines are full-widthRows.Padding(top: 4). Every line gets the same tight width as line 0.Easier labeling
startSpeakerAssignmentcall labels all selected lines.speaker_quick_picker.dart). Chips assign with one tap, with no Save step. Order: people already named in this conversation (most lines first), then most recently used (speakerLabelLastUsedMs), then alphabetical. "You" and "Add Person" (inline name field) are always there, plus search above 10 people.defaultApplyToSpeaker: true). One Save names every line of that voice, through the existing speakerId bulk path. The sheet lists those lines so the reader can uncheck any.Deviations from the brief (and why)
app/docs/ux-contract.md§4 says multi-select is a "Select" entry, not the long-press itself. Selection mode starts from Select instead.scripts/l10n.py,flutter gen-l10nor any Flutter command, and generated l10n files must never be edited by hand. All UI strings therefore reuse existing keys:done,undo,cancel,selectOption,nameSpeakerTitle,selectedCount,speakerLabelLinesLabeled,addPerson,you,enterPersonsName,searchPeople,save.speakerLabelingSessionTipkey ("Tip: label all speakers, then tap Done to update the summary once.") are ready in all 49 locales. Wiring it up is: onel10n.py add, aSharedPreferencesUtil().speakerLabelingTipShowncheck (getter/setter already added), and oneTextinSpeakerLabelingSessionBar.Known limitations
Tests
test/providers/speaker_summary_refresh_test.dart, new group "labeling pass" (10 tests):test/widgets/speaker_labeling_session_test.dart:textAlignis lefta,c→ "Labeled 2 lines" → no regeneration during a 10 s pause → Done → exactly 1 regeneration, then the outcome cardspeaker_labels.dartis updated: the checkbox is now on by default, and Done comes before the outcome card.setUp. The provider's save queue starts from a completedFuture.value(). If that future is created outside thetestWidgetsfake-async zone,awaiting it resumes on the real microtask queue.tester.pumpnever drains that queue, so the first save only ran after the test body had finished. This was a test-harness artifact, not a product bug: in the app, the provider and its futures share one zone.flutter test test/providers/speaker_summary_refresh_test.dart test/widgets/speaker_labeling_session_test.dart test/widgets/transcript_test.dart test/widgets/transcript_heading_test.dart test/widgets/name_speaker_sheet_test.dartpassed, 94/94.flutter analyzeandmake preflightwere blocked by the session's permission mode. Watch the Dart analyze lane.Review fixes
_adoptBridgedConversation. It moves everything to the survivor ID:_labelingSessionId, the confirmed and ended pass sets,_automaticSpeakerSummaryRefreshIdsand_speakerSummaryConversationId. The undo stack is keyed by segment, so it carries over unchanged.confirmSpeakerLabelingSessionandleaveSpeakerLabelingSessioncalls now resolve that ID through_bridgedConversationIds. The page's own Done, background and exit still end its pass, and a page underneath still can't. The aliases are cleared when the provider switches to another conversation._finishSpeakerSavealso resolves through the bridge. A Done or exit pressed while the bridging save was still in flight now regenerates the survivor once.undoLastSpeakerLabelreturns false).speaker_summary_refresh_test.dart:🤖 Generated with Claude Code
Line-Count-Exception: app/lib/backend/preferences.dart | 1500 -> 1505 | adds the speakerLabelingTipShown preference flag alongside the existing preference accessors; splitting the file for 5 lines would fragment related storage accessors
Line-Count-Exception: app/lib/pages/conversation_detail/conversation_detail_provider.dart | 1293 -> 1514 | the labeling-pass session state machine (session lifecycle, bridge adoption, undo groups, deferred reprocess scheduling) is one cohesive provider concern; splitting it across files would scatter the generation/rollback invariants this PR is careful to keep together
UI-Evidence: none -- behavior-level changes (session bar, picker sheet, alignment) verified by widget tests comparing rendered line positions; no emulator capture available in this environment.
Failure-Class: none