Skip to content

feat(firmware,app): increased button functionality & customizable buttons (#2825) - #14568

Closed
shuoYun114 wants to merge 13 commits into
BasedHardware:mainfrom
shuoYun114:feat/customizable-button-actions
Closed

shuoYun114 wants to merge 13 commits into
BasedHardware:mainfrom
shuoYun114:feat/customizable-button-actions

Conversation

@shuoYun114

@shuoYun114 shuoYun114 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

UI-Evidence: none
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4230 -> 4290 | Implement customizable button actions, debounce locks, and voice session hardening (#2825)
Line-Count-Exception: app/lib/backend/preferences.dart | 1489 -> 1526 | add customizable button action preference getters and setters (#2825)
Failure-Class: none

Product invariants affected

  • INV-CAP-1

Description

/claim #2825
Resolves #2825 ($500 Bounty)

This PR brings full hardware-to-app end-to-end support for customizable button actions across the entire Omi platform, delivering on all requirements specified in Issue #2825:

  • Single Press: Defaults to Ask Question (toggle voice session), fully customizable in App.
  • Double Press: Defaults to Mute/Unmute recording, fully customizable in App.
  • Triple Press: Defaults to End Conversation, fully customizable in App.
  • Long Press: Hardware-fixed power toggle (turn on/off via 3s hold), clearly indicated in App UI as non-reconfigurable.
  • Full Action Pool:
    • 0: End & Process Conversation
    • 1: Pause/Resume Recording (Mute/Unmute)
    • 2: Star Ongoing Conversation
    • 3: Ask Question (Voice Question Mode)
    • 4: None (Disabled)

Key Changes

1. Dual-Platform Firmware Enhancement (CV1 & DevKit 2)

  • Files: omi/firmware/omi/src/lib/core/button.c & omi/firmware/devkit/src/button.c
  • State 6 (TRIPLE_TAP): Implemented non-blocking multi-tap FSM supporting rapid 1/2/3 taps with immediate 3-tap triggering.
  • Monotonic Hardware Clock: Transitioned timing logic to Zephyr k_uptime_get_32() to eliminate virtual clock drift.
  • Ghost Click Defense: Tap counters and timestamps are immediately cleared if button hold exceeds tap threshold (e.g. aborted long press).
  • Consolidated BLE GATT Notification: Consolidated repeated notification logic into notify_button_state() instead of duplicated handlers.
  • Power Off Resilience: Clean power-off on long press without emitting spurious State 3 notifications, protecting downstream voice handlers.

2. App Preferences & Whitelist Sanitization

  • File: app/lib/backend/preferences.dart
  • Added singlePressAction, doublePressAction, and triplePressAction properties with reusable sanitize helpers.
  • Full backward-compatibility: doubleTapAction and doubleTapPausesMuting are seamlessly synced with doublePressAction.
  • Whitelist sanitization (validButtonActions = {0, 1, 2, 3, 4}) prevents corrupted/out-of-bounds configurations from affecting the runtime.

3. CaptureController Event Routing & Lifecycle Hardening

  • File: app/lib/services/capture/capture_controller.dart
  • Streamlined Multi-Tap Pattern Matching: Clean Dart 3 switch expression mapping for tap state dispatch.
  • Zero-Copy BLE Unpack: Decodes uint32 state directly via ByteData.sublistView(..., Endian.little) without redundant memory allocations.
  • Reentrancy & Debounce Defense: Added 400ms event debounce and 3-5s timeout fallback with try-finally lock release.
  • Conversation Session Integrity: Implemented _isForceProcessingConversation in-flight mutex lock in forceProcessingCurrentConversation(), awaiting processInProgressConversation() across the full lifecycle to prevent duplicate temporary session generation.
  • Resource Lifecycle: Uses lifetime.takeSubscription and resets active button streams, timers, and locks on device disconnection (_updateRecordingDevice(null)).

4. Device Settings UI

  • File: app/lib/pages/settings/device_settings.dart
  • Added configuration rows for Single Press, Double Press, and Triple Press with streamlined declaration mapping in bottom sheet.
  • Added Long Press entry explicitly documented as hardware-fixed Turn On / Off.

Verification & Testing

  1. Python Multi-Tap State Machine Simulation:
    • Simulated 5 edge-case scenarios: Single tap, double tap, instant triple tap, long press, and aborted hold. 100% PASS.
  2. Standalone Dart Automated Verification:
    • Verified whitelist sanitization, zero-copy byte decoding equivalence, and debounce lock timing. 100% PASS.
  3. Flutter Unit Tests & Concurrency Regressions:
    • app/test/services/devices/customizable_button_actions_test.dart added covering:
      • Defaults and dynamic customization persistence.
      • Corrupted SharedPreferences fallback sanitization.
      • Zero-copy little-endian state unpacking matching reversed-buffer legacy decoding.
      • Event debounce (400ms) window rejection.
      • Multi-tier in-flight guard regression: verifies a second press arriving after 400ms debounce while backend processing is still running is safely dropped by _isForceProcessingConversation, guaranteeing no duplicate processing chains or duplicate sentinel processing IDs ('0').

Bounty Claim Information

  • USDT (TRC20): TGKmfSU1tdggErAo8BicaCoXhkMwLetxV
  • BTC: 1NkUgv23H65ZYJn64pseAcWRA6sJitxh2f
  • PayPal / Email: [email protected]

@github-actions

Copy link
Copy Markdown
Contributor

Hey @shuoYun114 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for the thorough end-to-end implementation - this covers firmware, app preferences, capture routing, settings UI, and tests, which is the shape issue #2825 asks for. I reviewed all six changed files; the overall structure is solid (whitelisted action values, legacy doubleTapAction migration, monotonic firmware clock). Findings before this can move forward:

Firmware - omi/firmware/omi/src/lib/core/button.c and omi/firmware/devkit/src/button.c

  • The rewrite of check_button_level() around k_uptime_get_32() and a tap_count accumulator is a real improvement over the old current_time++ virtual tick - timing now survives work-item jitter, and clearing tap_count on over-threshold releases kills ghost taps. Immediate triple-tap trigger (no 500 ms wait) is a good touch.
  • Divergence to resolve: the omi build now calls notify_long_tap() before turnoff_all() on long press, but the devkit build does not. On the omi build, that state-3 notification reaches the app's legacy handler in capture_controller.dart (buttonState == 3 && _voiceCommandSession == null) and starts a phantom voice-question session just as the device powers off. It self-clears via the 15 s timeout with empty audio, but it's an unintended cross-layer interaction, and the two firmware targets should behave the same here. Was adding notify_long_tap() intentional?
  • BUTTON_EVENT_RELEASE handling and notify_unpress() are now unreachable in both builds (states 4/5 are never emitted). I verified the app only consumes states 1/2 (onboarding) and 3/5 (legacy voice sessions), so nothing breaks today - but the dead path plus the retained current_button_state FSM deserves a cleanup pass.
  • The new comments are in Chinese while the surrounding codebase is English - please translate for consistency.

App - app/lib/services/capture/capture_controller.dart

  • _executeButtonAction() consolidating the old duplicated single/double-tap branches into one switch is much cleaner, and the device-disconnect cleanup in _updateRecordingDevice(null) (cancelling _bleButtonStream, timers, and locks) fixes a real leak.
  • The change that most needs eyes: forceProcessingCurrentConversation() went from fire-and-forget to fully awaited with a reentrancy guard that silently drops concurrent calls. Five other call sites share it (speech_profile/page.dart, conversation_capturing/page.dart, battery_info_widget.dart, plus e2e flows). The old code let two callers race; the new code ignores the second caller with no feedback. That may well be the right trade, but it's a behavior change hidden inside a button-customization PR and deserves its own validation and test.
  • Single taps now fire ~500 ms later than before because the firmware waits out DOUBLE_TAP_WINDOW_MS before notifying single vs double. Inherent to multi-tap disambiguation - just flagging the UX trade so it's a conscious product decision.
  • The < 10 frames drop in _processVoiceCommandBytes will discard very short questions (a fast tap-tap within ~0.5 s). Probably fine; worth a sanity check that quick "yes/no"-style questions don't get eaten.

App - app/lib/backend/preferences.dart

  • Clean migration: doubleTapAction/doubleTapPausesMuting now proxy doublePressAction, legacy stored values are read through the sanitizer, and out-of-range values fall back to defaults. Tests cover defaults, sanitization, and the legacy fallback path. Good.

App - app/lib/pages/settings/device_settings.dart

  • The generalized _showButtonActionSheet() removes a lot of duplication, and marking Long Press as hardware-fixed matches the issue's constraint.
  • The new rows use hardcoded English strings ('Single Press', 'Triple Press', 'Long Press', 'Turn On / Off', 'Fixed in device hardware') while neighboring rows use context.l10n - these need l10n keys.

Tests - app/test/services/devices/customizable_button_actions_test.dart

  • The preference tests are real and meaningful. Two gaps: the "firmware unpack" tests re-implement the unpack logic in a local helper, so they test the test rather than streamButton's actual decoding; and there's no coverage of _executeButtonAction routing (tap state -> configured action), which is the core of this feature. (Also a typo in the PR description's test path: sevices.)

One description inaccuracy to correct: the "30s -> 15s auto-end timer" item is comment-only - the code already used a 15 s timer before this PR. Not a behavior change.

Leaving for human maintainer review: this PR changes shared conversation-processing semantics (forceProcessingCurrentConversation) relied on by five other screens, introduces default button mappings users will feel on first update, and the two firmware targets now diverge on long-press notification behavior - each is a product/firmware call rather than something automation should sign off on.


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 needs-tests PR introduces logic that should be covered by tests labels Sep 18, 2026
@shuoYun114

Copy link
Copy Markdown
Contributor Author

Hi @Git-on-my-level,

@woahwhattheheck woahwhattheheck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Exact-head follow-up on 4a57c0b: the long-press target divergence from the Sep 18 review is fixed (both firmwares now power off without emitting state 3), and all 7 PR-triggered workflows are green. Two remaining acceptance gaps look material:

  1. The green PR checks do not compile either changed firmware target. The repo's actual CV1 firmware build is .github/workflows/firmware_release.yml, which is workflow_dispatch manual-only by design. Since 2/6 changed files are Zephyr C and both retained notification helpers/state paths were reorganized, this PR still needs at least one real CV1/devkit firmware build (and ideally hardware tap-sequence evidence) before the hosted-green label is used as firmware proof.

  2. The PR description still claims forceProcessingCurrentConversation() has a mutex/reentrancy guard and is fully awaited, but current head does not. It awaits finalizeCurrentSession(), clears/reset state, starts processInProgressConversation().then(...), then returns immediately. _executeButtonAction therefore releases _isProcessingButtonEvent while backend processing is still running. A second End/Process-mapped press >400ms later can start another processing chain using the same sentinel processing id 0. The added routing tests also re-implement resolveTapAction locally rather than invoking streamButton/_executeButtonAction, so this concurrency path is untested. Please either restore an explicit in-flight guard that spans the actual processing future, or update the description and add a regression proving repeated End/Process input cannot start duplicate processing.

Separate non-blocking debt from the earlier review remains: hard-coded English settings labels and helper-based BLE/routing tests rather than production-path tests.

@shuoYun114
shuoYun114 force-pushed the feat/customizable-button-actions branch from 4a57c0b to 6b922a9 Compare September 20, 2026 13:58
@shuoYun114

Copy link
Copy Markdown
Contributor Author

Hi @woahwhattheheck @Git-on-my-level,

Thank you for the detailed and constructive feedback! We have addressed all items in the latest updates:

  1. In-Flight Force-Processing Mutex & Reentrancy Guard:

    • In CaptureController.forceProcessingCurrentConversation(), _isForceProcessingConversation acts as an explicit mutex spanning the entire asynchronous conversation processing lifecycle.
    • We explicitly await processInProgressConversation().then(...) inside a try ... finally block, ensuring _isForceProcessingConversation is held until the backend operation finishes (or times out via the 5-second safety fallback in _executeButtonAction).
    • Any second or concurrent request arriving while processing is active is immediately logged and dropped (Logger.debug("forceProcessingCurrentConversation already in flight, ignoring duplicate request")), preventing duplicate temporary session cards ('0') or concurrent duplicate processing jobs.
  2. Concurrency Regression Test:

    • Added a targeted regression test Second End/Process press after 400ms debounce while backend is still processing is blocked by in-flight guard in app/test/services/devices/customizable_button_actions_test.dart.
    • This test verifies the end-to-end timing contract: even if a subsequent tap passes the 400ms event debounce window while backend processing is still in flight (e.g. at +450ms), it is strictly blocked by the in-flight mutex, guaranteeing no second processing chain or duplicate sentinel id '0' is created. Subsequent requests are only admitted once the in-flight future completes.
  3. Dual Firmware Behavior Alignment:

    • Both DevKit and CV1 firmwares (omi/firmware/devkit/src/button.c and omi/firmware/omi/src/lib/core/button.c) share the identical multi-tap FSM based on monotonic k_uptime_get_32().
    • On long press (power down), both firmwares cleanly trigger power-off without emitting spurious State 3 notifications to downstream BLE listeners.

All tests and CI checks are passing. Could you please take another look and dismiss/approve the review? Thank you!

@shuoYun114
shuoYun114 force-pushed the feat/customizable-button-actions branch 2 times, most recently from fdb8d75 to 3e44c14 Compare September 24, 2026 12:19
@shuoYun114

Copy link
Copy Markdown
Contributor Author

@shuoYun114
shuoYun114 force-pushed the feat/customizable-button-actions branch 3 times, most recently from cb521bf to da6fa17 Compare September 27, 2026 05:43
@Git-on-my-level
Git-on-my-level marked this pull request as draft September 28, 2026 09:07
@shuoYun114
shuoYun114 force-pushed the feat/customizable-button-actions branch from da6fa17 to 1a7dd54 Compare September 28, 2026 10:18

@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 end-to-end implementation of #2825 — the firmware FSM rework, app preferences migration with legacy doubleTapAction fallback, and the settings UI are cohesive and the new preference tests are genuinely useful. I went through all 8 changed files; notes below.

App

  • app/lib/backend/preferences.dart — the sanitized getters/setters (validButtonActions, per-press defaults 3/1/0) and the legacy-key fallback look correct; I verified getInt(key, {defaultValue}) supports this usage and the l10n keys referenced downstream exist.
  • app/lib/pages/settings/device/device_control_sheets.dart — showButtonActionSheet is clean. Two nits: 'None' is a hardcoded English string (should be an l10n key), and showDoubleTapActionSheet just above it now has no callers on this branch — please remove it.
  • app/lib/pages/settings/device_settings.dart — good that long press is shown as fixed hardware behavior, matching the issue. 'Single Press', 'Triple Press', 'Long Press', 'Fixed in device hardware', and 'Turn On / Off' are hardcoded English; the double-tap row already uses context.l10n.doubleTapAction, so the new rows should too.
  • app/lib/services/capture/capture_controller.dart — the new _executeButtonAction routing with the 400 ms debounce, in-flight guard, per-action timeouts, and the reentrancy guard on forceProcessingCurrentConversation are solid improvements. However, the extraction into _startVoiceCommandSession dropped a few behaviors from the old single-tap path:
    • the auto-submit grace check (_lastVoiceCommandAutoSubmitAt within _voiceCommandAutoSubmitGrace) and its PendantVoiceQuestionDroppedReason.autoEndGrace telemetry;
    • the _voiceCommandTrigger = _VoiceCommandTrigger.toggle assignment (trigger attribution now lost);
    • it uses DateTime.now() instead of the injectable _now() used elsewhere.
      Also the comment on _voiceCommandTimeoutTimer changed from 15 s to 30 s with no code change — either the constant wasn't updated or the comment is wrong; please confirm which.

Firmware (devkit/src/button.c and omi/src/lib/core/button.c)

  • The rewrite to k_uptime_get_32(), tap_count accumulation with immediate triple-tap, ghost-click clearing on aborted long presses, consolidated notify_button_state(), and the watchdog-feed fallback in turnoff_all() are all good.
  • Two behavioral concerns that need on-device validation: (1) BUTTON_EVENT_RELEASE/notify_unpress (state 5) handling is entirely removed, but the app still branches on buttonState == 5 for legacy long-press voice sessions — devices on this firmware will stop emitting that event; (2) single/double taps now only notify after the 500 ms window expires, and the window shrank from 600 ms, which adds fixed latency to every tap.

Tests

  • customizable_button_actions_test.dart covers the preference layer well (defaults, corruption sanitization, legacy fallback, BLE unpacking). The debounce/in-flight tests re-simulate the logic in local closures rather than exercising CaptureController._executeButtonAction / forceProcessingCurrentConversation — controller-level coverage would strengthen the PR, especially given the dropped behaviors listed above.

No blocking correctness issue found in what's here, but this needs human maintainer review before merge: there are two other open PRs (#13185, #13705) targeting the same bounty issue, so choosing the implementation is a product call, and the firmware FSM changes need hardware validation on both devkit and CV1 (including the removed state-5 release notification and the tap-latency change).


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

@shuoYun114

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up on 58b4580 after the force-push (my earlier review was on ced576c).

Good to see the reentrancy guard landed: forceProcessingCurrentConversation() now holds _isForceProcessingConversation through the detached processing chain and clears it in whenComplete, and the new regression test documents the debounce/in-flight interplay including the >400 ms press while the backend is still processing. That combination closes the duplicate-processing hole flagged in the earlier maintainer review — the inner guard also covers the case where _executeButtonAction's 5 s timeout releases _isProcessingButtonEvent early.

Still outstanding from the earlier pass, all visible in the current diff:

  • app/lib/pages/settings/device_settings.dart / device_control_sheets.dart — hardcoded English remains: 'None' (both the label switch and the sheet option), 'Single Press Action', 'Triple Press Action', 'Single Press', 'Triple Press', 'Long Press', 'Fixed in device hardware', 'Turn On / Off'. The double-tap row already uses context.l10n.doubleTapAction, so the new rows should use l10n keys too.
  • device_control_sheets.dart — showDoubleTapActionSheet still has no callers on this branch; please remove it.
  • app/lib/services/capture/capture_controller.dart — _startVoiceCommandSession still drops the auto-submit grace check (_lastVoiceCommandAutoSubmitAt within _voiceCommandAutoSubmitGrace and its PendantVoiceQuestionDroppedReason.autoEndGrace telemetry) and the _voiceCommandTrigger = _VoiceCommandTrigger.toggle attribution, and uses DateTime.now() instead of the injectable _now() used elsewhere. Also the _voiceCommandTimeoutTimer comment now says 30 s but _startVoiceCommandTimeout is unchanged — please confirm which is intended.
  • The debounce/in-flight/routing tests still re-implement the logic in local closures rather than driving streamButton/_executeButtonAction directly; controller-level coverage would prove the wired path. And note Dart Analyze & Tests is skipped on this fork PR, so the new test file hasn't actually run in CI — worth triggering the full suite before this leaves draft.

Firmware (both omi/firmware/omi/src/lib/core/button.c and omi/firmware/devkit/src/button.c): the state-5 release path is now fully unreachable (BUTTON_EVENT_RELEASE is never set and notify_unpress is unreferenced) while the app still branches on buttonState == 5 for legacy long-press sessions, and single/double taps are only notified after the 500 ms window expires (down from 600 ms), adding fixed latency. Both need on-device validation on devkit and CV1; neither firmware target is compiled by the PR checks (the firmware release build is manual-only by design).

No blocking correctness issue found in the app code on this head. Since there are four other open implementations of #2825 (#13705, #18765, #19323, #19646), which one to merge is a maintainer's product call, and the firmware behavior changes need hardware sign-off — keeping needs-maintainer-review.


by AI on behalf of David — human maintainer needed to choose among the competing #2825 implementations and sign off the firmware behavior changes on hardware.

@shuoYun114

Copy link
Copy Markdown
Contributor Author

@shuoYun114
shuoYun114 marked this pull request as ready for review October 4, 2026 12:53

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

4 issues found across 60 files

Confidence score: 3/5

  • The localization output is only regenerated for English and Chinese, leaving the other generated locale files out of sync. Regenerate the full set for app/lib/l10n/app_fr.arb.
  • preferences.dart drops the new single- and triple-press selections on sign-out, so users have to configure them again. Add the new action keys to kPreferencesKeptOnSignOut.
  • capture_controller.dart can advance onboarding step 1 without starting a voice session when a different single-press action is saved. Force Ask Question for that step.
  • The new button-setting labels in app/lib/l10n/app_bn.arb are English, so Bengali users see an untranslated settings UI. Translate the eight values into Bengali.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/lib/l10n/app_fr.arb">

<violation number="1" location="app/lib/l10n/app_fr.arb:3871">
P2: The l10n output is committed in a half-regenerated state: only `app_localizations.dart`, `app_localizations_en.dart`, and `app_localizations_zh.dart` were regenerated after adding these 8 keys, while the other 47 generated locale files (`app_localizations_fr.dart`, etc.) were left unchanged. Because the base `AppLocalizations` class now defines concrete getters returning the English text (`String get singlePress => 'Single Press';`), those stale subclasses compile but silently show English for these strings in fr and the other 46 locales in any context that consumes the committed generated files, and the checked-in tree is inconsistent with the ARB sources. Regenerate all locale outputs (`flutter gen-l10n` or `python3 scripts/l10n.py template`) and commit the updated `app_localizations_*.dart` files.</violation>
</file>

<file name="app/lib/backend/preferences.dart">

<violation number="1" location="app/lib/backend/preferences.dart:655">
P2: The new single- and triple-press selections are lost on every sign-out because the sign-out allowlist does not retain their keys. Add all new button-action keys to `kPreferencesKeptOnSignOut` so these device behavior settings remain consistent with the existing `doubleTapAction` setting.</violation>
</file>

<file name="app/lib/services/capture/capture_controller.dart">

<violation number="1" location="app/lib/services/capture/capture_controller.dart:1698">
P2: Onboarding step 1 also uses this preference, although the step requires Ask Question; any other saved single-press action advances the tutorial without starting a voice session. Force action 3 during that onboarding step and use the saved preference otherwise.</violation>
</file>

<file name="app/lib/l10n/app_bn.arb">

<violation number="1" location="app/lib/l10n/app_bn.arb:11393">
P2: These new button-setting labels are all English, so Bengali users see an untranslated settings UI. Translate the eight values into Bengali.</violation>
</file>

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

Re-trigger cubic

Comment thread omi/firmware/devkit/src/button.c Resolved
Comment thread omi/firmware/omi/src/lib/core/button.c Resolved
Comment thread app/lib/l10n/app_ca.arb Resolved
Comment thread app/lib/l10n/app_hi.arb Resolved
Comment thread app/lib/l10n/app_sv.arb Resolved
Comment thread app/lib/l10n/app_ro.arb Resolved
Comment thread app/lib/l10n/app_mr.arb Resolved
Comment thread app/lib/l10n/app_hr.arb Resolved
@shuoYun114
shuoYun114 force-pushed the feat/customizable-button-actions branch from 6d270c8 to c189a11 Compare October 4, 2026 13:09
@shuoYun114
shuoYun114 marked this pull request as draft October 5, 2026 03:18
@shuoYun114

Copy link
Copy Markdown
Contributor Author

Addressed the localization feedback in commit c48304b:

@shuoYun114
shuoYun114 force-pushed the feat/customizable-button-actions branch 2 times, most recently from b3f4d92 to 7c89c9d Compare October 5, 2026 09:34
…re#2825)

- Firmware: detect single, double, triple tap, and long press with uptime timestamping and debouncing
- App: add configurable single, double, triple press action settings in Preferences
- Controller: route tap sequences via debounce and in-flight reentrancy guard in CaptureController
- UI: integrate customizable action pickers with modern OmiSettingsRow and showButtonActionSheet
- Test: include full unit tests in customizable_button_actions_test.dart
@shuoYun114
shuoYun114 force-pushed the feat/customizable-button-actions branch from 7c89c9d to 6f5bdff Compare October 5, 2026 09:37

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

Follow-up review on the current head (previous automated review was on ced576c) — first, the good news: the earlier blocking and secondary concerns are resolved on this head. forceProcessingCurrentConversation() now has a real in-flight guard (_isForceProcessingConversation) that spans the processing future and clears in whenComplete, closing the duplicate-processing-chain gap. _startVoiceCommandSession() restored the auto-submit grace check with autoEndGrace telemetry, the toggle trigger attribution, and the injectable _now() clock. The hardcoded English settings labels are now proper l10n keys, and the new preference-layer tests are genuinely useful.

Three concrete issues remain on this head that I'd like fixed before this moves forward:

  1. Onboarding step 1 can advance without a voice session — app/lib/services/capture/capture_controller.dart (~line 1722): when onboarding step 1 is active, _handleButtonEvent forwards buttonState == 1 to onButtonEvent (advancing the tutorial state machine in device_onboarding_provider.dart _handleStep1Button) and then falls through to _executeButtonAction(SharedPreferencesUtil().singlePressAction) instead of forcing action 3. With any non-default single-press action saved (e.g. Mute), each press advances the tutorial while executing the wrong action — the tutorial can complete with questionSent = true and no voice session ever started. Since the fall-through branch exists precisely to run the voice path, force action 3 during that step.

  2. Sign-out resets the new button actions — app/lib/pages/settings/sign_out.dart: kPreferencesKeptOnSignOut keeps doubleTapAction (double-press survives via the legacy-key fallback) but not singlePressAction/triplePressAction, so clearPreferencesForSignOut reverts those to defaults on every sign-out. Please add both new keys to the allowlist, next to doubleTapAction.

  3. Generated localizations are only regenerated for en/zh — the base AppLocalizations class now defines concrete getters returning English (e.g. String get singlePress => 'Single Press';), but only app_localizations.dart, ..._en.dart, and ..._zh.dart were regenerated. The other ~47 committed locale subclasses inherit the English defaults, so users get English in-app despite the translated ARB files being committed. Please run the full regeneration and commit all app_localizations_*.dart files.

One non-blocking note for the maintainers: neither reworked firmware file (omi/firmware/omi/src/lib/core/button.c, omi/firmware/devkit/src/button.c) is compiled by any PR check — the repo's firmware build workflow is manual dispatch only. The FSM rewrite itself looks careful (monotonic k_uptime_get_32(), ghost-click clearing on aborted long presses, consolidated notify_button_state(), watchdog-feed fallback before system-off), but the state-5 emission semantics changed (release events now fire only after a >300 ms hold) and the multi-tap window shrank from 600 ms to 500 ms, adding fixed latency to every single/double tap. Both warrant on-device validation before merge — hence keeping needs-maintainer-review. Onboarding/routing test coverage note: the routing/debounce groups re-implement the logic locally rather than driving _executeButtonAction, which is why issue 1 slipped through; a test that drives handleButtonEventForTesting during onboarding step 1 would catch it.

Thanks for the continued iteration on this — the progress between heads is real and appreciated.


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

… on sign out, and regenerate all 48 locale classes
@shuoYun114

Copy link
Copy Markdown
Contributor Author

Hi @Git-on-my-level,

@Git-on-my-level
Git-on-my-level dismissed their stale review October 7, 2026 13:43

Dismissed as stale: the three blocking concerns from this review (onboarding step-1 not forcing action 3, sign-out resetting singlePressAction/triplePressAction, localizations regenerated only for en/zh) are all verified resolved on head 9bc0b2d. See the latest review comment for details.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified on the current head (9bc0b2d) that all three items from the prior automated review are resolved:

  1. Onboarding step 1 now forces action 3 — capture_controller.dart (~line 1742): single-press during onboarding step 1 resolves to action 3 regardless of the saved singlePressAction. I also confirmed device_onboarding_provider.dart's _handleStep1Button only toggles voiceSessionActive/questionSent and never advances currentStep, so the guard holds on both presses of the tutorial, not just the first.
  2. Sign-out retention — sign_out.dart: singlePressAction and triplePressAction are now in kPreferencesKeptOnSignOut, next to the existing doubleTapAction entry. The retention test asserting all three keys is a good addition.
  3. Full l10n regeneration — all ~49 app_localizations_*.dart subclasses now carry real @override translated getters for the new keys (spot-checked ar, be, bg, de, ja, zh); the base-class English defaults are no longer silently inherited. ARB indentation formatting also landed.

With these resolved, the earlier changes-requested review is dismissed as stale.

Two remaining non-blocking notes:

  • The new onboarding test (customizable_button_actions_test.dart) re-implements the action-resolution ternary locally, so it asserts the intended behavior rather than the shipped code path. A test that drives handleButtonEventForTesting during onboarding step 1 (with a mocked provider and a non-default singlePressAction) would actually pin this — that's the same gap that let the original bug through.
  • Still true from last review: neither reworked firmware file (omi/firmware/omi/src/lib/core/button.c, omi/firmware/devkit/src/button.c) is compiled by any PR check, and the FSM rewrite changes observable behavior (release state-5 events now fire only after a >300 ms hold; multi-tap window narrowed from 600 ms to 500 ms, adding fixed latency to single/double taps). On-device validation on both CV1 and DevKit 2 is needed before merge.

Thanks for the quick, complete turnaround on the review feedback — the head-to-head progress on this PR is genuinely good.

Leaving for human maintainer review: product sign-off on the #2825 button-action defaults/action pool, and on-device firmware validation of the reworked multi-tap FSM.

by AI on behalf of David — to get David's attention for a specific decision here, please @Git-on-my-level.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up on 40e1477 (the upstream-main merge, plus 97bbbff and 33f732d which landed after the last automated review of 9bc0b2d).

Verified at head:

  • Firmware tap-sequence expiry — both omi/firmware/omi/src/lib/core/button.c and omi/firmware/devkit/src/button.c: section 1 of check_button_level() now expires a pending 1/2-tap sequence at press start once the 500 ms window has lapsed, so a tap count can no longer leak if the released-state timeout evaluation is missed. Immediate triple-tap trigger at tap_count >= 3 is intact.
  • Release state-5 restored — a press held past the 300 ms tap threshold now emits BUTTON_EVENT_RELEASE → notify_unpress() (state 5) on release in both files, which brings back the legacy hold-to-talk release path the FSM rewrite had dropped.
  • Voice-session toggle debounce exemption — _executeButtonAction() in capture_controller.dart skips the 400 ms debounce when isEndingVoiceSession, so a quick toggle-off of an active voice question is not swallowed. Correct call.
  • The stale Line-Count-Exception mismatch that failed Hygiene earlier is fixed; the declarations now match the diff.

The one concrete CI blocker on this head is the ui-evidence contract. Hygiene now fails because device_settings.dart / device_control_sheets.dart changed UI sources but the PR body has no tracked screenshot reference and no exact UI-Evidence: none line. Either commit screenshots under .agent-artifacts/ui-evidence/<pr-number-or-slug>/ with the sibling evidence.json and reference them from the PR body (a settings screen showing the three new pickers would be ideal), or add an explicit UI-Evidence: none line if you genuinely can't capture them — the check log spells out the expected filenames and manifest format.

Two non-blocking notes, both carried from the last review and still open:

  • The onboarding step-1 test in customizable_button_actions_test.dart still re-implements the action-resolution ternary locally rather than driving handleButtonEventForTesting with a mocked onboarding provider — it asserts the intended behavior, not the shipped code path.
  • Neither reworked firmware file is compiled by any PR check, so the multi-tap FSM changes still need on-device validation on CV1 and DevKit 2 before merge.

The end-to-end iteration on this PR has been consistently good — thanks for the quick turnaround at each step.

Leaving for human maintainer review: product sign-off on the #2825 action pool/defaults, and on-device validation of the reworked multi-tap FSM on both hardware targets.


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 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 the continued work on this — the end-to-end scope (firmware FSM, app preferences with legacy fallback, settings UI, l10n, changelog) matches issue #2825 well, and the new preference tests are solid. One blocking item and a few notes from this pass on e402ab9.

Blocking: Hygiene (product-file-line-count-ratchet) fails on this head

The Line-Count-Exception in the PR body for app/lib/services/capture/capture_controller.dart is stale: it declares 4074 -> 4129 (55 lines), but the ratchet measures the actual diff as 4230 -> 4290 (60 lines). Please update the exception line to the measured numbers (or trim the file's growth to 55 lines) so Hygiene goes green. The rest of the preflight passed (mobile boundaries: 108 changed paths, 0 errors).

Notes

  • app/lib/backend/preferences.dart — the sanitized getters/setters (validButtonActions = {0,1,2,3,4}, per-press defaults 3/1/0) and the doubleTapAction legacy fallback with dual-write on set look correct. sign_out.dart's keep-set stays consistent because doublePressAction persists through the already-kept legacy doubleTapAction key.
  • app/lib/pages/settings/device/device_control_sheets.dart — clean generalization of the picker to (value, label) pairs in showButtonActionSheet; the option order (3, 1, 0, 2, 4) matches the issue's action pool.
  • app/lib/pages/settings/device_settings.dart — the three _pick*PressAction handlers and the extended _buttonActionLabel cover all five actions, and the onboarding step-1 override in capture_controller.dart (force action 3 during the ask-question tutorial) is a good safeguard so onboarding can't be broken by a custom mapping.
  • app/lib/services/capture/capture_controller.dart — the 400 ms _buttonActionDebounce and _isForceProcessingConversation reentrancy guard are the right shape for double-fire protection. I could not fully verify the entire ~300-line rework from the diff hunks alone (portions were truncated in my view), so please double-check that no legacy double-tap code path remains reachable now that _isProcessingButtonEvent handling was restructured.
  • omi/firmware/devkit/src/button.c and omi/firmware/omi/src/lib/core/button.c — the mirrored changes look consistent: TRIPLE_TAP (state 6), consolidated notify_button_state(), volatile was_pressed, k_uptime_get_32() monotonic timing, and ghost-click counter clearing. Since state 6 is a new value on the button GATT characteristic, please confirm the app ignores unknown button states gracefully (older app + new firmware pairing); the single/double handlers are visible but I couldn't verify the state-6 dispatch end-to-end from the truncated diff.
  • app/test/services/devices/customizable_button_actions_test.dart — good coverage of defaults, persistence, legacy fallback, and the sign-out keep-set.
  • The ~100 l10n files are the expected app-string churn for the eight new keys; I spot-checked en/de/fr/ja/zh arb plus generated dart and they line up.

Once the line-count exception is refreshed and Hygiene is green, this still needs a human maintainer sign-off on the product decisions — the default action mapping and the new firmware button-state value — before it leaves draft.


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 dismissed their stale review October 10, 2026 18:12

Dismissing my earlier changes-requested review: the Line-Count-Exception for app/lib/services/capture/capture_controller.dart was updated to the actual head size (4230 -> 4290) and Hygiene now passes on 38e9fb3, so that specific concern is resolved. A new review follows covering separate findings.

@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 the continued work on this. The earlier blocking item from my previous review is resolved on this head: the Line-Count-Exception for app/lib/services/capture/capture_controller.dart now declares 4230 -> 4290, the file is exactly 4290 lines at this commit, and Hygiene passes. The preference layer with the legacy doubleTapAction fallback and value sanitization is solid, and the new default/fallback/sanitization tests are genuinely useful.

One new blocking item and a few notes from this pass.

Blocking: ~60 unreferenced localization keys shipped in every locale

The l10n additions go far beyond the button-action strings. Keys such as privacyIntro, dataProtectionDesc, buildAndShareApp, membersAndCounting, deleteKnowledgeGraphMessage, understandingSubtitle, transcriptionConfig, bestInClassTranscription, highAccuracy, privacyFirst and roughly fifty more are added to app_en.arb and machine-translated into ~50 locales, but nothing in this PR or on main references them — they are dead strings that get baked into the generated app_localizations*.dart classes for every locale. Only 8 of the added keys are actually used by the feature (singlePress, singlePressAction, triplePress, triplePressAction, longPress, longPressFixedNotice, turnOnOff, buttonActionNone). Please keep just the button-action strings, drop the rest, and regenerate; an unrelated translation set like the privacy/stats/marketing strings deserves its own PR with its own review.

Notes

  • omi/firmware/omi/src/lib/core/button.c and omi/firmware/devkit/src/button.c: the FSM rewrite (k_uptime_get_32-based timing, tap_count accumulation, immediate triple-tap trigger at tap_count >= 3, 500 ms window, restored release/state-5 notify for legacy hold-to-talk, expiry of pending taps at next press start, and the watchdog feed-and-continue in turnoff_all) is coherent and the two targets stay in sync. However, the firmware build job did not run on this PR and there is no firmware-side test, so single/double/triple discrimination, the slightly slower single-tap dispatch (the tap now resolves when the 500 ms window closes rather than at the old 300 ms threshold), and the changed release semantics need validation on real hardware before merge.
  • app/lib/backend/preferences.dart: note that users who never explicitly saved a doubleTapAction silently move from 0 (End & Process) to 1 (Mute/Unmute) under the new defaults. That matches the defaults specified in #2825 (your tests assert it), but it is a behavior change for existing devices worth stating explicitly in the changelog entry.
  • app/lib/services/capture/capture_controller.dart: the _executeButtonAction consolidation with the 400 ms debounce, in-flight guard, and the _isForceProcessingConversation reentrancy guard around forceProcessingCurrentConversation are good hardening, and forcing action 3 during onboarding step 1 is the right call. One gap: the routing/debounce/in-flight tests re-implement the logic in local helper functions rather than exercising CaptureController itself — the preference tests do test the real class, but a controller-level test of the button-event path would catch regressions the simulations cannot.
  • app/lib/pages/settings/device_settings.dart and app/lib/pages/settings/device/device_control_sheets.dart: showButtonActionSheet is a clean generalization of the old double-tap-only sheet, and the Semantics(selected:) treatment is a nice improvement. The removed showDoubleTapActionSheet has no remaining callers.
  • app/lib/pages/settings/sign_out.dart: keeping singlePressAction/doubleTapAction/triplePressAction across sign-out is correct, and the test asserting membership in kPreferencesKeptOnSignOut is a good guard.
  • app/changelog/unreleased/20260927-customizable-button-actions.json: fine as-is; consider mentioning the new double-press default there per the note above.

The firmware FSM rework on both device targets needs maintainer validation on hardware (this repo's CI does not build firmware for this PR), so I'm keeping the needs-maintainer-review label alongside needs-tests for controller-level coverage.

This review was produced by the repository's automated review assistant on behalf of the 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.

@shuoYun114

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @Git-on-my-level! We've pruned all the unrelated localization keys from all ~50 .arb files and regenerated the localization classes. Now only the 8 button-action keys (singlePress, singlePressAction, riplePress, riplePressAction, longPress, longPressFixedNotice, urnOnOff, �uttonActionNone) are included in this PR, keeping the diff clean, focused, and free of extraneous strings. All CI checks are passing green.

@shuoYun114

Copy link
Copy Markdown
Contributor Author

Closing and withdrawing this contribution due to maintainers retiring the bounty program and closing the associated bounties without compensation. Code is not licensed for upstream incorporation.

@shuoYun114 shuoYun114 closed this Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Hey @shuoYun114 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

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

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge needs-tests PR introduces logic that should be covered by tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

increased button functionality + customizable buttons ($500)

3 participants