Repository navigation
Device actions: support map actions with label keys - #19
Merged
Merged
Conversation
Action maps can use label keys (Trill _conf.mode: centroid/raw/..., ENS160 mode, QwiicButton LED: off/on/breathe), but the dashboard actions form parsed every key as a number, giving NaN option values (a React warning) and a selection that could never be sent. - DeviceActionsForm keeps a map selection as its key string; numeric keys are still sorted ascending, label keys keep their listed order - sendAction accepts the map key as a string for map actions - Only _conf.rate is delegated to setSampleRate(); other _conf.* map actions (e.g. Trill _conf.mode) write their mapped value Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
Some device type records use label keys in action maps: Trill
_conf.mode(centroid/raw/baseline/diff), ENS160mode(deep sleep/idle/standard) and QwiicButtonLED(off/on/breathe). The dashboard actions form parsed every map key withparseFloat, so:<option>gotvalue={NaN}, which React warns about ("Received NaN for thevalueattribute")Also,
sendActionpassed every_conf.*map action tosetSampleRate(), so Trill_conf.modewould have changed the sample rate instead of writing the mode.Changes
DeviceActionsForm: a map selection is kept as its key string. Numeric keys are still sorted ascending; label keys keep the order the record lists them. The default is the key matchingd, or the first key.sendAction(RaftDeviceManager,RaftDeviceMgrIF):datais nowArray<number | string>, so a map action can be sent its key. An action without a map still needs numbers and gets a warning, not an encode call, if given a string. Existing callers that pass numbers are unaffected._conf.rategoes tosetSampleRate(). Other_conf.*map actions write their mapped value.Testing
tsc --noEmitpasses for the library and the dashboardjest: 237/237 tests pass🤖 Generated with Claude Code