Repository navigation
Conversation
A Creator Micro 2 over Bluetooth LE reports `activeProfileId: -1` in its keymap.json. The profile lookup only checked the upper bound, so -1 went straight into the subscript and trapped with "Index out of range" the moment the bridge started - which is the first click on the menu-bar icon, every time. Resolve the index in one place, falling back to the first profile for any id outside the range (what an oversized id already did), and use it from the three keymap lookups and the emulator. Two tests feed -1 and an oversized id through every path. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EaYv7dSTLSNUJdZTsV3Fwv
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.
The crash
A Creator Micro 2 (product id 0x8298, over Bluetooth LE) reports
activeProfileId: -1in itskeymap.json.KeymapManager.activeLayerKeymapdidwhich only guards the upper bound, so -1 passes straight into the subscript and Swift traps:
The bridge starts from the
.taskon the menu panel, so this is the first click on the menu-bar icon, every launch, for anyone whose pad reports a negative id. The fixture anddocs/hacking.mdboth assume 0, which is presumably why it never showed up. The same one-sided check was inactiveLayerLayout,withAgentKeymapandPadEmulator.refreshBinding.The fix
One
activeProfileIndex(_:among:)resolves the index, trustingactiveProfileIdonly when it is a real index and falling back to the first profile otherwise - which is what an oversized id already did. The three keymap lookups and the emulator go through it. The pad's ownactiveProfileIdvalue is left untouched on write; only the lookup is clamped.Two tests feed -1 and 99 through
activeLayerKeymap,activeLayerLayout,isAgentKeymapAppliedandwithAgentKeymap.Verified on the pad that triggered it: the panel opens and the bridge runs where it used to trap.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EaYv7dSTLSNUJdZTsV3Fwv