Skip to content

Device actions: support map actions with label keys - #19

Merged
robdobsn merged 2 commits into
mainfrom
bugfix/action-map-label-keys
Oct 23, 2026
Merged

robdobsn merged 2 commits into
mainfrom
bugfix/action-map-label-keys

Conversation

@robdobsn

Copy link
Copy Markdown
Owner

Problem

Some device type records use label keys in action maps: Trill _conf.mode (centroid/raw/baseline/diff), ENS160 mode (deep sleep/idle/standard) and QwiicButton LED (off/on/breathe). The dashboard actions form parsed every map key with parseFloat, so:

  • each <option> got value={NaN}, which React warns about ("Received NaN for the value attribute")
  • picking an option stored NaN, so Send did nothing

Also, sendAction passed every _conf.* map action to setSampleRate(), so Trill _conf.mode would 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 matching d, or the first key.
  • sendAction (RaftDeviceManager, RaftDeviceMgrIF): data is now Array<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.
  • Only _conf.rate goes to setSampleRate(). Other _conf.* map actions write their mapped value.
  • Version 2.9.0 → 2.9.1

Testing

  • tsc --noEmit passes for the library and the dashboard
  • jest: 237/237 tests pass
  • Not yet tested on hardware

🤖 Generated with Claude Code

robdobsn and others added 2 commits October 23, 2026 19:45
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>
@robdobsn
robdobsn merged commit 52d040c into main Oct 23, 2026
1 check passed
@robdobsn
robdobsn deleted the bugfix/action-map-label-keys branch October 23, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant