Skip to content

feat(app): add Omi button action toggle - #11193

Merged
Git-on-my-level merged 11 commits into
mainfrom
mobile-button-actions-fw
Sep 22, 2026
Merged

Git-on-my-level merged 11 commits into
mainfrom
mobile-button-actions-fw

Conversation

@undivisible

@undivisible undivisible commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add an Omi Button Actions toggle to mobile Device Settings, enabled by default.
  • Gate Omi BLE button handling and pending voice-command submission on the preference.
  • Add localized labels and preference regression coverage.

Scope

App-only. Firmware is unchanged; firmware-owned behavior such as long-press power-off is not affected.

Verification

  • bash app/test.sh — 1,112 tests passed
  • bash app/scripts/analyze_ratchet.sh — passed
  • flutter test test/unit/omi_button_actions_test.dart — passed
  • Flutter localization generation — stable
  • Bounded pre-push checks — passed

Review in cubic


Note

Medium Risk
Changes live BLE button and voice-command submission paths on Omi devices; mistakes could drop legitimate actions or leak audio after the user disables the feature, though cancellation and onboarding guards target that.

Overview
Adds a user preference Omi Button Actions (default on) so the mobile app can ignore single/double-tap and device-button voice commands on Omi hardware without changing firmware.

Device Settings shows an Omi Button Actions switch for DeviceType.omi; the Double Tap action picker is nested under it and hidden when actions are off. Turning the switch off persists the preference and calls cancelActiveVoiceSession() so buffered command audio is not sent later.

Capture gates _handleButtonEvent and voice submission on the preference for Omi-typed recording devices only; interactive onboarding still receives button events, with tighter rules so tutorial voice sessions are cancelled on wrapper teardown and cannot submit after onboarding ends. cancelActiveVoiceSession plus a submission generation counter also blocks in-flight codec/submit races. OpenGlass devices normalized after getDeviceInfo() are not subject to this Omi-only gate (voice can still process when actions are “disabled” for Omi).

DeviceProvider re-pushes the capability-normalized paired device into capture after connect so the gate matches post-discovery identity (e.g. Omi advertising vs OpenGlass after image stream).

Localized label omiButtonActions and unit/controller tests cover persistence and the gating edge cases.

Reviewed by Cursor Bugbot for commit 7b26f86. Configure here.

Failure-Class: none

Line-Count-Exception

Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 2900 -> 3116 | Button-actions speaker-haptic injection seam and capability-normalized recording-device updates ride the existing capture lifecycle; file is frozen oversized at 2900 by #9838 and the PR re-applies branch semantics inside main's C1/C2 structure rather than splitting mid-feature.

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_13d8dee6-b0a6-4dde-9418-8ca8ed828621)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d6572d64fe

ℹ️ 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".

Uint8List.fromList(snapshot.sublist(0, 4).reversed.toList()).buffer,
).getUint32(0);
Logger.debug("device button $buttonState");
if (_recordingDevice?.type == DeviceType.omi && !SharedPreferencesUtil().omiButtonActionsEnabled) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Let onboarding receive disabled button events

When an Omi owner turns this switch off and later opens Settings → Device Tutorial, this return executes before deviceOnboardingProvider.onButtonEvent. The tutorial's single-press and double-press steps depend on that callback, so they can never complete; bypass the preference gate while onboarding is active and cover this interaction with a handler-level test rather than only preference persistence.

AGENTS.md reference: AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 103 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

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

Thanks for this @undivisible — clean, well-scoped app feature, and the default-on preference is the right call for preserving current behavior. The l10n coverage across all locales and the hermetic unit test are appreciated.

One blocking issue before this lands:

Onboarding stranding when the toggle is off. In capture_controller.dart the new guard at line 768 (if (... !omiButtonActionsEnabled) return;) runs before the interactive-device-onboarding intercept (lines 771–779). That means a user who has turned Omi Button Actions off cannot advance the single/double-press onboarding steps, because deviceOnboardingProvider.onButtonEvent never fires. Onboarding button handling isn't really an "action" this toggle should disable. The fix is small: move the gate to just after the onboarding block so onboarding events still flow regardless of the preference.

