fix(key_codes): add Function key arm so macOS fn can be bound to a chord#950
Open
sridhar-3009 wants to merge 1 commit into
Open
fix(key_codes): add Function key arm so macOS fn can be bound to a chord#950sridhar-3009 wants to merge 1 commit into
sridhar-3009 wants to merge 1 commit into
Conversation
key_from_str() had no arm for "Function", so it fell through to None. Since build_chord propagates that as a hard Err via ?, binding any chord containing fn made build_chord_bindings fail entirely — HotkeyMonitor was never spawned, silently killing both push-to-talk and toggle-to-talk until the chord was reverted. Every other layer (keytap's macOS key tap, Key::Function itself, the frontend's canonicalKeyFromEvent/displayLabelForKey) already handles fn — only this string-to-Key bridge was missing the arm. Fixes jamiepine#941
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChangesFunction key support
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #941.
Problem
key_from_str()intauri/src-tauri/src/key_codes.rshad no arm for"Function", so it fell through toNone.build_chordpropagates thatNoneas a hardErrvia?, so any chord containingfnmadebuild_chord_bindingsfail entirely —HotkeyMonitorwas never spawned, silently disabling both push-to-talk and toggle-to-talk until the chord was changed back to a mapped key. No error is logged either, since the failure happens before the "ChordMatcher build failed" log line would run.Every other layer already supports it:
keytap::Key::Functionexists (confirmed injamiepine/keytap'ssrc/key.rs)kVK_Function→Key::Function)canonicalKeyFromEvent/displayLabelForKeyalready allowlist/label'Function'→'fn'Only this string→
Keybridge was missing the arm.Fix
One arm, exactly as suggested in the issue:
Testing
There's no existing test suite for
key_codes.rs(no#[test]module in the file), so I didn't add test scaffolding beyond the scope of this one-line fix. I don't have a Mac to verify the chord end-to-end, but the fix is a direct, mechanical addition matching the pattern of every other key arm in the same match block.Summary by CodeRabbit