Replace uniform mouse jitter with Gaussian-distributed delays#228
Replace uniform mouse jitter with Gaussian-distributed delays#228ulziibay-kernel merged 1 commit intomainfrom
Conversation
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: PR modifies mouse jitter/delay logic in what appears to be a client or testing utility, not kernel API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal) as specified in the filter. To monitor this PR anyway, reply with |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3f19e61. Configure here.
3f19e61 to
513303d
Compare
The per-step delay jitter for smooth mouse movements and drags used a uniform ±2ms offset (rand.Intn(5) - 2), producing near-constant inter-event timing. Real human mouse movement has substantially more timing variance due to motor noise, acceleration phases, and micro-hesitations. Replace with a Gaussian distribution (Box-Muller, stddev = 40% of mean delay, clamped to [3ms, 3x mean]). This preserves the average movement duration while producing natural timing variance in each step. Affects both doMoveMouseSmooth and doDragMouseSmooth code paths. Made-with: Cursor
513303d to
7e5c658
Compare

Summary
rand.Intn(5) - 2(uniform ±2ms) mouse movement jitter with Gaussian-distributed delaysdoMoveMouseSmoothanddoDragMouseSmoothcode pathsProblem
The uniform ±2ms jitter on smooth mouse movement delays produces near-constant inter-event timing (~40ms ± 2ms). Real human mouse movement has substantially more timing variance — humans accelerate, decelerate, and have natural motor noise that creates variable intervals between input events.
Measured inter-event intervals from current implementation:
This is unnaturally uniform. Real human mouse input shows much wider spread.
Fix
New
gaussianDelay(meanMs, minMs)function using Box-Muller transform:This produces inter-event timing that follows a bell curve instead of a flat line, matching real human motor noise characteristics.
Test plan
TestGaussianDelay— validates mean (within 15%), variance (>5), floor (≥3ms), ceiling (≤3x mean)TestGaussianDelay_VarianceMuchHigherThanUniform— confirms >3x the old uniform varianceMade with Cursor
Note
Medium Risk
Changes core input timing behavior for
MoveMouse/DragMouse, which could alter perceived speed/smoothness or impact consumers that assume consistent step delays. Logic is bounded/clamped and covered by new statistical unit tests, limiting risk.Overview
Smooth mouse movement timing is now more human-like. The uniform ±2ms per-step jitter used during smooth
MoveMouseand smoothDragMousehas been replaced withgaussianDelay()(Box–Muller), clamped to a floor and 3× mean, to introduce realistic inter-event variance.Default step delay was increased from 10ms to 20ms for both API-side point calculation and
mousetrajectory.GenerateMultiSegmentTrajectory, affecting how many trajectory points are generated whenduration_msis provided.Adds unit tests validating
gaussianDelay()mean/variance bounds and demonstrating higher variance vs the previous uniform jitter (including a Welford velocity-variance simulation).Reviewed by Cursor Bugbot for commit 7e5c658. Bugbot is set up for automated code reviews on this repo. Configure here.