Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions nodes/config/ui_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,10 @@ module.exports = function (RED) {
msg = await appendTopic(RED, widgetConfig, wNode, msg)
}

// store the latest msg passed to node
datastore.save(n, widgetNode, msg)
// store the latest msg passed to node unless payload is missing
if (typeof msg.payload !== 'undefined') {
datastore.save(n, widgetNode, msg)
}
Comment on lines +1105 to +1107
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change creates an inconsistency with widgets that have custom onInput handlers. For example, ui_switch.js (lines 58-60) explicitly saves to datastore when msg.payload === undefined with the comment "may be setting class dynamically or something else that doesn't require a payload". Since the purpose of this fix is to prevent saving messages without payloads (to avoid clearing displays on refresh), consider whether widgets with custom onInput handlers like ui_switch should also skip saving when payload is undefined for consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +1105 to +1107
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change lacks test coverage for the specific scenario it's fixing: messages with msg.ui_update, msg.enabled, or msg.visible but no msg.payload should not be saved to the datastore. Consider adding a test that:

  1. Sends a message with only msg.ui_update (or msg.enabled/msg.visible) and no payload
  2. Verifies that datastore.save() is NOT called for this message
  3. Verifies that the state properties are still set correctly via statestore.set()
  4. Confirms that on browser refresh, the display value is not cleared

This would ensure the fix works as intended and prevent regression.

Copilot uses AI. Check for mistakes.

if (hasProperty(widgetConfig, 'passthru')) {
if (widgetConfig.passthru) {
Expand Down
Loading