Repository navigation
Generator: Kanata decides what is a key, so key names are never typed as letters - #1329
Conversation
… as letters
The generator decided "key or word to type" from a hand-kept list that
missed real Kanata keys, so `.keystroke("f21")` became `(macro f 2 1)` and a
rule silently typed three characters instead of being refused. It now asks
the bridge (BackendCapabilityProfile.knowsKey): a name Kanata knows is
emitted as that key and goes through admission like any output, refused
with "sends f21, which the current backend can't send" when the session
cannot post it; only a word Kanata does not know ("hello") is typed. The
list remains the fallback when no bridge is available.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Review of #1329 One behavior risk and two minor points.
The new tests all call 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 548b6accc9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let known = BackendCapabilityProfile.shared.knowsKey(token) { | ||
| return !known |
There was a problem hiding this comment.
Canonicalize KeyPath aliases before querying Kanata
When the live bridge is available, KeyPath aliases that Kanata does not recognize verbatim—such as escape, space, return, and command—produce known == false, so this early return bypasses the fallback alias set and the later convertToKanataKey mappings. Existing mappings then generate (macro e s c a p e), (macro s p a c e), etc. instead of esc, spc, ret, or lmet; canonicalize the token before querying the bridge or preserve the alias check ahead of this return.
Useful? React with 👍 / 👎.
The generator decided "key or word to type" from a hand-kept list in
KanataKeyConverter.shouldConvertToMacrothat missed real Kanata keys, so.keystroke("f21")became(macro f 2 1)— a rule that silently typed three characters instead of being refused (found while fixing test fixtures for phase 6).What
BackendCapabilityProfile.knowsKey(_:): true/false from the bridge (a nil answer for the name while the bridge answers forameans "not a Kanata key"), nil when there is no bridge.shouldConvertToMacroasks it first: a name Kanata knows is emitted as that key, so admission refuses it with a reason when the session can't post it; only a word Kanata doesn't know is typed. Typing words (hello→(macro h e l l o)) is an existing, tested feature and is unchanged. The hand list stays as the no-bridge fallback.Scope note
The card proposed refusing every unknown name, but that would break the intended text-typing feature; the actual bug was real key names falling into the word path, which this fixes at the source.
Tests
GeneratorKeyNameTests: keys vs words through the converter;knowsKeyanswers and its no-bridge nil; anf9 → f21rule is refused byreviewAdmissionwith the presenter sentence and by the save gate, never written as a macro.KEYPATH_TEST_ENFORCE_CLEAN_SUMMARY=1 Scripts/run-tests-safe.sh: 5,796 passed, 0 app warnings/errors, 0 build warnings. Doc note in rules-admission-review.md §4.5.🤖 Generated with Claude Code