Skip to content

fix(capture): refuse silent pendant voice-question sessions while muted (#20478) - #22057

Open
ocakciomursel-pixel wants to merge 2 commits into
BasedHardware:mainfrom
ocakciomursel-pixel:fix/cv1-refuse-silent-voice-question-while-muted-20478
Open

ocakciomursel-pixel wants to merge 2 commits into
BasedHardware:mainfrom
ocakciomursel-pixel:fix/cv1-refuse-silent-voice-question-while-muted-20478

Conversation

@ocakciomursel-pixel

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

Copy link
Copy Markdown
Contributor

Fixes #20478

Summary

Prevents a pendant single-tap (or legacy long-press) from starting a silent, non-capturing voice-question session while double-tap mute (isPaused) is active:

  • Refuse voice-question start while muted (CaptureController._handleButtonEvent):
    • When isPaused is true (outside interactive device onboarding), buttonState == 1 (single-tap toggle) and buttonState == 3 (legacy long-press) refuse to start _voiceCommandSession, emit DebugLogManager.logEvent('pendant_voice_question', {'phase': 'refused_muted'}), and play the double-pulse failure haptic (_playVoiceQuestionFailureHaptic(deviceId)) instead of the single-pulse start acknowledgement.
    • If a button end/release arrives while muted (buttonState == 1 or buttonState == 5 with _voiceCommandSession != null), cancels the session via cancelActiveVoiceSession() instead of submitting empty/partial frames.
  • Cancel active voice session on mute (CaptureController._setCaptureMuted):
    • When capture transitions to muted (muted == true), any active non-onboarding _voiceCommandSession is immediately cancelled via cancelActiveVoiceSession() so double-tapping to mute mid-question does not leave a 15s timer running.
  • Guard command audio buffering (CaptureController.streamAudioToWs):
    • Gates collectCommandAudio by !isPaused (unless interactive onboarding is active).

Verification

  • Added unit tests in app/test/providers/omi_button_actions_controller_test.dart:
    • single tap and legacy long press refuse to start a silent voice session while muted (#20478)
    • double-tap mute cancels an active voice question session (#20478)

View guided diff

Product contracts and evidence

Product invariants affected: INV-CAP-1. This change refuses a voice-question session during an explicit user mute; it does not authorize automatic audio loss while capture is active.

UI-Evidence: none -- no visual UI change; refusal feedback is haptic-only

Physical pendant haptic behavior has not been verified on-device.

Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4517 -> 4540 | Keep the bounded mute admission check beside the existing capture-session authority; splitting the controller is outside this fix.

Failure-Class: none
The fix addresses admission of a voice-question session while the pendant is explicitly muted; no failure-class registry entry is added by this PR.

@Git-on-my-level

Copy link
Copy Markdown
Member

The production change here is correct and nicely scoped — this closes the silent-session path from #20478 exactly as the issue's privacy-explicit option describes. Leaving one product confirmation to a maintainer rather than approving.

Correctness, file by file:

  • app/lib/services/capture/capture_controller.dart
    • _setCaptureMuted (~line 798): cancelling the active non-onboarding voice session on the mute transition is the right fix — it kills the 15s auto-submit timer and clears _commandBytes, so double-tap-mute mid-question can't later submit stale frames.
    • _handleButtonEvent single-tap (~2046) and legacy long-press (~2085): refusal while isPaused logs pendant_voice_question/refused_muted and plays the distinct double-pulse failure haptic before any session starts — good, the user gets feedback instead of a dead session.
    • End paths (~2073 single-tap, ~2103 buttonState 5): cancel while muted instead of _endVoiceCommandSession, so no empty/partial submission. Consistent with cancelActiveVoiceSession()'s generation bump preventing in-flight submits.
    • streamAudioToWs (~2136): gating collectCommandAudio on !isPaused (outside onboarding) is a correct backstop; comment update matches the new behavior.
  • app/test/providers/omi_button_actions_controller_test.dart: both new tests are behavior-level (no session, sendCount == 0, haptic pulse sequence [1,1,1,1] matching the 80ms double-pulse, refused_muted log events) and reuse the existing _NoSocketCaptureProvider/_RecordingCaptureExternalActions harness. One gap: CI on this PR only ran an AI reviewer, so these tests haven't executed anywhere yet.

Security/privacy: positive — this refuses capture-adjacent state while muted rather than bypassing it.

USER IMPACT: While the pendant is muted, tapping to ask a voice question now gives a clear failure buzz instead of silently pretending to listen; muting mid-question cleanly discards it.

What I'd still want as a reviewer: (1) the new tests run in CI (only the AI reviewer ran on this PR), and (2) maintainer confirmation of the product choice — #20478 also floats allowing one deliberate question while muted; this PR implements the refuse option, which looks right to me, but that call is a product decision, hence needs-maintainer-review.


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 needs-maintainer-review Needs a human maintainer to sign off before merge flutter flutter work labels Oct 17, 2026
@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review and verification, @Git-on-my-level!

Regarding the two points:

  1. CI test run: Workflows are currently in action_required pending maintainer approval (standard for external contributor PRs). The tests are written against the existing _NoSocketCaptureProvider / _RecordingCaptureExternalActions harness and pass cleanly.
  2. Product choice: We opted for the explicit refusal path over allowing a voice question while muted because when the user explicitly double-taps to mute the pendant, capturing or streaming audio without visual UI creates privacy ambiguity. The distinct double-pulse failure haptic provides immediate, unambiguous tactile feedback that the microphone is muted, keeping privacy guarantees absolute.

Looking forward to the maintainer review!

@aryanorastar
aryanorastar self-requested a review October 20, 2026 02:53

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

Since my last review: addressed — CI has now run on this head and Dart Analyze & Tests pass, confirming the tests you pointed to; still open — maintainer sign-off on the mute-vs-question semantics from #20478; newly surfaced — the Hygiene check fails a PR-body contract, the one blocking fix below.

This needs one small, non-code fix before merge. Hygiene fails ui-evidence because app/lib/services/capture/capture_controller.dart counts as UI source and the PR body has neither a tracked screenshot reference nor an explicit escape line. This change intentionally has no visual UI (feedback is haptic-only), so add this exact line to the PR description:

UI-Evidence: none -- no visual UI change; refusal feedback is haptic-only

Correctness re-verified on the current head:

  • capture_controller.dart ~798 (_setCaptureMuted): cancelling the active non-onboarding voice session on the mute transition kills the 15s auto-submit timer so a mid-question mute cannot later submit stale frames — exactly the privacy-explicit option #20478 describes.
  • capture_controller.dart ~2046 and ~2085 (single-tap, legacy long-press): refusing while muted logs pendant_voice_question/refused_muted and plays the distinct double-pulse failure haptic — unambiguous tactile feedback that mute is honored.
  • capture_controller.dart ~2136 (streamAudioToWs): collectCommandAudio now also requires !isPaused (interactive onboarding still exempt); precedence reads correctly and it is sound defense-in-depth if a session ever slips past cancelActiveVoiceSession.
  • omi_button_actions_controller_test.dart: the new tests assert session state, haptic pulses ([1,1,1,1]), zero socket sends, and both refused_muted events, plus the mute-mid-question cancel path — good coverage of both entry points.

USER IMPACT: while the pendant is double-tap-muted, a single tap or long-press no longer silently pretends to start a voice question — it is refused with a distinct double-buzz haptic, and muting mid-question now cancels the question cleanly.

No new queries, latency, or external API cost; the behavior change is strictly more privacy-conservative. Once the UI-Evidence line is added and Hygiene goes green, the only remaining item is the maintainer product call on what mute authorizes (review already requested) — the on-device repro suggested in #20478 stays unverified, but the state machine is unit-covered.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level need human response

Updated the PR description with the exact requested line:

UI-Evidence: none -- no visual UI change; refusal feedback is haptic-only

The source head is unchanged (4ea35cf7f3988e988bd57559de6dd9d7e96bae29). The existing Dart Analyze & Tests check is successful; the latest Repo Checks run is awaiting workflow approval. Please approve the pending workflow so Hygiene can validate the current description, and re-review the description-only request when it passes.

A human maintainer product decision is still needed for #20478: this implements explicit refusal of a voice question while muted, with haptic feedback, rather than temporarily overriding mute. Physical pendant behavior remains unverified.

@Git-on-my-level
Git-on-my-level dismissed their stale review October 22, 2026 14:23

Resolved: the PR body now contains the exact required line "UI-Evidence: none -- no visual UI change; refusal feedback is haptic-only", which satisfies the Hygiene ui-evidence contract; this was the only blocking item from this review. Head unchanged. Remaining before merge: maintainer product sign-off on #20478 semantics and on-device haptic verification.

@Git-on-my-level

Copy link
Copy Markdown
Member

Since my last review: addressed — the PR body now carries the exact UI-Evidence: none -- no visual UI change; refusal feedback is haptic-only line, which satisfies the Hygiene ui-evidence contract (checked against .github/scripts/check_ui_evidence.py's escape pattern); that was the only blocking item, so I've dismissed my changes-requested review · still open — maintainer sign-off on the #20478 mute-vs-question semantics and on-device haptic verification · newly introduced — none.

Verdict: the production change is correct and complete for what it claims; from my side this is ready for maintainer sign-off. Head is unchanged (4ea35cf).

Code, for the record:

  • app/lib/services/capture/capture_controller.dart — _setCaptureMuted (~798) cancels any active non-onboarding voice session on the mute transition, so double-tap-mute mid-question kills the 15s auto-submit timer instead of later submitting stale frames; _handleButtonEvent refuses single-tap (~2046) and legacy long-press (~2085) session starts while isPaused with the double-pulse failure haptic and a pendant_voice_question/refused_muted log event; muted end-of-press (~2105) cancels rather than submitting partial frames; streamAudioToWs (~2140) additionally gates collectCommandAudio on !isPaused, so even a session that slipped through cannot buffer audio while muted.
  • app/test/providers/omi_button_actions_controller_test.dart — both new tests assert the behavior end-to-end (no session created, zero bytes sent, refusal haptic pulses, two refused_muted events; double-tap mute mid-session cancels with zero sends), and Dart Analyze & Tests passed on this exact head.

Blast radius: pendant button behavior only, and only while muted; the onboarding path is explicitly exempted. Performance/cost impact negligible (a boolean check per button event). Privacy strictly improves — no audio can be captured, buffered, or submitted while the user has muted the device.

USER IMPACT: while the pendant is muted, a single tap no longer silently opens a dead voice-question session — you feel a distinct double-buzz "muted" haptic instead, and muting mid-question immediately cancels it.

Still wanted before merge: (1) maintainer sign-off on the #20478 product choice (refuse-with-haptic rather than temporarily overriding mute), (2) on-device verification of the double-pulse haptic on a physical pendant, and (3) maintainer approval of the pending workflow run so Hygiene/Detect Changes confirm the updated PR body on CI — the escape line matches the contract, so it should pass. Leaving for human maintainer review: the mute-vs-question product decision and physical-pendant verification are maintainer calls, not automation calls.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@ocakciomursel-pixel
ocakciomursel-pixel force-pushed the fix/cv1-refuse-silent-voice-question-while-muted-20478 branch from 86f4aae to 68f2811 Compare October 23, 2026 20:28

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 needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CV1: single tap starts a silent voice-question session while double-tap mute is active

2 participants