Repository navigation
fix(app): keep pendant voice questions out of app and Mentor threads - #22311
Conversation
The voice endpoint carries no app or chat session, so the backend saves
a pendant question and its answer to the main Omi chat. The app only
kept them out of Past chats and a fresh chat: with a chat app's thread
open (a Mentor notification opens app 'mentor'), both were appended
there. They vanished from that thread on its next load, appeared in the
main chat instead, and a typed follow-up in the app's thread did not
have them as context.
Choose the thread from the selected app too, read once before the turn
starts. The chat drawer's Omi choice ('no_selected') still means the
main chat. In any other thread the reply still plays; it just does not
become a row there.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level
left a comment
There was a problem hiding this comment.
The production change is correct and nicely scoped — approving. The one-line guard now matches where the server actually persists pendant voice turns.
Findings by file:
- app/lib/providers/message_provider.dart — the voice-visibility guard now reads appProvider.selectedChatAppId at turn start ('no_selected' → main chat) and a voice turn becomes rows only when chatSessionId == null && !isFreshChat && no app is selected. I verified the premise against backend/utils/chat.py: process_voice_message_segment_stream calls chat_db.get_chat_session(uid) with no app and sets app_id = None, so both the question and the answer are saved to the main Omi chat — the rows shown in an open app thread were phantoms that the thread's next load dropped. Reading the selection once also keeps the analytics chatTargetId consistent with the visibility decision.
- app/test/providers/message_provider_voice_test.dart — new tests cover the regression (Mentor thread open → rows stay out) and the no_selected → main-chat positive case through the full question/data/done chunk sequence; the past-thread case was already covered. Hermetic, drives the production MessageProvider.
- app/changelog/unreleased/20261019-pendant-voice-main-chat.json — accurate, matches the observed user-visible change.
- .github/failure-classes/FC-chat-turn-projected-outside-its-server-thread.json — schema matches the existing failure-class entries and its canonical_prevention_artifact points at the new tests.
UX: with an app thread open, the pendant answer still plays aloud but no longer appears as rows in that thread (they were dropped on the next reload anyway); it lands in the main chat where the server saved it. Security: no security surface touched. Blast radius: pendant voice path only — verified single caller (CaptureController → ProviderCaptureExternalActions → MessageProvider); the typed path and chat-screen mic are unaffected.
USER IMPACT: Questions you ask with your pendant now stay in your main Omi chat instead of briefly appearing in an app's or Mentor's chat and then vanishing on the next load.
Non-blocking thought for a future pass: a voice turn started while an app thread is open, with the user switching to the main chat mid-stream, is not exercised — worth a test if that transition ever becomes reachable.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
kodjima33
left a comment
There was a problem hiding this comment.
Automated review: scoped bug fix, CI green, root-caused, test-covered. Approving per policy.
What changed and why
Fixes #22310
A pendant question goes to
/v2/voice-messages, which names no app and no chat session. The backend saves the question and its answer to the main Omi chat (process_voice_message_segment_streamreads the main session and stores the answer withapp_id=None).The app already kept these rows out of Past chats and out of a fresh chat, but not out of a chat app's thread. With an app's thread open, the question and answer were appended there. That happens after you pick an app in the chat drawer, open chat from an app's page, or tap a Mentor notification, which opens app
mentor. On that thread's next load the rows were gone and showed up in the main chat instead. A typed follow-up in the app's thread also did not have them as context, because its history comes from the app's own session.sendVoiceMessageStreamToServernow checks the selected app as well. A voice turn becomes rows only in the main chat: no chat session, not a fresh chat, and no app selected. The chat drawer's Omi choice (no_selected) still means the main chat. The selection is read once when the turn starts, and the analytics event uses the same value. In any other thread the reply still plays through the pendant; it just does not become a row there, the same as with Past chats open.Product invariants affected
INV-CHAT-1 (one shared transcript across surfaces). Its path globs cover only the desktop apps and this PR touches none of them; the invariant check (
.github/scripts/check_product_invariants.py --suggest) requires no ID for these paths. I name it because it states the rule this mobile fix applies: voice is an input device against the shared main conversation and never forks it.How it was verified
MessageProvider.sendVoiceMessageStreamToServerthroughCaptureController._processVoiceCommandBytes. Picking an app (_selectAppon the chat page,_openChatWithAppon an app's page, and the/chat/<app id>deep link a Mentor push opens) setsselectedChatAppId.refreshMessagesthen clearschatSessionIdandisFreshChatand loads that app's thread, so the old guard (chatSessionId == null && !isFreshChat) treated the app's thread as the main chat.GET /v2/messages?app_id=<app>reads only that app's session, while the voice pipeline writes to the main session. A typed turn's history (get_cache_aligned_messagesinchat_turn.py) is scoped to the app the same way.dart format --line-length 120(pinned Flutter SDK) on the changed Dart files: no changes..github/scripts/mobile-changelog.py validatepasses.scripts/failure-class validatereports no errors for the declaration or the new definition.ci:fullruns the new tests and the full app suites. I wrote the first new test to fail on main, where the question and answer are appended to the Mentor thread.Tests
app/test/providers/message_provider_voice_test.dart, next to the existing Past chats test, with the same injected audio saver and reply stream:pendant voice turn stays out of an open app thread such as Mentor: with appmentorselected, a full answered voice turn (question, answer text, saved answer) leaves the thread as it was. On main the question and answer are appended, so this fails.pendant voice turn still lands in the main chat after Omi is picked in the drawer: withno_selectedselected, the same turn is appended to the main chat. This also passes on main; it checks that the drawer's Omi choice still counts as the main chat.UI evidence
UI-Evidence: none -- no layout change, and no simulator or device here; the provider tests check which thread gets the rows.
Failure class (fixes)
Failure-Class: new
Failure-class transition narrative
Adds
FC-chat-turn-projected-outside-its-server-thread. Violated contract: a chat turn may be shown in the open thread only when the server writes it to that thread. #19838 applied this rule to pendant voice for Past chats when it added them, and #20432 fixed the same shape for typed sends during an app switch (a send could target the new app while the old thread was still on screen). Guard:app/test/providers/message_provider_voice_test.dartdrives a pendant voice turn through the productionMessageProviderin each kind of thread: a past chat, an app's thread, the drawer's Omi choice, and no app at all.🤖 Generated with Claude Code