In Photoshop 2026 UXP, batchPlay duplicate Error!!!!

In Photoshop 2026 UXP, batchPlay duplicate document returns [{_obj:“error”, result:-128}] inside executeAsModal

I am developing a Photoshop UXP plugin. In Photoshop 2025, duplicating the current document via batchPlay or Document.duplicate works. In Photoshop 2026, the same command returns [{ _obj: “error”, message: “”, result: -128 }] even inside executeAsModal.

Recorded command from Alchemist:

await batchPlay([
{
_obj: “duplicate”,
_target: [{ _ref: “document”, _enum: “ordinal”, _value: “first” }],
documentID: 59,
_options: { dialogOptions: “dontDisplay” }
}
], {});

This works when replayed manually, but inside my plugin workflow it returns -128 and no new document is created.

Questions:

  1. Did Photoshop 2026 change restrictions around duplicating documents from UXP plugins?
  2. Is document duplicate blocked in some modal/plugin contexts?
  3. Should plugins use core.createTemporaryDocument instead?
  4. If createTemporaryDocument is used, how can we access layers or use it as a normal Document?

-128 means that user canceled operation. E.g esc key. Unless there is error with error code.

Thanks for the replies — I’ve actually found the root cause now.

It turns out the issue was that I was opening my main workspace using a UXP modal dialog. After the modal pops up, batchPlay commands (like duplicate) are now blocked in Photoshop 2026, although they worked in older versions.

My guess is that modals were always supposed to restrict certain layer/document operations, but this restriction had a loophole before — and I just happened to be relying on it :sweat_smile:. So it was basically a coincidence that it worked at all, and once the bug was fixed in 2026, it stopped working.

As a heads-up for other developers: avoid running batchPlay commands that modify documents or layers from inside a UXP modal dialog. It looks like Photoshop 2026 has tightened these restrictions, so what worked before should no longer be relied upon.

In the end, I gave up on using the modal window approach entirely.

Thanks again for the help, and hopefully this saves someone else some debugging time!

Did you try interactive: true in executeAsModal? That often allows you to use dialog and change document at the same time.

I tested this on Photoshop 2026 on Windows as well, and my results seem to point in the same direction.

As @Jarda said, -128 means “user cancelled”, and I also tried the interactive: true suggestion.

I tested the same duplicate command inside executeAsModal from different contexts:

  • Directly from the plugin UI, without a dialog → :white_check_mark: works
  • From a modeless dialog, dialog.show():white_check_mark: works
  • From a modal dialog, dialog.showModal():cross_mark: [{ _obj: "error", result: -128 }]
  • showModal() + executeAsModal(fn, { interactive: true }):cross_mark: still -128

So the issue seems to be specifically related to showModal(), not to running batchPlay from a dialog in general.

A modeless dialog opened with show() can run document-modifying batchPlay commands inside executeAsModal correctly. In my tests, duplicating the document repeatedly from a show() dialog worked without errors.

interactive: true does not seem to fix the showModal() case. My interpretation is that showModal() blocks Photoshop’s UI in a way that prevents Photoshop from granting the modal scope to executeAsModal in the first place.

interactive: true may affect the behavior once the modal scope has already been granted, but it does not seem to help if that scope cannot be entered.

So the workaround seems to be: use a modeless show() dialog for any UI that needs to modify the document.

const { core, action } = require("photoshop");

const dlg = document.createElement("dialog");
dlg.innerHTML = `<button id="dup">Duplicate</button>`;

document.body.appendChild(dlg);

dlg.querySelector("#dup").addEventListener("click", async () => {
  await core.executeAsModal(async () => {
    await action.batchPlay([
      {
        _obj: "duplicate",
        _target: [
          {
            _ref: "document",
            _enum: "ordinal",
            _value: "first"
          }
        ],
        _options: {
          dialogOptions: "dontDisplay"
        }
      }
    ], {});
  }, {
    commandName: "Duplicate document"
  });
});

dlg.show();          // Works with a modeless dialog
// dlg.showModal();  // Returns -128

@SandeepSharma , is this showModal() + executeAsModal behavior intended in Photoshop 2026, or could it be a regression from Photoshop 2025?

Hope this helps.

From the Related Topics, it looks like running batchPlay inside modal dialogs has actually been unstable for a long time — there are mentions of issues going back to 2022 and 2024 posts as well.

So this isn’t exactly new; it just finally caught up with me :joy:.

Right now, my workaround is to open two separate plugin panels instead. Since the dependent popups are confined strictly within their own plugin windows, this avoids the modal context entirely.

Thanks again for all the replies. Hopefully this helps more people avoid the same rabbit hole! :hole: