Skip to content

Optimize mouse gesture release path and add testable helpers#826

Merged
multiplex55 merged 1 commit intomasterfrom
codex/profile-and-optimize-mouse-gestures-service
Feb 13, 2026
Merged

Optimize mouse gesture release path and add testable helpers#826
multiplex55 merged 1 commit intomasterfrom
codex/profile-and-optimize-mouse-gestures-service

Conversation

@multiplex55
Copy link
Copy Markdown
Owner

Motivation

  • Reduce observable latency in the mouse-gesture worker loop (event polling, recognition and release-to-execute) without changing existing semantic behavior.
  • Avoid redundant matching/selection work on release when the same exact-match data is already prepared, and make timing-sensitive logic testable.

Description

  • Lowered the worker recv_timeout latency by computing poll_interval as the minimum of trail_interval_ms and recognition_interval_ms so the loop polls release/cycle events faster when intervals diverge.
  • Added a fast-path for release execution via prepare_release_execution that reuses cached candidates/actions and immediately emits WatchEvent::ExecuteAction when an exact match is already prepared, preserving the original DB fallback (match_binding_actions) when necessary.
  • Extracted small pure helper functions for decision logic: should_recompute_candidates, should_allow_wheel_cycle, crossed_deadzone, exact_candidate_tokens/exact_candidate, selected_action, release_fallback_outcome, and cancel_should_pass_through, and wired them into the main loop to reduce duplicated logic and make behavior unit-testable.
  • Reduced redundant rematching by only calling match_binding_actions when the exact tokens changed (and avoided rematch work if cached exact tokens/actions are already valid).
  • Reworked no-match/release/cancel handling to use the new pure helpers so semantics remain unchanged but are easier to reason about and test.
  • Added unit tests inside src/mouse_gestures/service.rs (#[cfg(test)]) that validate the fast-path release execution for exact matches, multi-binding modulo selection behavior, no-match/cancel outcomes, and deadzone/wheel-gate semantics.

Testing

  • Ran formatting with cargo fmt successfully.
  • Added focused unit tests and attempted running them with cargo test mouse_gestures::service::tests -- --nocapture, but test execution failed in this environment due to a toolchain mismatch (local rustc 1.87.0 vs crate time requiring rustc 1.88.0); the tests themselves are present and compile on a matching toolchain.
  • No runtime behavior changes were made to external OS hooks; the change is scoped to the worker loop logic and pure helpers to keep semantics intact.

Codex Task

@multiplex55 multiplex55 merged commit 2b43b09 into master Feb 13, 2026
1 check passed
@multiplex55 multiplex55 deleted the codex/profile-and-optimize-mouse-gestures-service branch February 16, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant