Repository navigation
fix(agent): make chained gestures responsive and action-paced - #1761
oliver-mee wants to merge 7 commits into
Conversation
[Medium impact] The changes affect held gesture actions across both desktop input routes. The PR needs fixes for both app-switch cancellation gaps and the required user-guide update before merging. Findings
|
1651955 to
b58806f
Compare
|
Rebased onto Validated with Rust 1.99.0: workspace formatting and Clippy, workspace tests (2,230 passed, four ignored), documentation with warnings denied, ast-grep guards, and the portable-crate WASM checks all pass. This is local macOS and WASM validation, not a claim that the upstream Windows/Linux matrix has finished. The updated head is |
bd560c0 to
e4c31c5
Compare
e4c31c5 to
371ed2b
Compare
|
@greptileai please review the latest head, |
e585f08 to
fe8c51e
Compare
AprilNEA
left a comment
There was a problem hiding this comment.
Thanks for the rebase. The security read found no issues, and I approved the CI and Build runs for fe8c51e1. All required checks pass.
Changes requested:
crates/openlogi-agent/src/lifecycle.rs:536andcrates/openlogi-agent-core/src/runtime/button.rs:425:ForegroundChange::ContextOnlynow cancels every non-gesture press on any front-app change. On master (since #1652) these presses survive unless a per-app override is involved. With this head, a heldHoldShortcut(for example push-to-talk) is released when another app takes focus, and a pending long press or wheel hold is dropped. This is outside the gesture scope. Keep ordinary presses alive onContextOnly, or show the failing case and move the change to its own PR. The test name atorchestrator/tests/capture_plans.rs:223no longer matches the behavior either way.crates/openlogi-device/src/session/gesture/accum.rs:287:swipe.accumulate_at(now, 0, 0)is a no-op, becauseaccumulate_atreturns before it touches state on zero motion (swipe.rs:206). Remove the call and its comment.crates/openlogi-core/src/binding/swipe.rs:81-84:GesturePolicykeeps three parallel[_; 4]arrays indexed throughdirection_index() -> Option<usize>. Keep each direction's settings in one struct (for exampleDirectionPacing { enabled: bool, min_interval: Duration }) in a single array.repeat_distancesis alwaysGESTURE_REPEAT_DISTANCEin this PR; add it in #1909, its first user.swipe.rs:377:end_atignores_now.held_sinceno longer gates anything, sobackdate_hold_for_test(swipe.rs:391) and its 9 test calls have no effect. Drop the unused parameter and the test seam, and store the hold as aboolor a state enum instead ofOption<Instant>.accum.rson_event_at: 8 parameters behind#[expect(clippy::too_many_arguments)]. Group the four route slices (gesture_cids,dpi_cids,gesture_button_cids,button_cids) into one struct (.agents/rules/rust.md: "Replace long parameter lists with Change/Params structs").crates/openlogi-core/.ast-grep/rules/core-gesture-timing-owner.yml:15: the patternGesturePolicy { $$$FIELDS }only matches a struct literal, and the private fields already reject that outsideswipe.rsat compile time. Remove the rule.- Hardware: the PR body says this head is not tested on a device. Run the checklist from the PR body on hardware and post the result.
Not for you to change yet: removing GESTURE_HOLD_FOR_SWIPE, the 400 ms / 200 ms same-direction pacing, and unbound swipes consuming the click are default-behavior changes. The gate removal also overlaps #1996 and #2022. These need a maintainer decision; hold further work on the gate part until it is made.
| @@ -110,6 +157,8 @@ pub struct SwipeAccumulator { | |||
| /// zero after each commit, so one hold can chain swipes (left, right, | |||
| /// left...) the way Options+ does. | |||
| last: Option<GestureDirection>, | |||
| /// Recognized stroke waiting for pacing; only fresh continuation may emit it. | |||
| pending: Option<GestureDirection>, | |||
There was a problem hiding this comment.
Gesture phases use dependent fields
SwipeAccumulator adds last_commit and pending beside holding, fired, last, repeat, and moved_at. Together they describe whether a hold is idle, collecting movement, continuing a stroke, or waiting to repeat. The fields permit invalid combinations, such as holding == false with last_commit.is_some(), or both pending and last being set.
This violates the owner's requirement against extending implicit state machines and must be addressed before merging. Replace these phase fields with one GestureState enum whose variants carry only valid data. Keep all writes in one transition implementation, and test each refused transition, including movement after cancellation and a pending stroke becoming a continuation without first committing. No reachable invalid combination was established, so the concern is non-blocking in behavior.
Context Used: Implicit state machines Flag any change that introduces or extends an implicit state machine: a lifecycle, phase, or mode that the code tracks through a combination of independent fields instead of one enum with one transition function. Report it as... (source)
f9a3fd3 to
50dd3ef
Compare
| previous.bindings != next.bindings | ||
| || previous.gestures != next.gestures | ||
| || previous_keys | ||
| != self | ||
| .shared | ||
| .keyboard_bindings | ||
| .read() | ||
| .ok() | ||
| .map(|keys| keys.clone()) |
There was a problem hiding this comment.
Held actions reach another app
Blocking. set_current_app ignores changes to pointer. On macOS, hold Back configured as LongPress(Copy, Paste) over focused window A, then focus B with the keyboard without moving the pointer. If B overrides Back with Undo, the maps still select A's actions, but PointerSelection changes from Shared to Distinct.
This comparison returns false, so apply_foreground skips cancellation. The pending press keeps Shared and can send Paste to B.
Include changes to focus admission when deciding which presses to cancel. Add a regression test that changes focus without moving the pointer during a pending long press.
Knowledge Base Used: Background agent service
| return false; | ||
| } | ||
| let previous = std::mem::replace(&mut self.current_app, id); | ||
| let previous = self.hook_maps_for(self.current_device()); |
There was a problem hiding this comment.
Blocking. set_current_app now compares only current_device() and the global keyboard map. In focused-profile mode, hold Back on a nonselected MX Master 3S over Bluetooth with a pending Paste long action, then enter an app overriding Back with native MouseBack. The selected mouse's maps stay unchanged, so global cancellation is skipped.
Removing the other mouse's diversion retires its capture session. That branch in watchers/gesture.rs cancels only gesture presses. The ordinary long press remains live until restoration finishes and can fire Paste in the new app.
Cancel changed bindings on every live device before retirement, while preserving unrelated holds. Add a secondary-device app-switch test with restoration delayed past the long-press deadline.
Knowledge Base Used:
| Directional gestures share one raw-distance recognizer across HID++ and OS hooks. | ||
| The first deliberate swipe and changes of direction qualify at 50 raw units; | ||
| there is no initial hold timer. Same-direction ordinary repeats require another | ||
| 600 units and at least 400 ms on macOS/Linux or 200 ms on Windows. A 250 ms rest | ||
| rearms the distance threshold without bypassing action pacing. Reversals and | ||
| axis changes bypass the previous direction's repeat cooldown. |
There was a problem hiding this comment.
Main guides omit gesture changes
Blocking. This page describes changed gesture timing and click behavior, but none of docs/CONFIGURATION.md, docs/USAGE.md, or docs/DECISIONS.md changes or points here. The repository's documentation rule requires user-visible behavior changes in at least one of those guides.
Add a short summary and link from the relevant guide so users can find the new behavior.
Rule Used: Severity: medium. A user-visible behaviour change or a known limitation left by a fix (state lost on restart, a race window not covered, Ctrl-C skipping a hand-back) is stated in docs/CONFIGURATION.md, docs/USAGE.md, or docs/DECISIONS.md in the... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Rebased onto current
Two things I am not claiming as done. Item 7, the hardware checklist, has not been run on a device yet, and I have not re-checked the test name at The gate questions stay parked until the #1996 / #2022 decision is made. |
Summary
Make held directional gestures respond to deliberate movement immediately and pace repeated actions without delaying reversals or axis changes. This builds on the chained-swipe recognizer merged in #1652.
Rebase status
98d60ca7b34b7e9b3fe7975ae11dff223b634c8e, which was also upstreammasterat validation (previous base:5f0435b5c73a1e43ef63707af7867bbc074113eb). Validated head:50dd3ef386e8d6207b291d8e5d50273526a1eea7.GESTURE_HOLD_FOR_SWIPE, 400 ms / 200 ms same-direction pacing, and unbound swipes consuming the click. Upstream had not independently changed those behaviors since the previous base; no gate-removal work was added.Changes
openlogi-core: retain signed-distance, backtracking and drift handling; resolve per-direction runtime policy centrally; bound pending movement without changing its slope. Keep each direction's enabled state and minimum interval in oneDirectionPacingarray, useGESTURE_REPEAT_DISTANCEdirectly, and remove the unused hold timestamp and test seam. Remove the initial hold timer and add deterministic-time processing.openlogi-device: carry policy through HID++ capture and reconnects while preserving stale-report suppression and wheel-hold support. Group capture routes inCaptureRoutesand drop stale initial reports without a zero-motion accumulator call.openlogi-agent-coreandopenlogi-agent: retain the physical hold across unchanged contexts, refresh action targets, cancel changed bindings and retiring gesture capture, and release earlier held shortcuts before a different action. Ordinary presses, pending long presses and wheel holds now survive app changes when effective bindings are unchanged, matching the behavior since fix(core,agent): chain swipes within one gesture-button hold #1652.Testing
Validated on Linux aarch64, Rust 1.99.1, with
RUSTFLAGS=-D warnings. Tests, rustdoc and the final WASM checks also usedCARGO_INCREMENTAL=0:cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace(4,696 passed, 5 ignored, 0 failed across 44 result groups; isolated test home)RUSTDOCFLAGS=-D warnings cargo doc --workspace --no-deps --document-private-items --exclude openlogi-ui --exclude openlogi-desktop --exclude openlogi-overlay --exclude openlogi-agentast-grep scanandast-grep scan .githubcargo check -p openlogi-device-registry -p openlogi-hidpp -p openlogi-device --target wasm32-unknown-unknowncargo check -p openlogi-core --no-default-features --target wasm32-unknown-unknownFocused checks also passed: 36 swipe tests, 26 device accumulator tests, and the app-switch lifecycle regression test.
Native macOS and Windows checks were not run locally. This head is not runtime-tested on hardware. The remaining hardware checklist is:
Continuous volume response is the separate follow-up.
Related: #1634, #969, #365, #1048 and #1698.