fix(commands): ignore allowed shortcut conflicts#2272
Conversation
Greptile SummaryThis PR fixes double-processing of
Confidence Score: 4/5The change is minimal and targeted — one filter line that prevents double-dispatch for The fix is correct and well-scoped. The only leftover is the now-unreachable The
|
| Filename | Overview |
|---|---|
| src/renderer/lib/commands/command-shortcut-binder.tsx | Filters out conflictBehavior === 'allow' shortcuts from the keys list in CommandShortcutBinder, preventing double-dispatch for shortcuts like cmd+w. Leaves isAllow dead-code in SingleKeyBinder. |
Sequence Diagram
sequenceDiagram
participant User
participant AppKeyboardShortcuts
participant CommandShortcutBinder
participant SingleKeyBinder
participant commandRegistry
Note over CommandShortcutBinder: PR fix: 'allow' shortcuts filtered out
User->>AppKeyboardShortcuts: press cmd+w
AppKeyboardShortcuts->>commandRegistry: dispatch(shortcutKey)
Note over CommandShortcutBinder: Before fix: SingleKeyBinder was ALSO mounted for 'allow' shortcuts
Note over CommandShortcutBinder: After fix: 'allow' shortcuts have no SingleKeyBinder
User->>AppKeyboardShortcuts: press non-allow shortcut (e.g. cmd+k)
AppKeyboardShortcuts->>SingleKeyBinder: hotkey fires
SingleKeyBinder->>commandRegistry: dispatch(shortcutKey)
Comments Outside Diff (1)
-
src/renderer/lib/commands/command-shortcut-binder.tsx, line 20-32 (link)Dead code in
SingleKeyBinder— sinceCommandShortcutBindernow filters out everyconflictBehavior === 'allow'key before mountingSingleKeyBinder,isAllowwill always befalseat runtime. Thee.preventDefault()branch and the conditional spread of{ conflictBehavior: 'allow' }are unreachable. Consider removing this logic to keep the component in sync with the new invariant.Prompt To Fix With AI
This is a comment left during a code review. Path: src/renderer/lib/commands/command-shortcut-binder.tsx Line: 20-32 Comment: Dead code in `SingleKeyBinder` — since `CommandShortcutBinder` now filters out every `conflictBehavior === 'allow'` key before mounting `SingleKeyBinder`, `isAllow` will always be `false` at runtime. The `e.preventDefault()` branch and the conditional spread of `{ conflictBehavior: 'allow' }` are unreachable. Consider removing this logic to keep the component in sync with the new invariant. How can I resolve this? If you propose a fix, please make it concise.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/renderer/lib/commands/command-shortcut-binder.tsx:20-32
Dead code in `SingleKeyBinder` — since `CommandShortcutBinder` now filters out every `conflictBehavior === 'allow'` key before mounting `SingleKeyBinder`, `isAllow` will always be `false` at runtime. The `e.preventDefault()` branch and the conditional spread of `{ conflictBehavior: 'allow' }` are unreachable. Consider removing this logic to keep the component in sync with the new invariant.
```suggestion
useHotkey(
getHotkeyRegistration(shortcutKey, keyboard),
() => {
commandRegistry.dispatch(shortcutKey);
},
{
enabled: getEffectiveHotkey(shortcutKey, keyboard) !== null,
}
);
```
Reviews (1): Last reviewed commit: "fix(commands): ignore allowed shortcut c..." | Re-trigger Greptile
arnestrickmann
left a comment
There was a problem hiding this comment.
thanks for catching this and for the fix
summary
demo of it working now:
https://streamable.com/fdx3s7