Skip to content

fix(core): recognize fast swipe gestures on release - #2548

Open
zerodegs wants to merge 1 commit into
AprilNEA:masterfrom
zerodegs:fix/fast-gesture-release
Open

zerodegs wants to merge 1 commit into
AprilNEA:masterfrom
zerodegs:fix/fast-gesture-release

Conversation

@zerodegs

Copy link
Copy Markdown

Summary

A gesture button released before GESTURE_HOLD_FOR_SWIPE (160 ms) was classified as a plain click, so a quick thumb flick either fired the button's Click action or did nothing. The release now classifies the travel it accumulated, so a fast swipe still moves.

Changes

  • openlogi-core: SwipeAccumulator::end returns the direction still due (Option<GestureDirection>) instead of a "was a click" flag, classifying the hold's final travel. A hold that already committed mid-motion emits nothing, so a fast swipe cannot also click or fire twice.
  • openlogi-agent-core: the OS-hook path resolves the action from the release direction (resolve_gesture_action, formerly resolve_gesture_click), keeping the Click/default fallback for sparse maps and honoring an explicit Action::None.
  • openlogi-device: the HID++ capture path forwards the release direction rather than a Click (gesture released instead of gesture click).

Testing

  • cargo test -p openlogi-core -p openlogi-agent-core -p openlogi-device
  • New tests: a fast release resolves a swipe in each of the four directions, small or ambiguous motion still resolves to Click, and a release never dispatches twice.
  • Runtime-tested on an MX Master 3S (macOS 26.6.2, Bolt receiver): quick thumb-button flicks change desktop on release instead of being swallowed as clicks.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The change affects gesture-button actions across the OS-hook and HID++ capture paths.

The gesture change needs the required user documentation and regression counter-proof before merging.

Findings

  1. P1 Fast-release guidance is missing ▶
  2. P1 Regression counter-proof is missing ▶
  3. P2 Swipe phases remain implicit ▶

Summary

Fast swipes now resolve from accumulated travel on release in both capture paths.

  • Gesture buttons keep fast swipes pointed in the direction they moved.

zerodeg00 explicitly describes moving quick clicks becoming swipes as the purpose of the PR; this behavior is not reported as a correctness defect.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Button released] --> B{Hold exists?}
    B -->|No| C[Emit nothing]
    B -->|Yes| D{Swipe already fired?}
    D -->|Yes| C
    D -->|No| E[Classify final travel]
    E -->|Clear direction| F[Emit swipe]
    E -->|Small or ambiguous| G[Emit Click]
    F --> H[End button press]
    G --> H
Loading

Reviews (1) · Last reviewed commit: "fix(core): recognize fast swipe gestures..." · Reviewed by Greptile

Comment on lines +250 to +255
pub fn end(&mut self) -> Option<GestureDirection> {
self.held_since.take()?;
if self.fired {
return None;
}
Some(detect_swipe(self.dx, self.dy).unwrap_or(GestureDirection::Click))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Swipe phases remain implicit

SwipeAccumulator::end extends release behavior while held_since, fired, last, repeat, and repeat_cross still encode the phase separately. For example, last = Some(direction) with fired = false is invalid, but the type permits it. This violates the repository requirement to make extended state machines explicit.

Replace these phase fields with an enum such as Idle, Uncommitted, and Committed, carrying only valid data. Keep transitions under one owner and test refused edges, including motion while idle and repeated release. No newly reachable invalid combination was established, so this is a maintenance concern rather than a demonstrated gesture failure. The explicit repository requirement must still be satisfied before merging.

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)

if self.fired {
return None;
}
Some(detect_swipe(self.dx, self.dy).unwrap_or(GestureDirection::Click))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Fast-release guidance is missing

SwipeAccumulator::end now turns a quick press with enough travel into a swipe rather than a click, but this PR changes only Rust files. The repository requires user-visible behavior changes to be documented in docs/CONFIGURATION.md, docs/USAGE.md, or docs/DECISIONS.md in the same change.

Before merging, explain that the 160 ms gate applies to firing during motion, not to recognizing a swipe on release. The fast-release tests cover the code boundary; the missing piece is the required user documentation.

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!

Comment on lines +335 to +336
assert_eq!(triggered.token(), press.token());
assert_eq!(action, Action::PreviousDesktop);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Regression counter-proof is missing

The repository requires the PR to name the reverted line or killed mutant that makes its regression test fail. The testing notes list tests and a hardware check, but give no counter-proof.

For fast_hook_gesture_dispatches_the_swipe_before_ending_its_press, temporarily restore click-only release classification while keeping the new return type. Confirm that the Action::PreviousDesktop assertion fails and record the result before merging. The test reaches the production hook path; this concerns the required proof, not a claim that the test is ineffective.

Rule Used: Severity: medium. Every bug fix ships a regression test that fails without the fix, and the PR states the counter-proof (the reverted line or the killed mutant). A test that passes with the fix reverted is not a regression test: ask for inputs where ... (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!

@davidbudnick davidbudnick added platform: all Cross-platform issue type: bug Something is broken or behaves incorrectly labels Nov 15, 2026

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

platform: all Cross-platform issue type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants