add/remove cable by code: history?

Hi,

I’m adding/removing cable via code, on GUI thread, basically this way:

void addCable(int64_t inputModuleId, int64_t inputInputId, int64_t outputModuleId, int64_t outputInputId, int colorId) {
	rack::engine::Cable *cable = new rack::engine::Cable;
	cable->inputId = (int)inputInputId;
	cable->inputModule = APP->engine->getModule(inputModuleId);
	cable->outputId = (int)outputInputId;
	cable->outputModule = APP->engine->getModule(outputModuleId);
	APP->engine->addCable(cable);

	app::CableWidget *cableWidget = new app::CableWidget;
	cableWidget->setCable(cable);
	cableWidget->color = settings::cableColors[colorId];
	APP->scene->rack->addCable(cableWidget);
}
void removeCables(int64_t inputModuleId) {
	for (PortWidget *portWidget : getOutputs()) {
		for (CableWidget *cableWidget : APP->scene->rack->getCompleteCablesOnPort(portWidget)) {
			if (cableWidget->cable->inputModule->id == inputModuleId) {
				APP->scene->rack->removeCable(cableWidget);
				delete cableWidget;
			}
		}
	}
}

It seems to works nice. BUT: not able to push those “changes” in history. Which other context should I trigger/push to also insert those change int the history road? (so a CTRL+Z will undo the added/removed cables)?

Thanks

Some casual skimming of rack source suggest you will APP->history->push() a new CableAdd Action.