[BUG] performMenuCommand() inside executeAsModal() does not work with negative commands

Noticed this on:
Manifest v4
Api v2
Ps v23.3.2, v23.4.2, v23.5 (beta)

Run this in console multiple times (change ["menuBarInfo"]["submenu"][10]["submenu"][3]["submenu"][1] path to some 3rd party plugin menu command - these are negative - which would change app state):

const photoshop = require("photoshop");

const getMenuItem = () => {
    return photoshop.action.batchPlay([{
        "_obj": "get",
        "_target": [
            {"_property": "menuBarInfo"},
            {"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"},
        "_options": {"dialogOptions": "dontDisplay"}
    }], {synchronousExecution: true})[0]["menuBarInfo"]["submenu"][10]["submenu"][3]["submenu"][1]

// await photoshop.core.executeAsModal(async () => {
    const menuItem = getMenuItem()

        commandId: menuItem.command,
        kcanDispatchWhileModal: true,
        _isCommand: false

// }, {commandName: "Command"})

You will notice that menu item before command and after have same negative command ID always. Now uncomment both lines where script is wrapped in executeAsModal() and run multiple times. You will notice how command ID toggles between two values every run. Also running in execModal negative commands does not work.

This is very counter intuitive - shouldn’t state changing actions be run in a modal state? Now it’s reverse - command (which changes Ps state, because this plugin command I run, generates a bunch of new layers) works only if it’s ran not in a modal state :confused: I’m very confused

I’m thinking if the issue could be because of incompatibility of modal states between plugins :confused: I mean if Plugin1 runs a command of Plugin2 in execModal(), where Plugin2 also runs that command in its own execModal() :confused: In such case now we cannot group multiple commands into a single history state