Skip to content

feat(demo): improve cursor movement and typing realism#4783

Merged
gregpriday merged 3 commits intodevelopfrom
feature/issue-4776-improve-demo-cursor-movement
Apr 2, 2026
Merged

feat(demo): improve cursor movement and typing realism#4783
gregpriday merged 3 commits intodevelopfrom
feature/issue-4776-improve-demo-cursor-movement

Conversation

@gregpriday
Copy link
Copy Markdown
Collaborator

Summary

  • Replaces fixed-duration cursor movement with Fitts's Law scaling so short moves to large targets are fast and long moves to small targets decelerate naturally
  • Adds Perlin-noise micro-jitter (~2px amplitude) over interpolated x/y coordinates for organic hand tremor without altering the overall path
  • Splits long movements (>500px) into a ballistic phase and an acquisition phase, with an explicit overshoot and correction curve on moves over 500px
  • Adapts step count to distance and duration rather than always using 30 keyframes
  • Replaces uniform 1000 / cps keystroke delay with Gaussian-distributed base delays, longer pauses after spaces and punctuation, burst-mode multiplier for mid-word characters, and occasional hesitation pauses
  • Adds a brief cursor-settling drift after clicks to simulate the hand relaxing post-click

Resolves #4776

Changes

  • src/components/Demo/DemoCursor.tsx — all movement, typing, and click-feedback logic
  • src/components/Demo/__tests__/DemoCursor.test.tsx — test coverage for the new behaviours
  • Minor type and preload adjustments in electron/preload.cts, shared/types/ipc/api.ts, and shared/types/ipc/demo.ts

Testing

Unit tests updated and passing. The Fitts's Law scaling, noise generation, two-phase movement, variable keystroke timing, and click-settling are all covered in the test suite.

- Add Fitts's Law auto-duration computation when durationMs is omitted
- Add 1D value noise for perpendicular micro-jitter on cursor paths
- Scale keyframe count dynamically with distance (10-60 steps)
- Split long moves (>300px) into ballistic + acquisition phases
- Add post-click settling drift (1-2px, 150ms ease-out)
- Replace uniform typing delay with Gaussian-distributed context-aware delays
- Make durationMs optional on DemoMoveToPayload and DemoMoveToSelectorPayload
- Pass target element width to Fitts's Law for moveToSelector
- Add 7 new tests covering Fitts's Law, two-phase movement, settling, typing variance
- Make durationMs optional in shared/types/ipc/api.ts ElectronAPI type
- Add mid-word burst typing multiplier (0.7x for consecutive letters)
- Guard against cps=0 causing Infinity delay
- Fix animateSpy mock type to avoid TS2493 tuple index errors
- Format DemoCursor.tsx with prettier
@gregpriday gregpriday force-pushed the feature/issue-4776-improve-demo-cursor-movement branch from 01aa7db to 86242f3 Compare April 2, 2026 04:28
@gregpriday gregpriday merged commit 68997fa into develop Apr 2, 2026
3 checks passed
@gregpriday gregpriday deleted the feature/issue-4776-improve-demo-cursor-movement branch April 2, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve demo cursor movement and typing realism

1 participant