Add frontend pre and post debug message hooks#5495
Merged
Conversation
6 tasks
Contributor
Author
|
Usage example - add extra button to warning & error level messages: if (RED.hooks.isKnownHook?.('debugPostProcessMessage')) {
RED.hooks.add('debugPostProcessMessage.my-plugin', function (processedMessage) {
const { message, element, payload } = processedMessage
let tt = ''
switch (message?.level) {
case 20:
tt = 'This is an error message. Click for details.'
break
case 30:
tt = 'This is a warning message. Click for details.'
break
default:
return // only interest in error and warning level messages
}
const metaRowTools = element.find('.red-ui-debug-msg-meta .red-ui-debug-msg-tools')
if (metaRowTools.length) {
const buttonEl = $('<button class="my-plugin-tool-button red-ui-button red-ui-button-small"><i class="fa fa-question"></i></button>')
RED.popover.tooltip(buttonEl, tt)
buttonEl.data('my-plugin-debug-data', { message, payload }) // for access to debug data in click handler
buttonEl.on('click', function () {
const debugData = buttonEl.data('my-plugin-debug-data')
// Do the necessary with the debug data
if (debugData.message.level === 20) {
alert('Error messages are indicated by the red edges!\n\n' + JSON.stringify(debugData.message, null, 2))
} else if (debugData.message.level === 30) {
alert('Warning messages are indicated by the yellow edges!\n\n' + JSON.stringify(debugData.message, null, 2))
}
})
metaRowTools.append(buttonEl)
}
})
} Example: |
knolleary
approved these changes
Feb 25, 2026
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.

Types of changes
closes #5489
Proposed changes
editor-client/src/js/hooks.jsutil/lib/hooks.jsdo)debugPreProcessMessageanddebugPostProcessMessageisKnownHookto permit node/plugin integrations to query if the hook they intend on attaching to is a known/supported hookvartolet/constnodes/core/common/lib/debug/debug-utils.jsprocessDebugMessagein the 2 new hooksdebugPreProcessMessageanddebugPostProcessMessagetoolsto be passed tocreateObjectElementred-ui-debug-msg-toolsspanelement (function generated messages dont get a toolbar like all other messages)debugPostProcessMessagehooks to affect the debug messages5.x stream
There is a 2nd PR here: #5490 - we can either merge that or wait until nr5 is merged into master
Checklist
npm run testto verify the unit tests pass