A couple of smaller follow-ups (non-blocking):

  • The DeviceType.omi && !omiButtonActionsEnabled check is duplicated verbatim at lines 710 and 768; a small private getter (e.g. bool get _omiButtonActionsDisabled => ...) would keep future gate changes in one place.
  • The new Switch uses activeTrackColor: Color(0xFF8E8E93) (the iOS off-state grey), so it reads as disabled while ON and is inconsistent with the sibling auto-sync toggle (0xFF8B5CF6). Matching the existing accent would make the enabled state clearer.
  • When the toggle is off, the Double Tap configuration row below it stays visible and tappable even though it's now a no-op — consider hiding/disabling dependent rows, or adding a subtitle.

Notes: CI shows two cancelled PR Metadata Preflight runs alongside a passing one; please make sure checks are green before merge. I've added feature-fit-review since this is a new user-facing settings surface that warrants a human product/maintainer look, and needs-maintainer-review for the onboarding fix. No security/privacy/dependency concerns from my read.


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 needs-maintainer-review Needs a human maintainer to sign off before merge feature-fit-review Needs review of product/feature direction with Omi mission/vision flutter flutter work labels Aug 7, 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.

Omi button action toggle reads clean and is fully localized — feature, so leaving the merge call to Nik.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @undivisible — clean, well-scoped implementation. Notes for the human sign-off:

Implementation

  • Both capture-controller guards (_processVoiceCommandBytes and the BLE button stream callback) read the preference at event time, so live toggling works without a reconnect/restart. Default-on preserves current behavior.
  • Scope correctly limited to DeviceType.omi; other device types are unaffected. Firmware-owned behavior (long-press power-off) is untouched, as stated.

Minor edge case (non-blocking)

  • If a voice-command session is already active when the user flips the switch off, in-flight bytes are dropped silently and the session lingers until its timeout fires. Not a correctness bug, but dismissing the active session on toggle-off would be slightly cleaner UX. Your call.

Coverage / CI

  • Unit test covers default value + persistence. Dart Analyze & Tests, Android Compile Smoke, Formatting, Hygiene, and Backend Hermetic Merge Gate are green on the latest head. The two "PR Metadata Preflight" entries in the check summary are cancelled runs from earlier pushes; the latest run succeeded.

Leaving the product/feature-fit sign-off to a human maintainer.


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 i18n Internationalization / localization changes and removed i18n Internationalization / localization changes labels Aug 7, 2026
@undivisible
undivisible force-pushed the mobile-button-actions-fw branch from d6572d6 to 0fa4b8c Compare August 8, 2026 05:16
@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_7adf90d1-39e6-451a-9ee4-d1bca91713fe)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fa4b8c4fd

ℹ️ 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".

Comment on lines +712 to +713
bool get _omiButtonActionsDisabled =>
_recordingDevice?.type == DeviceType.omi && !SharedPreferencesUtil().omiButtonActionsEnabled;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize device identity before applying the Omi-only gate

When a user disables this preference for an Omi and later connects an OmiGlass, its button actions can remain disabled with no switch available to restore them. Native discovery initially classifies peripherals using the Omi service as DeviceType.omi; device-info loading subsequently reclassifies OmiGlass only in pairedDevice (which hides the switch), while _onDeviceConnected passes the original device to the capture controller. Consequently, this check treats that OmiGlass as an Omi and applies the persisted global preference; base the gate on the normalized device identity rather than the original discovery value.

Useful? React with 👍 / 👎.

