Marching ants not redrawn while a modal dialog is open inside executeAsModal

If a plugin changes the selection inside executeAsModal and then opens a modal dialog (uxpShowModal) in the same command, Photoshop keeps drawing the old selection’s marching ants until the dialog closes and the command ends. The selection itself has changed (reading it back returns the new one), only the ants are stale.

Minimal repro on github make a selection, click the button. It deselects, then opens a dialog. Expected: no ants. Actual: the old ants are still there.

core.executeAsModal(async () => {
    await action.batchPlay([{ _obj: 'set', _target: [{ _ref: 'channel', _property: 'selection' }],
        to: { _enum: 'ordinal', _value: 'none' } }], {});
    await dialog.uxpShowModal({ title: 'Stale Marching Ants' });
}, { commandName: 'Deselect and Show Dialog' });

app.updateUI() doesn’t redraw them. Opening the dialog after the command ends works, but then the change and the dialog can’t share one history step.

Our real case: a filter resizes the document and carries the selection through the resize, then shows its dialog. The ants show the selection at its old size and position while the preview uses the correct one.

Is there a way to force the ants to redraw inside a command?

I’d love to see app.updateUI()improved to show updates, there are many scenarios (such as layers panel) which defer updating until the model is done. In some cases a delay or alert may help (or user moving the modal alert), but it isn’t complete, reliable, or a great experience. You could run back to back modals, but that is could break your workflow if the user has other panels which may be listening and might alter document state by jumping in after the first modal.