Sec/inputhandle#261
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughEnhanced error handling in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/server/InputHandler.ts (2)
234-258:⚠️ Potential issue | 🟠 MajorZoom handler missing outer try/catch -
LeftControlcan get stuck.The
keyboard.pressKey(Key.LeftControl)on line 246 is outside the try block. If this call throws, thefinallyblock won't execute andLeftControlwill remain pressed. This contradicts the PR objective of ensuring guaranteed key release.🐛 Proposed fix to wrap the entire zoom operation
case "zoom": if (this.isFiniteNumber(msg.delta) && msg.delta !== 0) { const sensitivityFactor = 0.5 const MAX_ZOOM_STEP = 5 const scaledDelta = Math.sign(msg.delta) * Math.min(Math.abs(msg.delta) * sensitivityFactor, MAX_ZOOM_STEP) const amount = Math.round(-scaledDelta) if (amount !== 0) { - await keyboard.pressKey(Key.LeftControl) try { + await keyboard.pressKey(Key.LeftControl) if (amount > 0) { await mouse.scrollDown(amount) } else { await mouse.scrollUp(-amount) } + } catch (err) { + console.error("Zoom event failed:", err) } finally { - await keyboard.releaseKey(Key.LeftControl) + await keyboard.releaseKey(Key.LeftControl).catch(() => {}) } } } break🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/server/InputHandler.ts` around lines 234 - 258, In the "zoom" case of InputHandler.ts the keyboard.pressKey(Key.LeftControl) is called before the try/finally, so if pressKey throws LeftControl can stay stuck; move the pressKey call inside a try block (so the try begins before or immediately after calling keyboard.pressKey) and ensure keyboard.releaseKey(Key.LeftControl) remains in the finally to always run; in other words, wrap the entire zoom operation (including keyboard.pressKey, the mouse.scrollDown/scrollUp calls, and any conditional logic that computes amount) in a try/finally that calls keyboard.releaseKey(Key.LeftControl) in finally, keeping the existing amount checks and mouse.scrollDown/scrollUp behavior.
6-25:⚠️ Potential issue | 🟡 MinorAddress formatting check failure before merge.
The CI pipeline reports a formatting mismatch. Run the formatter to fix code style issues:
npx biome format --write src/server/InputHandler.ts🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/server/InputHandler.ts` around lines 6 - 25, The CI failed due to formatting mismatches in the InputMessage interface; run the formatter to fix style (e.g. run `npx biome format --write src/server/InputHandler.ts`), then stage and commit the updated file so the InputMessage interface definition and surrounding whitespace/indentation match project formatting rules before re-pushing the branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/server/InputHandler.ts`:
- Around line 234-258: In the "zoom" case of InputHandler.ts the
keyboard.pressKey(Key.LeftControl) is called before the try/finally, so if
pressKey throws LeftControl can stay stuck; move the pressKey call inside a try
block (so the try begins before or immediately after calling keyboard.pressKey)
and ensure keyboard.releaseKey(Key.LeftControl) remains in the finally to always
run; in other words, wrap the entire zoom operation (including
keyboard.pressKey, the mouse.scrollDown/scrollUp calls, and any conditional
logic that computes amount) in a try/finally that calls
keyboard.releaseKey(Key.LeftControl) in finally, keeping the existing amount
checks and mouse.scrollDown/scrollUp behavior.
- Around line 6-25: The CI failed due to formatting mismatches in the
InputMessage interface; run the formatter to fix style (e.g. run `npx biome
format --write src/server/InputHandler.ts`), then stage and commit the updated
file so the InputMessage interface definition and surrounding
whitespace/indentation match project formatting rules before re-pushing the
branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: f59b7801-64b4-4750-98b8-b52c3fd6cec1
📒 Files selected for processing (1)
src/server/InputHandler.ts
Fixes #202
Summary by CodeRabbit