Duplicating a document with SmartObject causes an app.refresh() bug
I am preparing a script, which resizes the active document into multiple different scaled versions of it and exports each version to multiple locations. I am doing it with the lazy approach of creating and modifying a duplicate of the original document as a failsafe to keep original intact. The problem/bug appears only when I duplicate a document, which contains a smart object and report the end of script execution via an alert. As visible in the screenshots, it results in the app.refresh not refreshing the application frame correctly. Note, that after the alert is closed, the application is refreshed to normal, since the script finished execution.
Before execution:

At the end of execution on alert:

The script is meant to be used with documents, which will always have a SmartObject (taken from Illustrator), since such is the local convention for this type of documents. Since the artists use different versions of Photoshop, I cannot report the execution progress by a progress bar. I need to report the execution status, because the script also always returns back to the original state without any history with UNDOs and it looks like "nothing happened". So I need an alternative to an alert dialog that will work with most versions of photoshop or a way to force app.refresh to work correctly.
A simplified version of the script:
function main(){
var doc_original = activeDocument;
// imagine an actual for loop from this part on
for(...){
var doc_copy = doc_original.duplicate("TEMP");
// imagine resize + export code (still TODO)
doc_copy.close(SaveOptions.DONOTSAVECHANGES);
}
}
var original_active = activeDocument;
original_active.suspendHistory(history_state_name, 'main()');
// removes any modification to original document (just calling duplicate marks it as changed)
executeAction(charIDToTypeID('undo'), undefined, DialogModes.NO);
activeDocument = original_active;
// refresh solves the problem of not updating the active document
refresh();
alert("Finished export");
I encountered the issue on MacOS Mojave 10.14.3 with a MacBook Pro (15-inch, 2018, 2.6 GHz Intel Core i7, 16 GB 2400 MHz DDR4).