trailing: Switch(
value: _omiButtonActionsEnabled,
activeThumbColor: Colors.white,
activeTrackColor: const Color(0xFF8B5CF6),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace the purple switch accent with a neutral color

The newly added enabled-state track uses 0xFF8B5CF6, adding another purple UI accent despite the repository's locked requirement that new UI use white or neutral treatments instead. Use a neutral track color for the enabled switch state.

AGENTS.md reference: AGENTS.md:L90-L90

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level dismissed their stale review August 8, 2026 06:39

Dismissed — all blockers from this review are resolved on head 0fa4b8c4fd: (1) the Omi button-actions gate now runs after the interactive-onboarding intercept, so onboarding still receives button events; (2) the duplicated DeviceType.omi && !omiButtonActionsEnabled check is consolidated into the _omiButtonActionsDisabled getter; (3) the Switch accent is now 0xFF8B5CF6; (4) the dependent Double Tap row is hidden when the toggle is off. The remaining gate is human product/feature-fit sign-off.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up verification on head 0fa4b8c4fd — all four items from my earlier review are addressed:

  1. Onboarding stranding (was blocking) — the _omiButtonActionsDisabled gate in the BLE button stream now runs after the interactive-device-onboarding intercept, so onboarding onButtonEvent still fires regardless of the toggle. The same guard in _processVoiceCommandBytes remains at the top, which is correct since voice-command bytes are a genuine "action," not onboarding. ✓
  2. Duplicated guard — consolidated into the bool get _omiButtonActionsDisabled private getter; both call sites read through it. ✓
  3. Switch accent — now activeTrackColor: Color(0xFF8B5CF6), matching the sibling auto-sync toggle. ✓
  4. Dependent Double Tap row — now hidden when the toggle is off (conditional spread on _omiButtonActionsEnabled), with a clean non-Omi fallback path. ✓

Implementation notes:

  • Preference defaults to true, preserving current behavior.
  • Gate is correctly scoped to DeviceType.omi; other device types are unaffected.
  • Default-on + event-time reads mean live toggling works without reconnect/restart.
  • Dart Analyze & Tests, Android Compile Smoke, Formatting, Generated Files, and Backend Hermetic Merge Gate are green on this head (the earlier PR Metadata Preflight/Hygiene failures were on the superseded force-pushed commit and are now passing). I dismissed my stale changes-requested review accordingly.

Minor, non-blocking: if a voice-command session is already active when the user flips the toggle off, in-flight bytes are dropped silently and the session lingers until its 15s timeout. Not a correctness issue, but dismissing the active session on toggle-off would be marginally cleaner.

Leaving the product/feature-fit sign-off to a human maintainer — the blocking feature-fit-review / needs-maintainer-review labels remain.


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

Omi button action toggle — feature, approve only.

undivisible added a commit that referenced this pull request Aug 9, 2026
…malize Omi identity (PR #11193)

- Replace the purple switch accent (0xFF8B5CF6) with neutral white to satisfy the no-purple UI invariant.

- Cancel any in-flight voice-command session when the user disables Omi button actions, so audio captured while enabled is dropped instead of submitted after disabling.

- Normalize device identity before applying the Omi-only gate: an OmiGlass advertising as DeviceType.omi during discovery no longer inherits the persisted Omi button-actions preference.
@cursor

cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_a2c1d455-c043-4d38-91cb-5ecf14128454)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74733b8b21

ℹ️ 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".

Comment on lines +807 to +809
// Omi button actions are disabled by the user: skip action handling but
// onboarding (handled above) still receives button events regardless.
if (_omiButtonActionsDisabled) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exempt tutorial voice presses from the disabled gate

When actions are disabled and the user opens Device Tutorial, step 1 still cannot complete: onButtonEvent marks the first press active and the second press questionSent, but this return prevents both presses from starting or ending the actual voice-command session, so SinglePressStep enters Processing and waits indefinitely for a MessageProvider response that will never arrive. The fresh evidence beyond the earlier callback-ordering comment is that the new step-1 fall-through immediately encounters this preference gate; exempt those tutorial presses and cover the disabled-preference path through the button handler rather than only testing preference persistence.

AGENTS.md reference: AGENTS.md:L28-L30

Useful? React with 👍 / 👎.

Comment on lines +719 to +722
bool _isOmiButtonActionsDevice(BtDevice? device) {
if (device == null || device.type != DeviceType.omi) return false;
final name = device.name.toLowerCase();
return !(name.contains('openglass') || name.contains('omiglass') || name.contains('glass'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use capability-normalized identity for the Omi gate

For an OmiGlass that advertises the Omi service under a name without glass, openglass, or omiglass, this still classifies the raw recording device as an Omi. Fresh evidence after the earlier identity comment is that BtDevice._getDeviceInfoFromOmi explicitly reclassifies an OmiDeviceConnection as DeviceType.openglass when hasImageStream == 'true', so capability-only Glass devices are supported even when their names do not match these heuristics; pairedDevice then hides the switch while _recordingDevice remains the original Omi-shaped object and suppresses its button events whenever the global preference is false. Base the gate on the capability-normalized device identity instead of the discovery name.

Useful? React with 👍 / 👎.

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

Thanks @undivisible — this is a clean, well-scoped feature. Observations from the diff:

capture_controller.dart

  • The _omiButtonActionsDisabled gate in streamButton is correctly placed after the onboarding interception, so interactive onboarding still receives button events even when actions are disabled. Good separation of concerns.
  • _isOmiButtonActionsDevice properly excludes OmiGlass units that advertise as DeviceType.omi by name-matching 'glass'/'openglass'/'omiglass', avoiding accidental suppression of OpenGlass behavior.
  • cancelActiveVoiceSession() correctly cancels the timeout timer, clears _voiceCommandSession/_commandBytes, and is wired from device_settings.dart through CaptureProvider, so in-flight audio is dropped rather than submitted after the toggle flips.
  • _processVoiceCommandBytes early-returns when disabled — consistent with the streamButton gate.

device_settings.dart

  • The customization section now branches on device?.type == DeviceType.omi, preserving the existing double-tap row for non-Omi devices. Default-on switch preserves current user behavior.

preferences.dart

  • Standard getBool/saveBool pair, default true. No migration concern.

Tests / i18n

  • omi_button_actions_test.dart covers default-on and persistence. The capture-gating logic (OmiGlass exclusion, onboarding bypass) isn't unit-tested, which is reasonable given its BLE/device-state dependencies.
  • @omiButtonActions ARB metadata is present in the English source; generated localization files are consistent (Generated Files check passed).

The feature-fit-review and needs-maintainer-review labels are retained since the decision to expose this toggle (and its default/naming) is a product call. Note that @kodjima33's prior approvals were on earlier commits (d6572d6, 0fa4b8c); the current head (74733b8) has moved past them, so a maintainer re-confirmation on this head would close the loop before merge.

Reviewed by glm-5.2 (automation). Leaving for human maintainer review on the current head.


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

@undivisible undivisible added human Human-authored pull request app mobile labels Aug 10, 2026
undivisible added a commit that referenced this pull request Aug 10, 2026
…malize Omi identity (PR #11193)

- Replace the purple switch accent (0xFF8B5CF6) with neutral white to satisfy the no-purple UI invariant.

- Cancel any in-flight voice-command session when the user disables Omi button actions, so audio captured while enabled is dropped instead of submitted after disabling.

- Normalize device identity before applying the Omi-only gate: an OmiGlass advertising as DeviceType.omi during discovery no longer inherits the persisted Omi button-actions preference.
@undivisible
undivisible force-pushed the mobile-button-actions-fw branch from 74733b8 to 50d71d3 Compare August 10, 2026 21:11
@cursor

cursor Bot commented Aug 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_443c6f97-7383-4ebf-8963-8e7eb6de2681)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50d71d3be4

ℹ️ 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".

Comment on lines +722 to +723
activeThumbColor: Colors.white,
activeTrackColor: Colors.white,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Give the enabled switch a contrasting neutral track

When this toggle is enabled, both the thumb and track are pure white, causing the thumb to blend into the track and obscuring the switch position. Use a contrasting neutral track color so users can reliably identify the enabled state while preserving the repository's neutral-only UI treatment.

AGENTS.md reference: AGENTS.md:L90-L90

Useful? React with 👍 / 👎.

undivisible added a commit that referenced this pull request Aug 10, 2026
…malize Omi identity (PR #11193)

- Replace the purple switch accent (0xFF8B5CF6) with neutral white to satisfy the no-purple UI invariant.

- Cancel any in-flight voice-command session when the user disables Omi button actions, so audio captured while enabled is dropped instead of submitted after disabling.

- Normalize device identity before applying the Omi-only gate: an OmiGlass advertising as DeviceType.omi during discovery no longer inherits the persisted Omi button-actions preference.
@undivisible
undivisible force-pushed the mobile-button-actions-fw branch from 50d71d3 to 9034e79 Compare August 10, 2026 23:11

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

Feature (Omi button action toggle) — approve-only per policy (mobile area, not a bug fix). Note: CI currently shows failures (Dart Analyze, Formatting, Hermetic Merge Gate) — flagging for visibility, not blocking approval.

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

Mobile feature (Omi button action toggle) from flagged author, full diff re-read finds no abuse signal (pure app/l10n/provider files); DIRTY with failing required checks (Dart Analyze, Formatting, Backend Hermetic Merge Gate) so stays approve-only under the hard floor regardless of area rules.

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

Legit feature (Omi button-actions toggle gating BLE button/voice-command handling on preference), diff matches description, no abuse signals found. Mobile feature area -> approve-only per policy (not a bug fix). DIRTY mergeStateStatus + multiple real CI failures (Backend Hermetic Merge Gate, Dart Analyze, Formatting) block merge regardless — author should rebase and fix CI.

Address review feedback:
- Scope the Omi-button-actions gate to the action-handling path only, so
  interactive onboarding still receives button events when the toggle is off.
- Centralize the duplicated guard into a single _omiButtonActionsDisabled
  helper used by both _processVoiceCommandBytes and the BLE button stream.
- Hide the Double Tap row when Omi button actions are disabled (settings
  mismatch) and use the brand purple accent for the enabled switch track.
…malize Omi identity (PR #11193)

- Replace the purple switch accent (0xFF8B5CF6) with neutral white to satisfy the no-purple UI invariant.

- Cancel any in-flight voice-command session when the user disables Omi button actions, so audio captured while enabled is dropped instead of submitted after disabling.

- Normalize device identity before applying the Omi-only gate: an OmiGlass advertising as DeviceType.omi during discovery no longer inherits the persisted Omi button-actions preference.
Add focused coverage for onboarding delivery, normalized device identity, cancellation, and the post-codec preference race.

Failure-Class: none
Cancel tutorial voice sessions on onboarding exit, gate Glass by capability-normalized identity instead of name heuristics, stop collecting command audio when actions are disabled, and key the settings switch.
…lized devices

Prefer pairedDevice for the button-actions switch so OpenGlass reclassified after hasImageStream is not shown an Omi-only control, and cancel the tutorial voice session only after the user starts the flow.
Home and speech-profile were passing advertising-time connectedDevice into streamDeviceRecording, and tutorial dispose cancelled any in-flight voice session after Start.
- Re-drop the legacy long-press flag remnant (main removed it in #12477
  but the rebase resurrection left 6 undefined references in
  capture_controller.dart).
- Test fixture no longer opens a real transcription socket: override
  openConversationSocket to return null (mirrors main's
  _GatedSocketCaptureProvider pattern) so tests never reach
  buildHeaders -> FirebaseAuth.
- Seed the stored deviceIdHash and initialize PlatformManager in-test so
  header building has its late field without real device plugins.
- Stub path_provider and package_info channels in setUpAll.

All 10 controller tests + 2 unit tests pass; analyze clean on all
touched files.
@undivisible
undivisible force-pushed the mobile-button-actions-fw branch from cbbda02 to 8e149c1 Compare September 6, 2026 18:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-06T18:14:35.882902Z 8e149c1 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@undivisible

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main (head 8e149c14).

Two mechanical CI fixes pushed:

  1. Legacy long-press flag resurrection. The rebase had resurrected _voiceSessionStartedByLegacyLongPress from the pre-rebase branch while main removed it in 🧹 [Code Health] Remove tracking of legacy long press toggle #12477 — 6 undefined references in capture_controller.dart. Re-removed; behavior now matches main's 604e2f6e5d exactly (single-tap always ends a session, button-5 release ends any active session).

  2. Formatter drift in speech_profile_widget.dart (dart format line-length wrap) — committed as a style fix.

Rebase conflict resolutions (capture_provider.dart, capture_controller.dart): kept main's microphonePermissionRequester/phoneMicBatchRecorder/recordingTelemetry additions AND this PR's speakerHaptic injection; kept main's inline button handling? No — took the PR's _handleButtonEvent extraction (testability) and merged it with main's geolocation/WAL additions.

On the capabilityNormalizedDevice disconnected-device question (from the Aug 25 review): the current shape returns the remembered device after a disconnect, and streamDeviceRecording falls back to pcm8 when ensureConnection returns null — so yes, a transcription socket could open for an unconnected remembered device. Gating the getter on connectedDevice != null would restore the old check-only behavior, but it would also break the reconnect path that reads streamDeviceRecording with the normalized identity. The safer minimal fix: gate inside streamDeviceRecording — if ensureConnection is null and the device is not connected, skip socket setup and log. Happy to push that as a follow-up commit if that matches intent, or leave as-is if opening the socket for the remembered device is intended so reconnect streams immediately.

Verification: 10/10 omi_button_actions_controller_test.dart + 2/2 omi_button_actions_test.dart pass; flutter analyze clean on all 5 touched files; dart format clean.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e149c1492

ℹ️ 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".

// should have been cancelled — never submit audio captured after leaving.
final allowWhenDisabled =
_voiceCommandStartedDuringOnboarding && deviceOnboardingProvider?.isOnboardingActive == true;
_voiceCommandStartedDuringOnboarding = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep pending tutorial submissions cancellable

When actions are disabled and the second tutorial press ends a voice session, this clears the tutorial-ownership flag before _processVoiceCommandBytes finishes its asynchronous codec lookup. If the user exits during that lookup, cancelTutorialOwnedVoiceSession() now no-ops, the submission generation is not invalidated, and the captured allowWhenDisabled remains true, so the buffered audio is sent after onboarding has ended. Fresh evidence beyond the earlier active-session teardown finding is this post-session, pre-send window; retain ownership until submission finishes or make teardown invalidate tutorial-owned pending submissions too.

AGENTS.md reference: AGENTS.md:L45-L49

Useful? React with 👍 / 👎.

// pairedDevice instead of the raw advertising-time object.
final normalizedPairedDevice = pairedDevice ?? normalizedDevice;
if (captureProvider != null) {
captureProvider?.updateRecordingDevice(normalizedPairedDevice);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Revalidate the connection before restoring the recording device

If the device disconnects while this _onDeviceConnected continuation is awaiting streamDeviceRecording or the subsequent getDeviceInfo, onDeviceDisconnected() invalidates the captured session and clears the capture provider's recording device, but execution resumes here without another session check and assigns the cached paired device back. That leaves capture believing a disconnected device is active and can let its keep-alive path reconnect a transcription socket for the stale ID. Fresh evidence beyond the earlier cached-getter finding is this direct post-await write from a stale connection continuation; recheck connectionSession immediately before updating capture.

AGENTS.md reference: AGENTS.md:L45-L49

Useful? React with 👍 / 👎.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @undivisible — followed up on the rebased head 8e149c14. Both items from my last pass are confirmed fixed in the diff and CI:

  • Formatting — 8e149c1 wraps the speech_profile_widget.dart line; the Formatting check is green on this head.
  • Test bootstrap — 24b46a0 swaps the raw CaptureProvider fixtures for _NoSocketCaptureProvider (overriding openConversationSocket to return null so tests never reach buildHeaders → FirebaseAuth), stubs path_provider/package_info in setUpAll, seeds deviceIdHash, and boots PlatformManager.initializeServices() per test. Dart Analyze & Tests is green.
  • The rebase-resurrected _voiceSessionStartedByLegacyLongPress flag is fully gone on this head (0 references); single-tap-ends and release-ends semantics match main's post-🧹 [Code Health] Remove tracking of legacy long press toggle #12477 shape.

On the capabilityNormalizedDevice question from the Aug 25 review — I traced the disconnected-device path on this head and it's a bit sharper than "could open a socket":

  • DeviceProvider.onDeviceDisconnected() nulls connectedDevice but pairedDevice survives, so capabilityNormalizedDevice returns the remembered device, and the initState post-frame callback in pages/home/page.dart:502 now passes it into streamDeviceRecording (pre-PR this was connectedDevice == null → check-only).
  • streamDeviceRecording then runs the device-requested path: _resetState → _ensureDeviceSocketConnection → _getAudioCodec → ensureConnection (force=false) returns null for the disconnected device → codec falls back to pcm8 → _initiateWebsocket(force: true) opens a real transcription socket. _initiateDeviceAudioStreaming does bail out early (connection == null → return), so no audio ever flows — but the socket is open for a device with no BLE link.
  • Two side effects ride along: deviceRequested is now true, so _recordingTelemetry.prepare() mints a recording ID and failStart(failureClass: 'capture_unavailable') fires when nothing starts — every cold start with a paired-but-disconnected pendant gets classified as a failed start — and _captureSessionLocation(promptIfDenied: device != null) now takes the prompt-if-denied branch on plain app start.

On the fix shape: reconnect doesn't depend on this socket — _onConnected → connectDevice re-runs streamDeviceRecording with the normalized identity and opens the socket anyway — so gating _ensureDeviceSocketConnection on ensureConnection(deviceId) != null (your proposed minimal gate) looks safe from static reading and restores the old check-only behavior for the disconnected case. What remains is intent rather than mechanics: whether an open-but-idle socket for the remembered pendant is acceptable UX (and whether the backend is fine with the empty pcm8 session), and whether the cold-start capture_unavailable telemetry is the classification you want. That's a maintainer ruling on the current head — noting the earlier approvals all predate the rebase to 8e149c14.

With that ruling plus the small gate (or a comment stating the behavior is intended), this is ready for fresh maintainer sign-off.


by AI on behalf of David.

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

Feature (Omi button action toggle), not a bug fix — approve-only per policy confidence gate. Clean scoped diff (preferences.dart + localization only), no abuse signals. mergeStateStatus=UNKNOWN so holding at approve, not merging.

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

Feature (Omi button-actions toggle), mobile/app area — approve-only per policy (features stay approve-only outside desktop).

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

Mobile feature (button-action toggle) — approve-only per policy (not a bug fix); re-affirming approval on backlog re-eval.

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

feat(app) Omi button action toggle -- feature not bug fix, approve-only; re-approving since reviewDecision reverted to REVIEW_REQUIRED.

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

feat(app) Omi button action toggle -- near-duplicate of #12305, feature not bug fix, approve-only; re-approving since reviewDecision reverted to REVIEW_REQUIRED again.

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

Feature (mobile): Omi button actions toggle. Clean, well-tested gating of BLE button/voice-command paths behind a persisted preference; onboarding exemption and race-safe cancellation (submission generation counter) reviewed in full given elevated-scrutiny author. No abuse signals. Approve-only per policy (feature, not bug fix).

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

app-only feature (Omi button action toggle), gated behind preference; approve per policy (feature in mobile/community area stays approve-only, no merge).

@Git-on-my-level

Copy link
Copy Markdown
Member

Merge-forward performed by @dazheng_hermes_macstudio_bot (authorized by David): merged origin/main into this branch (8e149c1..ca2a1a3, merge commit ca2a1a3e54), no rebase, no force-push.

Conflict resolutions (main's C1/C2 capture-session structure kept, branch semantics re-applied):

  • capture_controller.dart: kept main's session/lifetime constructor + handler structure; re-applied the branch's speakerHaptic injection seam (param + _speakerHaptic field + short-circuit in _playSpeakerHaptic) and type-preserving recording-device updates (_recordingDevicePreservingNormalizedType around main's _rollCaptureSession). Main's computed isPaused => _preferences.deviceMuted supersedes the branch's startup mute-restore (same outcome, main's mechanism).
  • device_provider.dart: union — branch's capabilityNormalizedDevice getter + normalized recording-device pushes kept; main's generation guards kept.
  • speech_profile_widget.dart: main's AnimatedBuilder rewrite kept; branch's getter swap is subsumed (restart now flows through capture.recordingDevice, which the device_provider normalization feeds).
  • capture_provider.dart: union of constructor params (super.speakerHaptic + main's new seams).
  • Test stub updated for main's new geolocation socket param; Line-Count-Exception declared in PR body for capture_controller.dart (2900 -> 3116).

Verified locally at ca2a1a3e54: dart analyze lib 0 errors (142 pre-existing infos); flutter test button-actions suites 12/12 pass; ownership audit clean (net diff = exactly the branch's 110 owned files; 29 main-side files restored to origin/main bytes after formatter drift).

@Git-on-my-level
Git-on-my-level merged commit 3845372 into main Sep 22, 2026
39 checks passed
@Git-on-my-level
Git-on-my-level deleted the mobile-button-actions-fw branch September 22, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app feature-fit-review Needs review of product/feature direction with Omi mission/vision flutter flutter work human Human-authored pull request mobile 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.

3 participants