Registering action in new ui main toolbar

I wanted to register my action in new ui main toolbar (macos) and all of below fails:

val group = ActionManager.getInstance().getAction(IdeActions.GROUP_MAIN_TOOLBAR_NEW_UI) as DefaultActionGroup
group.add(DebugUsingHotSwapAgentAction.getAction())

and standard:

<action
   id="HotSwap.debug"
   class="com.vaadin.plugin.actions.DebugUsingHotSwapAgentAction"
   text="Debug using HotSwapAgent"
   icon="/vaadin/icons/debug.svg">
   <add-to-group group-id="RunToolbarMainActionGroup"
       relative-to-action="Run"
       anchor="after"/>
   <add-to-group group-id="MainToolbarRight" />
</action>

What’s interesting is that for plugin.xml it is displayed for < 1 second and then removed. (it can be seen on screen recording in GH issue Show debug with hotswap in toolbar by default · Issue #177 · vaadin/intellij-plugin · GitHub).

I also noticed in sources that some actions extend CustomComponentAction and define there where to be placed, but no luck in my case, implemented as below:

override fun createCustomComponent(presentation: Presentation, place: String): JComponent {
        presentation.text = "Debug using HotSwapAgent"
        presentation.icon = VaadinIcons.DEBUG_HOTSWAP
        return object : ActionButton(this, presentation, ActionPlaces.NEW_UI_RUN_TOOLBAR, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
        }
    }

I can see it is possible because SearchEverywhere or JRebel actions are present exactly there.

You definitely never should do this programmatically as it breaks user settings. But adding to a relevant group in XML must work

So why it disappears?

Screen Recording 2025-04-11 at 11.54.05

We do it this way usually:

<action id="SendFeedback"
        class="com.jetbrains.ds.actions.DSSendFeedbackAction"
        icon="PycharmDSCustomizationIcons.Feedback">
    <add-to-group group-id="MainToolbarRight" 
                  anchor="after" relative-to-action="SearchEverywhere"/>
</action>

Do you have any update() logic for it?

Ok, so having action defined as:

<action
                id="HotSwap.debug"
                class="com.vaadin.plugin.actions.DebugUsingHotSwapAgentAction"
                icon="/vaadin/icons/debug.svg">
            <add-to-group group-id="MainToolbarRight"
                          anchor="after" relative-to-action="SearchEverywhere"/>
        </action>

I end up with disappearing magic still:
Screen Recording 2025-04-11 at 12.00.52

I think I’ve found issue - my action extends ExecutorAction, when replaced with classic AnAction it is fine:

Real reason was that ExecutorAction has been toggling visibility in

presentation.setVisible(targetNodes.isNotEmpty());

My executor action implementation needed to be updated.