How to remove some actions from commandstack

Hi every one!
Is there somehow to remove some actions from commandstack?
In my case I have this code

 this.bpmnModeler.on('shape.added',(e) => {   
 
      var modeling = this.bpmnModeler.get('modeling');
      var commandStack = this.bpmnModeler.get('commandStack');
      switch (element.type) {
        case "bpmn:StartEvent":
          modeling.setColor(element, {
            stroke: '#76B233'
          });
          break;            
      }           
  });

this code paint the start event with green color. But when I hit ctrl+z the start event becomes black.
So my question is:
How to remove the .setColor action from commandstack?
I tried to use the code below after .setColor:

var commandStack = this.bpmnModeler.get(‘commandStack’);
commandStack._stack.pop();

But when I did it, the ctrl+z and ctrl+y stop to work

– >If I put some color in another component, the behavior is the same when I hit ctrl+z

You’re executing a separate command when calling modeling#setColor. Ctrl + Z will only undo that command, not the one that created the shape. To set the color without a separate command use a command interceptor:

class MyCommandInterceptor extends CommandInterceptor {
  constructor(eventBus, modeling) {
    super(eventBus);

    this.postExecuted(["shape.create"], ({ context }) => {
      const { shape } = context;

      if (is(shape, "bpmn:StartEvent")) {
        modeling.setColor(shape, { stroke: "fuchsia" });
      }
    });
  }
}

CodeSandbox: CommandInterceptor Example - CodeSandbox

Please don’t do that, you’re playing with :fire: :fire_engine: :dash:

Hi philippfromme!

Thank you so much for the code!

It´s workin using CommandInterceptor !!