Notification when On Start (function node) is modified

I see node red has updated to add a notifcation when you add description to a node. Wonderful!
It would be equally great to see a notification when On Start (function node) has content (other than the default comments). Doesn't have to be on the node itself, but at least in the tab under "Edit function node". Reason is the same as for description icon. I don't often add descriptions to nodes or code to "On Start". But when I do, it is generally important. Everything is compartmentalized so you never see the "full picture" at the same time, and these details are easily overlooked.

Perhaps it's difficult? Perhaps it's hard to design. Doesn't matter if the On Start tab has a different background color, icon or anything else. It would be useful none the less. My current solution is to manually add a comment on top of main code tab (On Message) that says On Start has content.

I sympathise with the need to know when there is code on the "On start" and "On stop" tabs.

Looking at the function config in my browser dev tools. I see that at the right hand end of each tab label is <span class="red-ui-tabs-badges"></span>.
I have never seen anything in this bit of the dialog.

What are these badges? Should there be a badge for "This tab contains code", thus maybe allowing us to tweek the tab's appearance?

1 Like

I have been using this line for several years as the first..
// Look in On Start

4 Likes

Haha this feature is so much needed!

Yes, it would be good if, for example, the On Start tab were to be highlighted in some way if there were any content.

Asked chatgpt to review some code for me. It noticed I had some useless context initialization in On Start. Turns out I've copied another function node which used that, but rewritten it to be something different that didn't use context at all. I never noticed :zany_face:

I don't think that I've ever found an actual use for the On Start feature to be honest.

It's great for setting things up like context, functions etc. that do not need to be run every time a message arrives.

1 Like

It can hide some boiler plate when initializing context. On the other hand, I've never found a use case for On Stop, but I know from other programming cases it may be required to close some connections. However, this hightlight/notification would be equally useful for both.

The function node config has 4 tabs, surely the same highlighting should be applied to all of them?

The Setup tab should be highlighted if any external modules are specified, the other three if there is any code except comments (On Start and On Stop come with two lines of comment, On Message has two lines: empty and return msg;)

So a newly created function would have just the On Message tab highlighted.

Do the core developers have any thoughts about this feature request?

1 Like

No complaints from me. Makes sense to have some sort of highlight on the tabs if there is content.

4 Likes

I wonder if there is any milage in adding a hint in the node text (like the Inject node has) when "On Start" or "On Stop" are populated? :thinking:

Same. Makes sense!

@ThingsTinkerer As the OP, to avoid this getting lost in the forum, would you be in a position to raise a FR issue on the Node-RED Repo outlining the request and link it back to this thread?

2 Likes

Thx, you mean like this?
FR: UI notification when On Start or On Stop are modified (function node) · Issue #5436 · node-red/node-red

3 Likes

Yup. Perfect.