-
Notifications
You must be signed in to change notification settings - Fork 23
fix: removed client-side sensitivity double-application #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: removed client-side sensitivity double-application #54
Conversation
📝 WalkthroughWalkthroughRemoved client-side sensitivity from the trackpad gesture hook so the client sends raw deltas; server InputHandler now reads CONFIG.MOUSE_SENSITIVITY per event, applies invert/sensitivity scaling, rounds results, and guards zero amounts before performing scroll/zoom actions. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Server as Server
participant Config as Config
Client->>Client: capture gesture (sumX, sumY, delta)
Client->>Server: send raw gesture message (sumX, sumY, delta)
Server->>Config: read CONFIG.MOUSE_SENSITIVITY
Config-->>Server: sensitivity
Server->>Server: apply invertMultiplier * sensitivity, round deltas
Server->>Server: if amount != 0 then perform scroll/zoom/move
Server-->>Client: (optional) ack / UI update
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Tip We've launched Issue Planner and it is currently in beta. Please try it out and share your feedback on Discord! Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/server/InputHandler.ts`:
- Around line 47-52: The switch cases for 'scroll' (where invertMultiplier and
scrollSensitivity are declared and mouse.scrollDown/mouse.scrollRight are
called) and the 'zoom' case must be wrapped in their own block braces to prevent
const-scope leakage across cases; edit the case 'scroll' and case 'zoom' bodies
to enclose their existing statements in { ... } so invertMultiplier,
scrollSensitivity and any local vars in the 'zoom' case are block-scoped to that
case.
- Around line 50-51: The scroll amounts passed to mouse.scrollDown and
mouse.scrollRight (in InputHandler.ts) can be non-integers because
scrollSensitivity may be a float, causing native truncation; wrap the computed
values (msg.dy * invertMultiplier * scrollSensitivity and msg.dx * -1 *
invertMultiplier * scrollSensitivity) with Math.round() before awaiting
mouse.scrollDown and mouse.scrollRight so the nut-js functions receive integer
ticks (use msg.dy/msg.dx checks as-is).
🧹 Nitpick comments (1)
src/server/InputHandler.ts (1)
27-27:CONFIG.MOUSE_SENSITIVITY ?? 1.0is repeated three times; the fallback is already inconfig.tsx.
CONFIG.MOUSE_SENSITIVITYalready defaults to1.0via the nullish coalescing insrc/config.tsx(line 20). The?? 1.0here is redundant. Consider reading it once at the top ofhandleMessage(or as a class field) to keep it DRY:async handleMessage(msg: InputMessage) { + const sensitivity = CONFIG.MOUSE_SENSITIVITY; switch (msg.type) {Then reuse
sensitivityin themove,scroll, andzoombranches.Also applies to: 49-49, 57-57
|
Hey @imxade |
765cbd8 to
c0b424b
Compare
Fixes: #52
This PR fixes a bug where mouse sensitivity was being applied twice for cursor movement (client hardcoded + server config), while being ignored completely for scroll and zoom events.
Changes:
Removed the sensitivity parameter and its hardcoded 1.5 default. The client now sends raw touch deltas.
Updated
InputHandler.tsto apply CONFIG.MOUSE_SENSITIVITY to Scroll and Zoom events. Previously, it only applied sensitivity to mouse movement.How Has This Been Tested?
Manual Verification: Verified that removing the client-side multiplier correctly delegates sensitivity logic to the server.
Build Check: Ran npm run build to ensure no type errors or build regressions.
Checklist
My code follows the style guidelines of this project
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
My changes generate no new warnings.
Summary by CodeRabbit
Refactor
Bug Fix
Improvement