Skip to content

fix(mobile): route pendant tutorial question outcome through capture and handle voice failures (#23385) - #23391

Open
ocakciomursel-pixel wants to merge 2 commits into
BasedHardware:mainfrom
ocakciomursel-pixel:fix/pendant-tutorial-question-stall-23385
Open

ocakciomursel-pixel wants to merge 2 commits into
BasedHardware:mainfrom
ocakciomursel-pixel:fix/pendant-tutorial-question-stall-23385

Conversation

@ocakciomursel-pixel

@ocakciomursel-pixel ocakciomursel-pixel commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #23385

Summary

Fixes the interactive pendant tutorial's "Ask Omi a Question" step (SinglePressStep) stalling on "Processing your question…" when the user is viewing a non-main chat session/app or when a voice question attempt fails after submission.

What changed and why

  • Typed voice question outcome pipeline (MessageProvider → CaptureExternalActions → CaptureController → DeviceOnboardingProvider):
    • Added VoiceQuestionFailure and VoiceQuestionOutcome in capture_external_actions.dart and returned Future<VoiceQuestionOutcome> from MessageProvider.sendVoiceMessageStreamToServer, CaptureExternalActions.sendVoiceMessageStreamToServer, and ProviderCaptureExternalActions.sendVoiceMessageStreamToServer.
    • Preserved chat-session isolation in MessageProvider.sendVoiceMessageStreamToServer (voiceMessages still stays out of non-main threads, fresh chats, or app threads like Mentor) while returning the submitted request's transcribed question and final answer—or its terminal failure (noSpeech, quota, busy, audioSaveFailed, offline, timeout, server, notSignedIn, incomplete, unknown)—directly to the capture caller.
    • Bounded _voiceAudioFileSaver with _voiceReplyTimeout so a hung local file write cannot stall _voiceSendInFlight or the tutorial indefinitely.
  • Admitted capture transitions and attempt-scoped tutorial state:
    • CaptureController._handleButtonEvent no longer advances DeviceOnboardingProvider on step 1 before capture admits the voice session. Dropped taps (such as during the 2-second auto-submit grace window or while a submission is already in flight) and non-voice button states no longer flip the tutorial UI into "Listening...".
    • DeviceOnboardingProvider now scopes each tutorial question attempt with a monotonic activeAttemptId (onVoiceSessionStarted, onVoiceQuestionSubmitted, onQuestionAutoSubmitted, onVoiceResponseReceived, onVoiceQuestionFailed) and ignores callbacks from stale attempts, after step exit/completion, after disposal, or after an answer has already been received.
    • CaptureController._processVoiceCommandBytes bounds pending submissions in time (_voiceCommandSubmissionTimeout) and routes every drop/failure (emptyFrames, sendInFlight, noDevice, codecLookupFailed, timeout, and stream/transport/quota failures) to the active tutorial attempt. cancelTutorialOwnedVoiceSession also cancels an in-flight tutorial submission if the user exits onboarding while "Processing your question…" is active.
  • Decoupled SinglePressStep from MessageProvider.messages and localized terminal failure hints:
    • SinglePressStep now reads userQuestion, aiResponse, questionFailed, and questionFailure directly from DeviceOnboardingProvider instead of listening to MessageProvider.messages, so unrelated chat traffic cannot complete or corrupt the tutorial step and answers still arrive when chat is outside the main Omi session.
    • Displays localized retry/limit explanations (voiceQuestionNoSpeech, chatQuotaExceededReply, chatReplyOffline, chatReplyTimeout, chatReplyServerError, chatReplyNotSignedIn, chatReplyFailed) on every terminal failure and resumes the bounce cue for retry.

Product invariants affected

  • INV-CAP-1: app/lib/services/capture/capture_controller.dart and app/lib/services/capture/capture_external_actions.dart are touched only on the pendant button voice-command question path (_handleButtonEvent, _beginVoiceCommandSession, _endVoiceCommandSession, _processVoiceCommandBytes). Normal pendant audio frame capture, WAL retention, batch routing, and socket streaming (streamAudioToWs) are unchanged.

Line-Count-Exception

Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4507 -> 4639 | scopes tutorial voice-command session admission, attempt tracking, timeout watchdog, and typed failure forwarding within the existing _processVoiceCommandBytes / _handleButtonEvent methods that directly mutate private voice-command controller state.

Failure-Class

Failure-Class: none

UI-Evidence

UI-Evidence: none -- reuses SinglePressStep's existing layout, bounce animation, and existing localized error strings (voiceQuestionNoSpeech, chatQuotaExceededReply, chatReplyOffline, chatReplyTimeout, chatReplyServerError, chatReplyNotSignedIn, chatReplyFailed); reaching the live pendant tutorial flow requires paired BLE hardware, and the UI states are covered by widget tests in app/test/widgets/device_onboarding_question_revisit_test.dart.

Verification

  • flutter test test/providers/device_onboarding_provider_test.dart test/providers/omi_button_actions_controller_test.dart test/providers/message_provider_voice_test.dart test/widgets/device_onboarding_question_revisit_test.dart
  • dart format --line-length 120 --set-exit-if-changed --output=none on all changed Dart files

View guided diff

@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: this is a well-scoped, correctly-designed fix for the tutorial stall, with unusually strong test coverage — no blocking findings from me; leaving the merge call to a human maintainer.

What I verified:

  • app/lib/pages/onboarding/.../single_press_step.dart — the root cause is genuinely addressed: the old _onMessagesChanged listener completed the step only when the human/AI pair landed in the main chat messages list, so a non-main session or app left the step spinning on "Processing your question…" forever. The step is now driven purely by DeviceOnboardingProvider state (aiResponse / questionFailed + questionFailure), and _failureMessage maps each VoiceQuestionFailure to an existing localized string (quota, offline, timeout, server, notSignedIn get specific copy; the rest sensibly fall back to chatReplyFailed).
  • app/lib/services/capture/capture_external_actions.dart — VoiceQuestionFailure/VoiceQuestionOutcome on the interface; NoopCaptureExternalActions now returns failed(unknown) instead of silently succeeding, which keeps fakes honest.
  • app/lib/providers/message_provider.dart — sendVoiceMessageStreamToServer returns the transcribed question (captured from human message chunks in the stream) plus the answer, or a typed failure; chat-session isolation for voiceMessages is preserved; the audio-file save is now bounded by the existing _voiceReplyTimeout so a hung write can't wedge the re-entry guard.
  • app/lib/services/capture/capture_controller.dart — the 35s submission watchdog + generation counter means a hung codec lookup or stream can no longer wedge the tutorial or _voiceCommandSubmissionInFlight; failTutorial/completeTutorial are attempt-scoped (attemptId + identical() checks), so late replies from a previous attempt or after exiting onboarding are ignored — verified against the _endVoiceCommandSession/cancelActiveVoiceSession paths; _handleButtonEvent on the ask-question step only admits capture-started transitions, so grace-window or in-flight taps can't flip the UI to "Listening".
  • app/lib/providers/device_onboarding_provider.dart — monotonic activeAttemptId with _invalidateActiveQuestionAttempt on step exit/complete/dispose, canStartVoiceQuestion gating, dispose-safe notifyListeners: the right shape for the race fixes.
  • app/lib/coordinators/provider_capture_external_actions.dart — signature update to Future<VoiceQuestionOutcome> plus formatting only.
  • app/changelog/unreleased/20261023-pendant-tutorial-question-stall.json — accurate, follows the fragment convention.
  • Tests: device_onboarding_provider_test.dart (stale-attempt isolation, overlapping presses), omi_button_actions_controller_test.dart (codec-failure reset, offline retry, grace-window tap drop, exit-during-flight cancellation), message_provider_voice_test.dart (typed outcomes across fresh chat/quota/audio-save failures), device_onboarding_question_revisit_test.dart (unrelated chat traffic no longer completes the step; localized failure copy asserted).

Non-blocking notes:

  • The 35s _voiceCommandSubmissionTimeout applies to all pendant voice submissions, not just tutorial ones. The underlying stream isn't cancelled (MessageProvider still updates chat and clears its own guard), but the first-chunk haptic would be skipped past 35s — worth a glance at pendant telemetry after this ships.
  • DeviceOnboardingProvider.onButtonEvent's step-1 path is now exercised only by tests, since capture drives the step via admitted transitions; fine, just noting the dual entry point.

Performance: no new queries or algorithmic cost — control-flow/state plumbing only. Cost: no new external calls. Security: no transport, auth, or data-handling changes.

USER IMPACT: the pendant tutorial's "Ask Omi a Question" step no longer gets stuck on "Processing your question…" when you're in another chat or app, or when the voice question fails — it now shows a clear localized retry or limit message and lets you try again.

Still wanted from a reviewer (nothing blocking): a manual on-device pass over the press-again/grace-window UX, since widget tests can't fully reproduce the BLE timing paths.

Automated review on behalf of the maintainers; leaving the merge decision to a human maintainer — no product or security concern, just a substantive behavioral refactor of the pendant capture path.


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 positive-signal Automation verified a genuine fix/quality contribution flutter flutter work labels Oct 23, 2026

@aryanorastar aryanorastar 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.

Thanks for the request-outcome and attempt-scoping work. I compared this with current main: #23466 has already merged the original outcome-pipeline fix, with production-owner/widget and simulator coverage, so applying this broader replacement now would duplicate that implementation.

Verification did uncover a remaining native playback boundary. An outer submission timeout can return the tutorial to retry while MessageProvider is still held on native output setup/stop; it also needs safe late-cleanup ownership. Draft #23609 addresses those producer-side paths on top of main, with 99 focused tests and iOS simulator acceptance; CI is still running. No additional unique requirement from this PR was established in this pass. Leaving it unmerged and open rather than applying the same pipeline twice. #23385 stays open through the remaining fix/release/customer follow-up.

aryanorastar added a commit that referenced this pull request Oct 26, 2026
The pendant tutorial can remain on Processing with spoken replies
enabled after #23466: native playback setup was awaited before starting
the voice-stream deadline, and failed replies awaited native audio
cleanup before releasing the voice busy guard.

Bound spoken-output admission with the existing voice-reply budget and
revoke late admission after failure. Finish failed questions
independently of best-effort, request-scoped cleanup, using a unique
playback identity. Cleanup follows the admitted playback lifecycle: a
skipped mode-off, missing-headphone or revoked-admission attempt owns no
new playback and must leave existing cleanup intact. An actually
admitted replacement retires old cleanup after asynchronous boundaries.

Refs #23385 and merged #23466. This builds on the merged outcome
pipeline rather than reapplying #23391. Preserve recordings, WAL
custody, settings, firmware and backend contracts. No backend deployment
is needed. Keep the customer incident open until a mobile release
contains the complete fix and the reporter confirms question → answer →
Continue and retry.

## Review correction

The initial head `385422f01a` incorrectly guarded cleanup with
`_beginAttemptSeq`, which advances even when playback is skipped. The
three review regressions pass on baseline and fail on that head. The
revisions through `d87ea9ea8ee1467160fa3493f91115a64d7725d1` use the
existing `_lifecycleToken` as cleanup ownership in both `interrupt` and
an admitted begin that is clearing prior audio. Six committed
regressions cover all three skips at each cleanup entry point. The
existing admitted-replacement regression is preserved unchanged. Earlier
green CI/no-blocker notes for `385422f01a` do not certify this revision.

## Verification

- Reproduced all three review cases against baseline and the initial PR
head: baseline 3/3 pass, initial head 0/3 pass. After the interruption
correction, all six baseline/current comparisons pass alongside the
committed service suite (27 tests total). The sibling admitted-begin
cleanup cases also fail on `0cedebcf1b` before that path is corrected
and now pass in the final focused suite.
- Revised head `d87ea9ea8ee1467160fa3493f91115a64d7725d1`: 105 targeted
provider, tutorial/widget and voice-playback tests pass. The production
service, capture → external-actions → MessageProvider → tutorial owners
execute with synthetic native/audio/provider I/O. No physical pendant or
live-provider acceptance claim.
- Final head `d87ea9ea8ee1467160fa3493f91115a64d7725d1`: analyzer
ratchet and bounded pre-push passed, including 27 selected
manifest/preflight checks. The local 90-day historical guard explicitly
skipped in the shallow clone; full-history CI must enforce it. The
affected tutorial integration flow was rerun successfully on the
dedicated iPhone 16 Pro/iOS26.5 simulator via attach/hot restart and
driver. Reused native debug host with current Dart and synthetic
native/audio/provider I/O; no fresh native binary, physical BLE or
live-provider claim. Current-head CI and maintainer re-review remain
required; keep draft.
- Previous head's remote CI passed 7,420 Flutter tests/four skipped and
Hygiene/full-history guard. Those results remain historical and must not
be reported as current-head CI.
- At the implementation-time release check on 2026-10-25, original
#23466 was in iOS 1.0.576 (1474), submitted for Apple review. This
follow-up is absent from that binary; merging and a later signed mobile
release remain separate from code verification.

## Product invariants affected

- INV-CAP-1: only pendant question response/playback completion changes;
BLE ingress, WAL custody, saved recordings and transcription settings
are preserved.

Failure-Class: new

Line-Count-Exception: app/lib/providers/message_provider.dart | 1203 ->
1208 | keeps request-local playback authorization, unique ownership and
best-effort cleanup beside the existing voice-stream result/finally
guard without another global owner or capture pipeline.

UI-Evidence: none -- layout is unchanged; the existing tutorial UI is
exercised through the production-owner simulator fixture documented in
app/docs/pendant-tutorial-question.md.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: pendant tutorial question can stall outside the main chat or after voice failures

3 participants