Skip to content

fix(app): keep pendant voice questions out of app and Mentor threads - #22311

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/pendant-voice-app-thread
Oct 19, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/pendant-voice-app-thread

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

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_stream reads the main session and stores the answer with app_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.

sendVoiceMessageStreamToServer now 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

  • Read the flow end to end. The pendant button reaches MessageProvider.sendVoiceMessageStreamToServer through CaptureController._processVoiceCommandBytes. Picking an app (_selectApp on the chat page, _openChatWithApp on an app's page, and the /chat/<app id> deep link a Mentor push opens) sets selectedChatAppId. refreshMessages then clears chatSessionId and isFreshChat and loads that app's thread, so the old guard (chatSessionId == null && !isFreshChat) treated the app's thread as the main chat.
  • Backend: 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_messages in chat_turn.py) is scoped to the app the same way.
  • Ran dart format --line-length 120 (pinned Flutter SDK) on the changed Dart files: no changes. .github/scripts/mobile-changelog.py validate passes. scripts/failure-class validate reports no errors for the declaration or the new definition.
  • I did not run tests locally. CI with ci:full runs 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 app mentor selected, 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: with no_selected selected, 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.dart drives a pendant voice turn through the production MessageProvider in 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

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]>
@apoorvdarshan apoorvdarshan added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Git-on-my-level Git-on-my-level added the flutter flutter work label Oct 19, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: scoped bug fix, CI green, root-caused, test-covered. Approving per policy.

@kodjima33
kodjima33 merged commit b1258e7 into BasedHardware:main Oct 19, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR flutter flutter work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pendant questions and answers show up in an app's or Mentor's chat thread instead of the main chat

3 participants