Prior behaviour: the Mode dropdown existed but nothing consumed it in the editor — analog fields (Scaling, Source Min/Max, Smoothing, …) were always visible, and the Channels JSON editor was always visible too. For a legacy node with no saved mode the dropdown defaulted blank so users reported "I cant even select digital or analog". Changes: - Initialize the Mode <select> from node.mode with an 'analog' fallback for legacy nodes (safe default — matches pre-digital behaviour). - Wrap analog-only fields and digital-only fields in labelled containers and toggle their display based on the selected mode. Mode change is live — no redeploy needed to see the right form. - Inline hint under the Mode dropdown tells the user what payload shape is expected for the current mode. - Channels JSON gets live validation — shows channel count + names on valid JSON, warns on missing key/type, errors on invalid JSON. - Label function appends ' [digital]' so the node visibly differs in a flow from an analog sibling. - oneditsave is mode-aware: only warns about incomplete scaling ranges in analog mode; in digital mode warns if the channels array is empty or unparseable. Runtime friendliness: - nodeClass node-status now shows 'digital · N channel(s)' on startup in digital mode, and 'digital · N/M ch updated' after each incoming msg so the editor has a live heartbeat even when there is no single scalar. - When analog mode receives an object payload (or digital receives a number), the node logs an actionable warn suggesting the mode switch instead of silently dropping the message. Explicit, not auto-detected: mode remains a deployment-time choice because the two modes take different editor config (scaling/smoothing vs channels map). Auto-detecting at runtime would leave the node unconfigured in whichever mode the user hadn't anticipated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
18 KiB
18 KiB