Skip to content

fix(agent): apply per-app gesture button clicks - #430

Open
devsaddle wants to merge 1 commit into
AprilNEA:masterfrom
devsaddle:codex/fix-per-app-gesture-button
Open

fix(agent): apply per-app gesture button clicks#430
devsaddle wants to merge 1 commit into
AprilNEA:masterfrom
devsaddle:codex/fix-per-app-gesture-button

Conversation

@devsaddle

@devsaddle devsaddle commented Jul 20, 2026

Copy link
Copy Markdown

Summary

Apply per-app single-action overrides to the Click arm of dedicated HID++ gesture sources while keeping their global swipe directions and gesture mode intact.

This revision rebases the original fix onto the current multi-source, per-button gesture architecture. It supports both the dedicated gesture button and other HID++ gesture sources such as the MX Master 4 haptic panel.

Root cause

Capture plans already rebuild their ordinary bindings for the foreground app, but hidpp_gesture_maps_for still projected only the global gesture maps. A dedicated HID++ gesture press therefore kept dispatching its global Click action after the foreground app changed.

Changes

  • pass the foreground app into hidpp_gesture_maps_for
  • build gesture mode and swipe arms from the global binding shape
  • overlay an effective per-app Binding::Single onto only GestureDirection::Click
  • pass the app through each device capture plan while keeping the GUI's editing view global
  • cover click override, swipe preservation, and foreground-app capture-plan republishing

Testing

  • cargo fmt --all
  • cargo test -p openlogi-core -p openlogi-agent-core --locked (191 core tests, 91 agent-core tests)
  • cargo clippy -p openlogi-core -p openlogi-agent-core --all-targets --locked -- -D warnings
  • cargo check -p openlogi-gui --locked reached GPUI's macOS shader build; the local Xcode installation lacks the optional Metal Toolchain, so the full GUI build is left to CI

Previously hardware-validated with an MX Master 2S using Safari and Chrome per-app navigation actions.

@devsaddle
devsaddle marked this pull request as ready for review July 20, 2026 09:55
@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes per-app gesture button click actions not being applied to HID++ gesture sources (e.g. the dedicated gesture button, MX Master 4 haptic panel). Capture plans were already rebuilt per foreground app for ordinary bindings, but hidpp_gesture_maps_for projected only the global gesture maps, so the Click arm of a gesture source kept firing its global action after the foreground app changed.

  • hidpp_gesture_maps_for gains an app_bundle parameter; it computes the effective per-app bindings once and overlays a Binding::Single action onto the Click arm of each gesture-mode source while leaving swipe directions and gesture mode from the global shape intact.
  • plan_for_device now threads app through to hidpp_gesture_maps_for; the GUI call site explicitly passes None to preserve the global-only editing view.
  • A new unit test (hidpp_source_applies_per_app_click_and_preserves_swipes) and an extended orchestrator integration test verify click override and swipe preservation end-to-end.

Confidence Score: 5/5

  • The change is tightly scoped: it adds one parameter to one function, uses the global binding shape to determine gesture mode, and only writes to the Click arm when the per-app effective binding is a plain Single action. All existing call sites are updated correctly; the GUI keeps the global view via an explicit None.
  • The fix is minimal and well-contained — one parameter threaded through two call sites, with the GUI explicitly opting out. The overlay logic is correct: the global stored bindings determine gesture mode (so a per-app Single cannot accidentally re-enable a demoted gesture source), and the effective per-app map is only consulted to patch the Click arm. New unit and integration tests cover the primary scenario and swipe-preservation invariant.
  • No files require special attention.

Important Files Changed

Filename Overview
crates/openlogi-core/src/bindings.rs Adds app_bundle parameter to hidpp_gesture_maps_for; overlays a per-app Binding::Single onto the Click arm while preserving the global gesture shape and swipe directions. Logic is sound — the effective binding is computed once outside the iterator and only applied when the effective result is a Single, which is unreachable when the global binding is already Single (filtered out earlier by the Binding::Single(_) => None arm). Minor closure variable shadowing noted.
crates/openlogi-agent-core/src/capture_plan.rs Threads app through hidpp_gesture_maps_for in plan_for_device — the one-line fix that was missing. All other plan-building paths already passed app, so this brings gesture bindings into line with the rest of the per-app effective dispatch.
crates/openlogi-agent-core/src/orchestrator/tests.rs Extends app_switch_republishes_capture_plans with a gesture-button per-app binding and two new assertions that verify the Click override is absent before app selection and applied after. Adds the published_gesture_click helper to extract the gesture click from the published plan.
crates/openlogi-desktop/src/state/bindings.rs Passes explicit None for app_bundle so the GUI's global editing view remains unaffected by per-app overrides, which matches the documented intent ("global view — no per-app overlay here").

Sequence Diagram

sequenceDiagram
    participant Orch as Orchestrator
    participant CP as plan_for_device
    participant BM as hidpp_gesture_maps_for
    participant Cfg as Config

    Orch->>CP: plan_for_device(config, key, route, app, gen)
    CP->>BM: hidpp_gesture_maps_for(config, Some(key), app)
    BM->>Cfg: bindings_for(key) — global stored shape
    BM->>Cfg: effective_bindings(key, Some(app)) — per-app overlay
    Note over BM: For each HID++ gesture source in gesture mode seed full 5-direction map from global shape then overlay Single binding onto Click arm only
    BM-->>CP: gesture direction map per source button
    CP-->>Orch: DeviceCapturePlan with gesture_bindings
    Note over Orch: Published to SharedCapturePlans watcher dispatches Click with per-app action
Loading

Reviews (5): Last reviewed commit: "fix(agent): apply per-app gesture button..." | Re-trigger Greptile

Comment thread crates/openlogi-agent-core/src/bindings.rs Outdated
@devsaddle
devsaddle force-pushed the codex/fix-per-app-gesture-button branch from 1058b38 to c16ed37 Compare July 20, 2026 10:00
@davidbudnick
davidbudnick force-pushed the codex/fix-per-app-gesture-button branch from c16ed37 to 3fe7181 Compare August 2, 2026 00:51
@davidbudnick davidbudnick added platform: linux Linux-specific issue platform: all Cross-platform issue labels Aug 2, 2026
@devsaddle
devsaddle force-pushed the codex/fix-per-app-gesture-button branch from 3fe7181 to c0c6511 Compare August 16, 2026 16:12
@devsaddle
devsaddle requested a review from AprilNEA as a code owner August 16, 2026 16:12
@devsaddle
devsaddle force-pushed the codex/fix-per-app-gesture-button branch from c0c6511 to 95a509d Compare August 19, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: all Cross-platform issue platform: linux Linux-specific issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants