Repository navigation
feat(web): add development collision detection for hotkeys - #334
Conversation
|
@SinghAstra is attempting to deploy a commit to the MagicAPI Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 11 minutes Limit details: You’ve used all 1 included review currently available under your plan. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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 |
ccda13a to
a22b17d
Compare
Resolves Noveum#332. Adds a strict collision check to HotkeyRegistry.register that warns in non-production environments when two advertised hotkeys tie on all tiebreakers (steps, shift specificity, and priority). Includes unit tests to verify identical priorities warn while differing priorities safely resolve.
a22b17d to
ac0b21f
Compare
imshashank
left a comment
There was a problem hiding this comment.
This is the right shape and it would have caught #331: two advertised entries, same key, same priority, warned about instead of silently resolved. Test file is in the correct mirrored path, the process.env.NODE_ENV guard keeps it out of production bundles, and skipping the self-comparison by id means a re-register does not warn at itself. 47 tests in apps/web/tests/lib/keyboard/ pass locally.
I want to flag the part I got wrong while reviewing, because it is the most interesting thing in the PR.
I had written you a comment arguing that stepsCollide was buggy: that ignoring shift per step and comparing the totals at the end was too loose, that shift+a b and a shift+b can never both match one keystroke sequence, and that your third test was therefore asserting a false positive. I was about to send it. Then I checked stepMatches before posting:
return step.shift ? actual.shift : true;A step without shift matches a shifted press. So pressing Shift+A then Shift+B matches both bindings. I proved it rather than reasoning about it a second time:
shift+a b matches Shift+A,Shift+B : true
a shift+b matches Shift+A,Shift+B : true
Both match, both have two steps, both have shift specificity 1, so beats() ties and selectMatch silently picks whichever registered first. That is exactly the class of bug this PR exists to catch, and comparing shift totals rather than per step flags is what catches it. Your version is correct and my correction would have introduced a false negative that quietly stopped detecting real collisions.
Worth a line in the PR description or the issue, because the next person to read stepsCollide will have the same objection I did, and the reason it is written that way is not obvious from the function alone.
Two small things, neither blocking:
- The test imports
'../../../src/lib/keyboard/registry.ts'. Everything else underapps/webuses the@/alias andAGENTS.mdasks for it.@/lib/keyboard/registry.tsalso survives the file moving. - The rest of the suite uses
describewithit, this file uses baretest.
Happy to take those in a follow up rather than another round here. Approving.
What this changes
Adds a development-mode warning check inside
HotkeyRegistry.register()to detect and flag silent hotkey tie collisions, along with a dedicated unit test suite.Why
When two advertised shortcuts tie on all three tiebreakers (steps, shift specificity, and priority), the registry silently resolves them based on registration order. This caused issues like #331 where the theme toggle shadowed the due-date menu shortcut. This check ensures developers are loudly warned in non-production environments if a tie occurs.
Closes #332
How you know it works
Added a new unit test file at
apps/web/tests/lib/keyboard/registry.test.ts.Ran
bun test apps/web/tests/lib/keyboard/registry.test.tsto verify that:console.warn.Screenshots
Not applicable.
Checklist
bun run verifyis green, all four checksany, no non-null assertions@orbit/sharedpackages/shared/src/policy, not only in the UIbun run db:releaseandbun run db:check-driftpassed against the target database before this shipsAnything reviewers should know
Implemented option 2 from the issue description: a non-production
console.warninsideHotkeyRegistry.register()when advertised hotkeys tie on all tiebreakers, allowing existing integration/E2E test runs to surface collisions.Greptile Summary
The PR adds development-only warnings when advertised hotkeys tie on binding structure, Shift specificity, and priority, plus focused registry tests.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (3): Last reviewed commit: "feat(web): add development collision det..." | Re-trigger Greptile