Copy as javascript 2025 - 2026

I noticed some differences when using the Copy as JavaScript tool. Why did this change?

If I run it on Photoshop 2025, I get this result.

async function dupLayer() {
let result;
let psAction = require(“photoshop”).action;
let command = [

{“_obj”:“copyToLayer”}
];
result = await psAction.batchPlay(command, {});
}

If I run it on Photoshop 2026, I get this result.

async function dupLayer() {
let commands = [
{
“_obj”: “copyToLayer”
}
];
return await require(“photoshop”).action.batchPlay(commands, {});
}

I believe you are seeing a change I made in August 2024 to pretty print the Action Descriptors instead of leaving them on one line.

It does look a bit strange with your example since it is one of the smallest. On the other end of the spectrum, text layer descriptors are halfway readable now.

Sam

What I posted is a simple example.
But I don’t understand the change.
If I upload the entire file with console.log, it doesn’t work.
Should I delete it?

 async function test() {
    let commands = [
        // Crea livello
        {
            "_obj": "make",
            "_target": [
                {
                    "_ref": "layer"
                }
            ],
            "layerID": 81
        },
        // Unisci visibili
        {
            "_obj": "mergeVisible",
            "duplicate": true
        }
    ];
    return await require("photoshop").action.batchPlay(commands, {});
}

console.log(
    await require("photoshop").core.executeAsModal(test, {"commandName": "Action Commands"})
);

if I leave this console log it doesn’t work

console.log(
    await require("photoshop").core.executeAsModal(test, {"commandName": "Action Commands"})
);