Quick Actions 3: The problem of Undo

Mojave’s bundled Quick Actions lull you into a sense of false security with their support for undoing actions.

For example, select an image and apply the Rotate Left Quick Action to it, and you can then undo that rotation. Apply Markup to an image and you can revert it to its original state, at least until you have clicked Done to save your changes and close the document. But when you make your own Quick Actions using Automator, they have no undo: once the action has been taken, you can’t readily reverse it.

To understand why Quick Actions in general, and those made using Automator in particular, can’t support undo you need to know how that feature normally works.

Way back in Classic Mac OS, there was a move towards implementing every action in apps by means of AppleEvents. This enabled all sorts of neat features: you could record a series of actions across different apps, then replay those AppleEvents in Script Editor, for example. Although there are actions which Automator and (to a lesser extent) Script Editor can capture, for example in Automator’s Watch Me Do facility, this isn’t as fundamental in macOS as it could have been.

Even if there were some central record of every action in every app, undoing many actions requires access to data, sometimes substantial quantities. When you apply changes to a large high-resolution image, the most reliable way to undo that action is often to revert to the previous data.

So there isn’t any sub-system in macOS which can keep a detailed track of what every app does so it can be reversed. When an app performs an action or user command, it is responsible for keeping track of that, and providing a means to undo it – a feature which is entirely voluntary, if strongly preferred.

When you save changes and quit an app, you lose the ability to undo those actions when you next open that document in that app. This is because the information required for undo is almost invariably lost once the app is closed.

These principles apply to Quick Actions too. If the Quick Action opens an applet, as it does when you use Markup, that can provide basic undo or revert until you close the applet by clicking Done. The Rotate Left Quick Action appears to cheat (and why not?) and merely rotates the image clockwise to implement its undo, which is handled through the Finder.

You can verify that by rotating an image left, then placing markup on it and clicking Done. You can still undo the rotate left in Finder’s File menu, and will see your marked-up image dutifully rotated clockwise and retain its markup. If undoing the rotate replaced the image with the original unrotated version, then the markup would disappear with that undo.

If you make your own Automator or other Quick Action, then once it has run, it quits (there is no other option), and there is no direct way of implementing undo. The same applies to AppleScript scripts and apps, and other scripting systems, when run in any way, not just Quick Actions. It is one of the major limitations of using a script to do something, rather than a full-blown app. Sadly, support forums contain many cries for help from those who have just discovered that they have mutilated lots of documents using automation or scripting, and seek to undo those changes.

Full-blown apps have another fallback which has got me out of several holes: the built-in version system in macOS. Apps made to take advantage of this automatically save a series of versions of documents which you are editing, to which you can revert using the command in the File menu. Quick Actions, and Automator scripts, don’t appear able to access that system at all.

One workaround for this problem is to make Finder copies of documents in the Automator or AppleScript script – which is exactly what Automator offers to do when you add an action which will change a document’s data to your workflow. It’s not a particularly good solution, though, as it leaves you to clean up those copies yourself.

The problem of Undo is a major consideration when building or using any Quick Action, Automator workflow, AppleScript, or other lightweight solution.