Repository navigation
feat(app): expose Omi haptic through local URL scheme - #13698
undivisible merged 21 commits into
Conversation
9cb50c6 to
5f933ec
Compare
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
woahwhattheheck
left a comment
There was a problem hiding this comment.
Exact-head review finding (19ca04d): the parser checks are strict, and current CI is green, but the new trust boundary still has an unbounded physical-actuator flood path. Production Android registers the omi URL scheme on an exported, BROWSABLE MainActivity, so other apps / browser navigation can invoke omi://device/haptic?.... openAppLink then calls ensureConnection(..., force: true) and immediately writes the haptic characteristic. In firmware, every haptic write calls play_haptic_milli, which cancels the pending haptic_off_work and schedules a new delayed-off timer; repeated level-3 links can therefore continuously extend motor-on time far beyond the nominal 500 ms command while also forcing BLE reconnection when disconnected.
Please bound this external command before merge—e.g. an app-side per-device cooldown / burst limiter (set before awaiting the connection/write so concurrent URI deliveries cannot race through it), or another explicit authorization/opt-in boundary that prevents arbitrary URL-scheme callers from driving an unbounded stream. Add a focused regression test proving rapid repeated external commands are rejected/coalesced rather than each reaching playHaptic. This preserves the intended local-agent notification use case without turning a BROWSABLE custom scheme into an unlimited wearable actuator/reconnect primitive.
woahwhattheheck
left a comment
There was a problem hiding this comment.
SOURCE RED · exact successor 4ae37974a28afe2ddf1236d4bc7c96327b24655b · independent review by Z-LaplaceHarbor-913948-X7K4 (ZLH-X7K4) / GPT-5.6 Sol.
The successor materially closes the predecessor’s immediate concurrency hole: the per-device slot is reserved synchronously before the first awaited reconnect/write, exact-boundary timing is deterministic, and an unavailable/failed dispatch consumes the slot. The new test correctly proves an immediate second URI cannot race through while the first player Future is pending.
One stop-merge physical-output/reconnect class remains: the limiter bounds admission time, not in-flight dispatches. After cooldown elapses, a second URI is accepted even if the first playHaptic Future is still unresolved. On the real AppShell path that Future first awaits ServiceManager.instance().device.ensureConnection(deviceId, force: true). DeviceService.ensureConnection() holds its global _mutex across _connectToDevice() / connection.connect(). Therefore, during a slow/offline reconnect an external caller can feed one accepted haptic URI every two seconds; those calls can queue behind the device mutex. When the connection finally succeeds, the queued calls acquire the mutex in turn, see the now-connected transport, return it immediately, and then each executes performPlayToSpeakerHaptic(level) outside the mutex. That converts a rate-limited arrival stream into a delayed burst of physical BLE writes, and still permits a bounded-but-growing reconnect/request queue while the first operation is unresolved.
This is directly reproducible at the new helper boundary without BLE: hold the first playHaptic Completer pending; advance injected elapsed time to exactly 2s; invoke a second haptic for the same device. Current code admits the second call and invokes player a second time even though the first dispatch is still pending. The current hostile advances to 2s only after completing the first Future, so it misses this case.
Closure: make same-device dispatch single-flight in addition to the cooldown (e.g. reserve an in-flight flag synchronously and release it only after playHaptic completes, while preserving the cooldown timestamp so failed dispatches still consume a slot), or mechanically prevent a later admitted URI from reaching reconnect/write while an earlier one is pending. Add the deterministic hostile first pending -> elapsed >= cooldown -> second same-device URI => rateLimited/coalesced and player call count remains 1; then prove a later call is admitted only after first completion plus the intended cooldown semantics. Keep per-device independence if multiple devices are intentionally supported.
Positive findings: scheme/host/path/level parsing remains narrow; production AppShell uses the module-global limiter rather than constructing a fresh limiter; same-device immediate concurrency and failed-dispatch retry storms are materially improved. Current exact-head workflow truth at review: Web Checks, Desktop Swift CI, Repo Checks, Backend Hermetic E2E, Backend Checks, and Desktop Checks completed SUCCESS; Mobile App Checks was still IN_PROGRESS, so this review does not call the whole head green.
REVIEW ONLY. Source/ref/finalization stay with the PR owner. Any head move invalidates this verdict.
kodjima33
left a comment
There was a problem hiding this comment.
Feature (new external haptic URL-scheme trigger), not a bug fix — per policy, features in app/mobile are approve-only, not merged. Scoped diff, custom-scheme-only (HTTPS explicitly rejected), tests added. No abuse signals.
woahwhattheheck
left a comment
There was a problem hiding this comment.
SOURCE GREEN on exact successor a35e37271d3323b4c184071dad0f3c62267f1df3 — independent rereview by Z-NoetherSpindle-914044-L6P3 (ZNS-L6P3) / GPT-5.6 Sol.
The residual physical-output/reconnect class from review 5191017002 is mechanically closed on this head. ExternalHapticRateLimiter.tryAcquire() now rejects a same-device request whenever that device is already in _inFlight, before consulting the cooldown and before any awaited reconnect/write; the reservation is added synchronously at admission and released only in finally. _lastAcceptedAt is deliberately retained across release, so false-return and throwing dispatches still consume the cooldown rather than creating retry storms. The production path uses the module-global limiter, so repeated openAppLink() deliveries do not instantiate fresh state.
The new hostile is the exact prior counterexample: first playHaptic Future remains unresolved, injected monotonic elapsed advances to the full 2-second boundary, a second same-device URI returns rateLimited, and player call count remains 1. Only after the first Future completes and releases single-flight can another dispatch enter. A separate throw-path hostile proves finally releases _inFlight without erasing the cooldown timestamp. The parser remains narrowly restricted to the three app-owned schemes, exact device/haptic, and one canonical level in 1..3; HTTPS and repeated/noncanonical level encodings remain non-handled. The AppShell path still fails closed when no paired device/connection exists or the native BLE transport lacks the haptic characteristic.
I do not find a surviving source-level blocker in the predecessor flood/burst class on this exact SHA. This is a source verdict only; upstream maintainer policy/merge authority and hosted execution remain separate. Any head movement invalidates this review.
|
Thanks for this — reviewed alongside the maintainer approval on this head. The implementation is clean: Two non-blocking observations:
Also verified the early return in by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
app/mobile feature (URL-scheme haptic trigger), not a bug fix — approve-only per confidence gate (features stay approve, no merge). Reviewed: scheme allowlist is custom (omi/omi-dev/omi-beta) only, HTTPS explicitly rejected, level validated 1-3, reuses existing BLE haptic primitive, hermetic tests added. No abuse signals.
kodjima33
left a comment
There was a problem hiding this comment.
app/mobile feature (URL-scheme haptic trigger), not a bug fix — approve-only per confidence gate. Reviewed: scheme allowlist is custom-only (omi/omi-dev/omi-beta), HTTPS explicitly rejected, level validated 1-3, reuses existing BLE haptic primitive, hermetic tests added. No abuse signals.
kodjima33
left a comment
There was a problem hiding this comment.
Re-evaluated under current policy (backlog drain).
kodjima33
left a comment
There was a problem hiding this comment.
Mobile feature (URL-scheme haptic trigger), not a bug fix — approve-only per policy; reuses existing BLE primitive, has test coverage, fails closed on malformed input.
kodjima33
left a comment
There was a problem hiding this comment.
Mobile feature (approve-only per policy — non-desktop features don't merge). Scoped, tested, no auth/secrets touched.
kodjima33
left a comment
There was a problem hiding this comment.
Feature (new external haptic-trigger URL scheme for the paired device), not a bug fix. app/lib is mobile/cross-platform Flutter code, not desktop/ or app/macos/, so per policy this needs Nik's product call rather than an autonomous merge. CI green, scoped and well-tested; approve only.
kodjima33
left a comment
There was a problem hiding this comment.
Mobile feature (haptic via local URL scheme), reuses existing BLE primitive, has unit tests, no auth/secret surface touched. Not desktop so no Summer Challenge ping; approve-only per confidence gate (feature, not a bug fix).
kodjima33
left a comment
There was a problem hiding this comment.
feat(app): new haptic URL-scheme trigger -- feature, approve-only per policy. No abuse signals (scheme allowlist, no HTTPS/credential surface).
kodjima33
left a comment
There was a problem hiding this comment.
Mobile feature (haptic via URL scheme), not a bug fix — approve-only per policy.
Watch and Ray-Ban transports no-op characteristic writes and still return success, so the external haptic URL reported played without a motor write. Only a native BLE transport that exposes the speaker haptic characteristic may proceed.
Restores app_shell.dart after an empty placeholder commit and keeps the external haptic path from reporting played on Watch or Ray-Ban transports, which no-op characteristic writes.
kodjima33
left a comment
There was a problem hiding this comment.
Mobile feature (haptic via URL scheme), not a bug fix — approve-only per policy. Hygiene check failing but not a merge candidate anyway.
kodjima33
left a comment
There was a problem hiding this comment.
Mobile feature (haptic trigger via local URL scheme), not a bug fix — approve only per policy, no merge. Note: Hygiene check is currently failing and this introduces a new externally-triggerable device-action surface worth a security glance.
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the careful work here - the fail-closed design and the single-flight rate limiter are well done, and this head already carries maintainer approval. One mechanical blocker remains before merge.
Blocking: Hygiene mobile-changelog-entry is red on this head
App changes require an unreleased changelog fragment that travels with the commit. This PR adds a user-invokable capability (omi://device/haptic?level=1|2|3), so it should carry a real fragment under app/changelog/unreleased/ describing the new scheme; a {"kind": "none"} fragment is only appropriate for internal-only edits. Adding it turns the PR run and the post-merge push run green together.
Review notes on the changed files:
- app/lib/services/external_haptic_trigger.dart - the parser is tight: allowlisted schemes (omi/omi-dev/omi-beta), host must be device, exactly one haptic path segment, a single canonical level in 1-3 (rejects 0x2, 02, %2B2, and repeated params). I particularly like that the rate limiter's admission timestamp survives a failed dispatch, so failed reconnect attempts still consume the 2s window instead of accumulating a burst.
- app/lib/core/app_shell.dart - good if (!mounted) return guard after the await. The playHaptic callback fails closed unless the transport is NativeBleTransport and actually exposes the speaker haptic characteristic, which correctly sidesteps the Watch/Ray-Ban no-op writeCharacteristic trap where performPlayToSpeakerHaptic would report success without a motor write. The notHandled fall-through preserves the existing deep-link path.
- app/lib/services/devices/transports/native_ble_transport.dart - the read-only hasCharacteristic wrapper is minimal and the fail-closed intent is documented at the call site and the method.
- app/test/unit/external_haptic_trigger_test.dart - thorough coverage: scheme matrix, HTTPS rejection, non-canonical levels, no paired device, unavailable transport, single-flight past cooldown, cooldown-consumed-on-failure, and thrown-player release semantics.
One design note for the record (not blocking): custom URL schemes can be fired by any local app, and on Android indirectly by web content. The per-device cooldown plus fail-closed transport check keeps that surface to an occasional buzz on the user's own wearable with no data returned to the caller - fine for the linked use case (#6716), just worth revisiting if this family of omi://device/... commands grows.
Once the changelog fragment lands and Hygiene goes green, this looks merge-ready from my side; no further review needed.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Add the user-facing release note required by PR BasedHardware#13698's mobile changelog gate. Verification commands: python3 .github/scripts/check-mobile-changelog.py --base f098880 --head HEAD python3 .github/scripts/mobile-changelog.py validate git diff --cached --check Changelog checks use the repository scripts from upstream main at 8cdeea9.
Resolve the AppShell link-routing conflict by retaining the reviewed haptic handler and upstream Home Screen widget routing. Preserve the reviewed haptic service and unit-test blobs. Verification commands: python3 .github/scripts/check-mobile-changelog.py --base 8cdeea9 --head HEAD python3 .github/scripts/mobile-changelog.py validate git diff --check 8cdeea9...HEAD Flutter is not installed in the local environment.
|
@Git-on-my-level The blocking mobile changelog requirement is now satisfied in this PR. At head The branch also incorporates main while retaining both Home Screen link routing and the haptic handler. The reviewed haptic service and unit tests are preserved. The PR description now records these results; Flutter tests were not run locally, and mobile test/build jobs were skipped by CI. Final status: PR Metadata Preflight also passed on this head. GitHub reports the PR as mergeable with a clean merge state. |
Dismissing this changes-requested review: the missing mobile changelog fragment has been added (app/changelog/unreleased/20261001-local-link-haptics.json) and the Hygiene check, including mobile-changelog-entry, now passes on the current head.
|
The changelog blocker from the prior review is resolved — The substantive implementation still looks good on re-read against the merged base: the strict URL grammar and scheme allowlist in Leaving the merge decision to the maintainers; re-adding by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks @woahwhattheheck — this is a carefully built change. Reviewed all five files on head
One ask: the mobile Dart/Build/Formatting CI jobs were skipped on this head, so the new 240-line test file hasn't been executed by CI. Please confirm it runs (e.g. push a trivial update or trigger the mobile CI path) before merge. For maintainers: this introduces a new externally-invokable actuation surface on the paired wearable ( This review was drafted by an AI reviewing agent on behalf of the Omi maintainers. It reflects policy and code analysis, not a human decision. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Executed the existing focused haptic test against current head
Successful execution and complete logs · Evidence artifact The runner downloaded the unchanged service and existing test from the exact commit, verified their Git blob hashes before execution ( flutter test --no-pub test/unit/external_haptic_trigger_test.dart --reporter expanded
flutter analyze --no-pub lib/services/external_haptic_trigger.dart test/unit/external_haptic_trigger_test.dartThe artifact contains the JSON test event stream, console/analyzer logs, source provenance, runtime version, and resolved harness lockfile. The cases cover supported schemes, HTTPS and malformed-level rejection, missing/unavailable devices, pending single-flight dispatch, failed-dispatch cooldown, and thrown-player cleanup. This establishes execution of the existing self-contained unit test only—not the full app dependency graph, Android/iOS builds, BLE/device integration, or a replacement for upstream CI. The original PR branch remains unchanged at |
|
Thanks @woahwhattheheck — the test-execution ask from the prior review is resolved. The evidence run is tied to this exact head (blob hashes I also re-verified the dispatch wiring against main: No technical blockers remain from my side. What's left is maintainer product sign-off on the current head: the approvals on record predate This comment was drafted by an AI reviewing agent on behalf of the Omi maintainers. It reflects policy and code analysis, not a human decision. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
AppShell listens to app links through `uriLinkStream.distinct()`, which drops any link equal to the one before it. #13698 routes `omi://device/haptic?level=N` through the same stream, so the second identical haptic link (an agent signalling "done" again, a Shortcut run twice) never reaches runExternalHapticTrigger: no buzz, no log line. Changing the level makes it work again, which is how it shows up. Haptic links are commands, so they now pass the dedupe; the trigger's 2s rate limiter already bounds bursts. Every other link is still deduped as before.
Summary
omi://device/haptic?level=1,2, or3(withomi-dev/omi-betafor those build identities).performPlayToSpeakerHapticBLE primitive rather than adding a second device transport path.This gives integrations and local agent workflows a small external-output primitive: an agent can signal “finished” or “needs attention” on the wearable without requiring the user to watch a screen.
app/changelog/unreleased/20261001-local-link-haptics.json: “Make your paired Omi buzz from local app links.”Verification
Added
app/test/unit/external_haptic_trigger_test.dartcovering the core path and main error paths.The focused mobile changelog check passed (
Mobile changelog fragment found.). At headaa72ae3502a6addc275ec750d5231bd8c0f8f05e, GitHub Actions Hygiene and Formatting passed. Hygiene includes passingmobile-changelog-entryandmobile-changelog-datachecks.On October 4, the unchanged service and existing focused test from head
aa72ae3502a6addc275ec750d5231bd8c0f8f05ewere executed in a minimal Flutter package using repository-pinned Flutter 3.44.5: 8/8 cases passed and focusedflutter analyzereported no issues. Source Git blob hashes were verified before execution. Execution logs · Evidence artifact. This verifies the self-contained service/unit-test only; the full application dependency graph, Android/iOS builds, BLE/device integration, and upstream mobile CI remain separate. The mobile Dart/test/build jobs on this head were skipped by upstream CI.The dispatch path itself reuses the existing device connection haptic writer, which already has focused BLE write coverage in the repository.
Security / trust boundary
The new parser accepts only the app identities' custom URL schemes (
omi,omi-dev,omi-beta) and does not treat HTTPS links as executable haptic commands. Levels are restricted to the firmware/app contract range 1–3.Product invariants affected
Failure class (fixes)
Failure-Class: none
Backend Hermetic Merge Gate
Out of scope: app-only Dart change; no backend or lockfile changes.
Fixes #6716