Skip to content

feat(app,firmware): remappable single/double/triple tap button actions (#2825) - #19323

Open
sirgawain0x wants to merge 9 commits into
BasedHardware:mainfrom
sirgawain0x:agent/customizable-button-actions-31b2
Open

sirgawain0x wants to merge 9 commits into
BasedHardware:mainfrom
sirgawain0x:agent/customizable-button-actions-31b2

Conversation

@sirgawain0x

@sirgawain0x sirgawain0x commented Sep 27, 2026 •

Copy link
Copy Markdown

Summary

Implements remappable single/double/triple tap button actions for Omi (#2825).

  • Firmware: progressive tap sequence recogniser + GATT 23ba7926 (CV1 + DevKit), feature bit 9
  • App: prefs + Device Settings for single/double/triple tap; long press power remains fixed
  • CaptureController: capability-gated progressive dispatch; legacy trailing-5 fix

Closes #2825

Test plan

  • Host tap_sequence firmware tests
  • button_action_test / omi button actions controller tests
  • Device: single/double/triple tap remapping on CV1/DevKit (happy to work with @beastoin for validation)

Product invariants affected

none

Invariants: none
Failure-Class: none

Review in cubic

cursoragent and others added 3 commits September 27, 2026 01:20
Implements BasedHardware#2825 with progressive tap notifications on a new BLE
characteristic so shorter gestures stay instant when longer ones are Off.
Long press remains fixed as firmware power off. Defaults: Ask, Mute, End.

Co-authored-by: G2 <[email protected]>
…_test

ScriptedDeviceConnection lacked getFeatures/getBleButtonTapsListener after
_streamButtonTaps started probing tap capability, crashing 25 capture tests.
Also clang-format the new firmware host test so Repo Checks / Formatting passes.

Co-authored-by: G2 <[email protected]>
Repo Checks / Formatting failed dry-run on the newly added header.

Co-authored-by: G2 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for this — a genuinely well-built end-to-end implementation of #2825. A few notes from review:

What looks good

  • omi/firmware/common/tap_sequence.h as a shared, host-testable recogniser (with run.sh wired into the checks manifest) is exactly the right shape for timing-sensitive logic like this.
  • The GATT additions on both CV1 and DevKit button.c are correct: notify_tap_sequence notifies on the new 23ba7926 taps characteristic (attrs[4]) without disturbing the legacy 23ba7925 path, and feature bit 9 gates discovery cleanly.
  • The trailing-release fix in capture_controller.dart (code 5 no longer ends a tap-started voice session, tracked via _voiceSessionFromHold) is a real bug fix with regression tests — good catch on the ~40ms trailing notify.
  • ButtonTapDispatcher's fire-now-vs-wait-for-sequence-end logic is sound and well unit-tested.

Points that need a maintainer call before merge

  1. Double-tap default migration (app/lib/backend/preferences.dart): the getter now returns mute (1) for an unset key, but the old UI stored 0 for an explicit "end & process" choice — and 0 is indistinguishable from "never set". Users who explicitly chose end-conversation will be silently remapped to mute on update. Worth deciding whether that's acceptable or whether a migration key should distinguish "explicitly chose 0" from "unset".
  2. DevKit capability asymmetry: capture_controller.dart detects DevKit taps support by probing the characteristic, but device_settings.dart gates the triple-tap row on the features bit alone — so DevKit never shows the triple-tap setting even on new firmware. Also worth confirming getCharacteristicStream actually throws for a missing characteristic on all platforms (it returns a listener unconditionally on iOS/macOS paths as written).
  3. Default latency: with double and triple both mapped by default, single-tap ask-question only fires at sequence end (~350ms after the tap). Fine if intentional, but it's the flagship gesture — worth a conscious UX decision.
  4. The test plan's device-validation checkbox for CV1/DevKit is still open; coordinating that with @beastoin before merge would de-risk the timing constants (300ms press / 350ms gap) against real hardware.

No security or supply-chain concerns found — no dependency, workflow, or secret surface; the checks-manifest addition only compiles a local test file. This needs a product decision on point 1 and on-device validation sign-off on point 4, so I'm flagging it for maintainer review rather than sign-off.


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 needs-maintainer-review Needs a human maintainer to sign off before merge label Sep 27, 2026
@Git-on-my-level
Git-on-my-level marked this pull request as draft September 28, 2026 09:07
@Git-on-my-level

Git-on-my-level commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Follow-up to my earlier review on this head — one correction to that note, plus two additions. After this I'll leave it with a human maintainer.

Correction — double-tap default migration (point 1 of my earlier comment): on a closer read of app/lib/backend/preferences.dart, the migration is handled correctly. The new getter reads _preferences?.getInt('doubleTapAction') directly and only returns mute (1) when the key is absent; an explicitly stored 0 still resolves to end-conversation. Users who deliberately chose "end & save" are not remapped — only users who never touched the setting move to the new #2825 default. That silent-majority default change still deserves a conscious maintainer call, but there is no explicit-choice migration bug.

DevKit root cause (extends point 2): the feature-bit gate never opens on DevKit because of the firmware, not the app: OMI_FEATURE_BUTTON_TAPS is only set in omi/firmware/omi/src/lib/core/transport.c (features_read_handler), while omi/firmware/devkit/src/transport.c has no features characteristic at all. So DevKit cannot advertise bit 9 even on new firmware — even though omi/firmware/devkit/src/button.c does notify on 23ba7926. If DevKit is meant to be supported in this PR it needs a features path; otherwise the onboarding doc's triple-tap card should say progressive taps are CV1-only for now.

Minor: app_tl.arb and the generated app_localizations_tl.dart ship the English strings for the four new keys untranslated.

Everything else from the earlier review stands as verified on this head: GATT table indexing on both button.c files (taps value at attrs[4], legacy notify untouched at attrs[1]), the shared tap_sequence.h recogniser with host tests, and the app-side dispatcher plus trailing-release fix with regression tests. The open items remain the DevKit decision above, the default-change sign-off, and the pending on-device validation — all maintainer calls.


by AI on behalf of David

Resolve l10n by replaying single/triple tap keys onto upstream ARBs,
port progressive button-taps dispatch onto upstream CaptureController
voice-command trigger/grace changes, and drop invalid const Icon colors.

Co-authored-by: G2 <[email protected]>
@sirgawain0x
sirgawain0x marked this pull request as ready for review September 28, 2026 17:35
Resolve l10n ARB/Dart conflicts by rebasing button-action keys onto
upstream locale catalogs and regenerating flutter gen-l10n.

Co-authored-by: G2 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @sirgawain0x — this is a genuinely well-built PR, especially for a first contribution here. Static review of the full diff below; no approval from me since this spans a device-protocol commitment and product defaults that need a maintainer's call.

What I verified and like

  • omi/firmware/common/tap_sequence.h: clean progressive multi-tap recogniser. The unsigned now_ms - press_ms comparisons are wraparound-safe, long holds with no prior taps stay silent so power-off remains on the legacy path, and the hold-ends-sequence branch (count > 0 && >= TAP_SEQUENCE_MAX_PRESS_MS) correctly terminates a sequence that turns into a hold. Host tests in tap_sequence_test.c cover tap/end ordering, multi-tap, holds, and timing edges — nice to see this tested without hardware.
  • Firmware GATT: the new 23ba7926 notify characteristic in both omi/firmware/omi/src/lib/core/button.c and omi/firmware/devkit/src/button.c reuses the existing CCC handler, and notify_tap_sequence targets button_service.attrs[4], which matches the expanded attribute table (primary + chrc + CCC + chrc + CCC). Legacy 23ba7925 notifications are untouched.
  • App gating: OmiFeatures.buttonTaps = 1 << 9 (services/devices.dart) is only advertised by omi/src/lib/core/transport.c under CONFIG_OMI_ENABLE_BUTTON, the connector default (performGetBleButtonTapsListener base impl) is a safe null, and CaptureController's sticky _deviceHasButtonTaps flag prevents a mid-gesture re-attach from double-firing via the legacy path. The dispatcher's _waitsForMoreTaps / _dispatched / _sawTaps state machine in services/capture/button_action.dart is coherent, and the sequence-end-without-taps ignore case is a good catch.
  • The trailing-release fix (legacy code 5 no longer kills a tap-started voice session, omi_button_actions_controller_test.dart) fixes a real bug independently of the new feature.
  • Test coverage is unusually thorough: button_action_test.dart unit tests, extended controller tests including the remap-to-mute and progressive paths, and a getFeatures() => 0 stub in scripted_device_connection.dart so legacy-path tests stay deterministic. The checks-manifest entry (firmware-tap-sequence-tests) follows the existing pattern.

Things a maintainer should decide before merge

  1. Silent default change for double tap: SharedPreferencesUtil.doubleTapAction (app/lib/backend/preferences.dart) now resolves an unset key to 1 (mute) instead of the previous 0 (end conversation). Every existing user's double-tap behavior changes on upgrade. The comment says this is issue increased button functionality + customizable buttons ($500) #2825's intent and docs/onboarding/omi.mdx documents mute as the default — but shipping a behavior change to all upgraders as a side effect of "remappable gestures" is a product call worth explicit sign-off (and maybe a changelog callout).
  2. Single-tap latency on the progressive path: when higher taps are mapped, a single tap can't dispatch until the 350 ms TAP_SEQUENCE_GAP_MS expires (or the hold-to-END branch fires). That adds ~350–390 ms to the primary ask-question interaction on new firmware. Probably acceptable, but it's the most-frequent gesture — worth confirming the trade-off is intended, and whether askQuestion sequences (fire-on-TAP, then ignore END) could instead skip the wait.
  3. DevKit asymmetry: devkit/src/button.c gains the 23ba7926 characteristic, but the feature bit is only advertised in the omi (CV1) transport.c — devkit has no equivalent change in this diff, so DevKit firmware never signals support and its app path stays legacy. If intentional (DevKit kept on legacy detection), a one-line note in DevKit2Testing.mdx would help; if not, it's a small gap.
  4. On-device validation: the test plan's CV1/DevKit hardware item is unchecked. Host + unit tests are strong, but BLE timing under real debounce/latency and the triple-tap gesture's discoverability are only verifiable on hardware.

No security, dependency, workflow, or data-handling surfaces touched; docs changes match the code as diffed.

Labeling positive-signal for the quality; keeping needs-maintainer-review — the two decisions that need a human are the all-users double-tap default change (product call) and the new 23ba7926/feature-bit-9 protocol commitment, which can't be validated without on-hardware testing.


🤖 AI-generated maintainer feedback on behalf of the Omi maintainers


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 firmware firmware work labels Sep 29, 2026
cursoragent and others added 2 commits October 1, 2026 00:46
Resolve l10n ARB/Dart conflicts by rebasing button-action keys onto
upstream locale catalogs and regenerating flutter gen-l10n.

Co-authored-by: G2 <[email protected]>
Review feedback on BasedHardware#19323: NativeBleTransport never threw for a missing
23ba7926 characteristic, so the DevKit probe always looked supported, and
Device Settings gated triple-tap on the CV1-only features bit.

- Expose DeviceTransport.hasCharacteristic and use it for taps support
- Gate settings UI and capture streaming on supportsButtonTaps()
- Honor single-tap remapping on the legacy button path
- Document CV1 feature-bit vs DevKit characteristic discovery

Co-authored-by: G2 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for this — a well-structured implementation of #2825. The capability-gated design (feature bit 9 on CV1, 23ba7926 characteristic presence on DevKit, sticky legacy-path suppression in capture_controller.dart) and the host-testable firmware recognizer in omi/firmware/common/tap_sequence.h with its gcc -Werror harness are both nicely done, as is the regression test for the trailing release (code 5) no longer killing tap-started voice sessions.

A few review notes:

Verified

  • notify_tap_sequence uses &button_service.attrs[4] in both omi/firmware/omi/src/lib/core/button.c and omi/firmware/devkit/src/button.c. I checked the GATT table layout: attrs[0] = primary service, [1..3] = legacy characteristic (the existing notifies use attrs[1]), [4..6] = the new taps characteristic. The index is correct on both targets and follows the file's existing convention.
  • ButtonTapDispatcher in app/lib/services/capture/button_action.dart: firing tap n immediately only when no higher count is mapped, waiting for sequence-end otherwise, with _dispatched/_sawTaps guards against mid-gesture re-attach double-fire and orphan END after reconnect — logic checks out and the unit tests cover exactly those cases.

One product question worth a maintainer decision

  • app/lib/backend/preferences.dart: the doubleTapAction getter now returns 1 (mute) when the key is unset, where it previously resolved to 0 (end conversation). That silently changes double-tap behavior on upgrade for every existing user who never opened the setting. The code comment says this matches increased button functionality + customizable buttons ($500) #2825's stated default — but since it's a behavior change for existing users baked into a preference migration, it deserves explicit sign-off rather than riding along with the feature.

Minor

  • app_tl.arb / app_localizations_tl.dart ship the English strings ("Single Tap", etc.) as Tagalog placeholders. Fine as a fallback, but worth a follow-up pass.
  • Docs (docs/onboarding/omi.mdx, DevKit2Testing.mdx) accurately describe the discovery mechanism and payload format — good.

The remaining test-plan item (on-device remapping validation on CV1/DevKit) is still open; firmware behavior can't be fully verified host-side. Leaving those two items — the unset-default behavior change and hardware validation — for human maintainer review before merge.


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

cursoragent and others added 2 commits October 1, 2026 14:33
Resolve l10n ARB/Dart conflicts by rebasing button-action keys onto
upstream locale catalogs and regenerating flutter gen-l10n.

Co-authored-by: G2 <[email protected]>
Resolve l10n ARB/Dart conflicts by rebasing button-action keys onto
upstream locale catalogs and regenerating flutter gen-l10n.

Co-authored-by: G2 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @sirgawain0x - this is a well-put-together feature. I reviewed the firmware, app, and docs surfaces; the host test suite for the recogniser passes locally (7/7), and the design keeps legacy behaviour intact for older images.

What looks good, with specifics:

  • omi/firmware/common/tap_sequence.h - clean header-only recogniser; unsigned now_ms - press_ms arithmetic makes it uptime-wraparound-safe, and long holds with no prior taps correctly stay silent so power-off keeps the legacy path. The host tests in common/test/tap_sequence/ run green locally via run.sh.
  • omi/firmware/omi/src/lib/core/button.c and omi/firmware/devkit/src/button.c - legacy single/double-tap notifications (attrs[1]) are retained alongside the new 23ba7926 notifications (attrs[4]); both GATT tables use the same attribute layout, and transport.c only advertises feature bit 9 under CONFIG_OMI_ENABLE_BUTTON.
  • app/lib/services/capture/button_action.dart - ButtonTapDispatcher semantics are sound: fires tap n early only when no higher count is mapped, _dispatched prevents double-firing when a mapped single tap grows into a multi-tap, and END without preceding taps is ignored (mid-reconnect case).
  • app/lib/services/capture/capture_controller.dart - the sticky _deviceHasButtonTaps suppression means a mid-gesture detach/re-attach cannot double-fire through the legacy path, and the trailing code-5 fix (release ends only legacy long-press sessions, not tap-started questions) has regression tests in omi_button_actions_controller_test.dart.
  • device_connection.dart / native_ble_transport.dart - the discovery split (CV1 feature bit 9 vs DevKit characteristic presence) is documented at the API, and default-false hasCharacteristic avoids the trap of inferring presence from a subscription API that creates a controller even when the characteristic is missing.
  • docs (DevKit2Testing.mdx, omi.mdx) match the implementation, and the new host check is registered in checks-manifest.yaml for both local and CI lanes.

Notes for the maintainer (why this needs human sign-off rather than automated approval):

  1. Behavior change for existing users: SharedPreferencesUtil.doubleTapAction now defaults to mute when the key was never set, where it previously resolved to end-conversation. Explicit choices are preserved (stored 0 still means end), but users who never touched the setting will see double-tap silently change. The docs in this PR present mute as the new default, so it looks intentional per increased button functionality + customizable buttons ($500) #2825 - it just deserves a conscious product decision before merge.
  2. Hardware validation is still unchecked in the test plan (CV1/DevKit remapping); host tests are solid but cannot cover the GATT notify path on real devices.
  3. As a first-time contributor's PR, only the AI reviewer check has reported so far - worth confirming the app/firmware CI lanes execute once approved to run.
  4. Minor: app_tl.arb ships the new tap strings in English (fallback) - fine, just noting it is not translated yet.

Category-wise this spans app and firmware coherently around one feature, so I reviewed it as a whole rather than asking for a split.

This feedback is AI-generated maintainer assistance on behalf of the Omi maintainers; human review is required before merge.


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

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

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

increased button functionality + customizable buttons ($500)

3 participants