[Fix] input handling, scrolling, and gesture state#366
Conversation
WalkthroughAdds touch-cancel gesture cleanup, pending input configuration application, positional keyboard injection, media-key mappings, consistent scroll inversion, macOS media events, and GStreamer development-shell configuration. ChangesInput handling
Development shell multimedia setup
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant InputHandler
participant PlatformInjector
participant KeyboardBackend
InputHandler->>PlatformInjector: Hold control key
PlatformInjector->>KeyboardBackend: injectKey("control", "HOLD")
InputHandler->>PlatformInjector: Inject zoom wheel
InputHandler->>PlatformInjector: Release control key
PlatformInjector->>KeyboardBackend: injectKey("control", "RELEASE")
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/Trackpad/TouchArea.tsx`:
- Line 10: Add the Next.js "use client" directive at the top of the TouchArea
component file so its touch and mouse event handlers run as a client component.
In `@src/server/InputHandler.ts`:
- Around line 202-205: Update the control-key and mouse-wheel injection flow
around this.injector.injectMouseWheel so the wheel call executes inside a
try...finally block, with this.injector.injectKey("control", "RELEASE") in the
finally clause to guarantee release when injection fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0be28747-297e-499c-a0b9-ba34e1af81da
📒 Files selected for processing (14)
shell.nixsrc/components/Trackpad/TouchArea.tsxsrc/hooks/useTrackpadGesture.tssrc/server/InputHandler.tssrc/server/api/apiHandlers.tssrc/server/drivers/keyMap.tssrc/server/drivers/linux/index.tssrc/server/drivers/linux/keyboard.tssrc/server/drivers/mac/index.tssrc/server/drivers/mac/keyboard.tssrc/server/drivers/mac/structs.tssrc/server/drivers/windows/index.tssrc/server/drivers/windows/keyboard.tssrc/server/types.ts
| onTouchStart: (e: React.TouchEvent) => void | ||
| onTouchMove: (e: React.TouchEvent) => void | ||
| onTouchEnd: (e: React.TouchEvent) => void | ||
| onTouchCancel: (e: React.TouchEvent) => void |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify if "use client" is present at the top of the file.
head -n 5 src/components/Trackpad/TouchArea.tsx | grep -q 'use client' || echo "Missing 'use client' directive in src/components/Trackpad/TouchArea.tsx."Repository: AOSSIE-Org/Rein
Length of output: 226
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,40p' src/components/Trackpad/TouchArea.tsxRepository: AOSSIE-Org/Rein
Length of output: 1265
Add "use client" to src/components/Trackpad/TouchArea.tsx. This component uses touch and mouse event handlers, so it must be a client component in Next.js.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/Trackpad/TouchArea.tsx` at line 10, Add the Next.js "use
client" directive at the top of the TouchArea component file so its touch and
mouse event handlers run as a client component.
Source: Path instructions
| this.injector.injectKey("control", "HOLD") | ||
| this.injector.injectMouseWheel(0, amount) | ||
| this.injector.injectKey("control") | ||
| this.injector.injectKey("control", "RELEASE") | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Ensure the modifier key is released if an error occurs.
If this.injector.injectMouseWheel throws an error, the execution will abort, leaving the "control" key logically stuck in the down position. Wrap the wheel injection in a try...finally block to guarantee the release event is dispatched.
🔒️ Proposed fix to prevent stuck keys
- this.injector.injectKey("control", "HOLD")
- this.injector.injectMouseWheel(0, amount)
- this.injector.injectKey("control", "RELEASE")
+ this.injector.injectKey("control", "HOLD")
+ try {
+ this.injector.injectMouseWheel(0, amount)
+ } finally {
+ this.injector.injectKey("control", "RELEASE")
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| this.injector.injectKey("control", "HOLD") | |
| this.injector.injectMouseWheel(0, amount) | |
| this.injector.injectKey("control") | |
| this.injector.injectKey("control", "RELEASE") | |
| } | |
| this.injector.injectKey("control", "HOLD") | |
| try { | |
| this.injector.injectMouseWheel(0, amount) | |
| } finally { | |
| this.injector.injectKey("control", "RELEASE") | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/server/InputHandler.ts` around lines 202 - 205, Update the control-key
and mouse-wheel injection flow around this.injector.injectMouseWheel so the
wheel call executes inside a try...finally block, with
this.injector.injectKey("control", "RELEASE") in the finally clause to guarantee
release when injection fails.
Addressed Issues:
N/A
Description
This PR improves the input system by fixing several gesture and keyboard-related issues across all supported platforms.
Changes
onTouchCancelhandling to prevent gestures from getting stuck when touch events are interrupted.Screenshots/Recordings:
N/A
Functional Verification
Screen Mirror
Authentication
Basic Gestures
One-finger tap: Verified as Left Click.
Two-finger tap: Verified as Right Click.
Click and drag: Verified selection behavior.
Pinch to zoom: Verified zoom functionality.
Modes & Settings
Cursor mode: Cursor moves smoothly and accurately.
Scroll mode: Page scrolls as expected.
Sensitivity: Verified changes in cursor speed/sensitivity settings.
Copy and Paste: Verified both Copy and Paste functionality.
Invert Scrolling: Verified scroll direction toggles correctly.
Advanced Input
Key combinations: Verified HOLD/RELEASE behavior for modifiers (e.g. Ctrl+C, Ctrl+Scroll Zoom).
Keyboard input: Verified Space, Backspace, and Enter keys work correctly.
Glide typing: Verified path drawing and text output.
Voice input: Verified speech-to-text functionality.
Backspace doesn't send the previous input.
Any other gesture or input behavior introduced:
Additional Notes:
This PR mainly focuses on improving input reliability and platform consistency by fixing gesture cleanup, modifier key handling, scrolling behavior, and media key support across Linux, macOS, and Windows.
Checklist
My PR addresses a single issue, fixes a single bug or makes a single improvement.
My code follows the project's code style and conventions.
I have performed a self-review of my own code.
I have commented my code, particularly in hard-to-understand areas.
If applicable, I have made corresponding changes or additions to the documentation.
If applicable, I have made corresponding changes or additions to tests.
My changes generate no new warnings or errors.
I have joined the Discord server and I will share a link to this PR with the project maintainers there.
I have read the contribution guidelines.
Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
In case of UI change I've added a demo video.
Summary by CodeRabbit