API to enter edit context or apply edits support

With dialogs you had a window open and you had to apply changes without making any errors and if you did make errors all the changes would be rolled back.

With plugin panels a user is always on the document level and the panel is always visible and changes can be made atomically (change by change sort of). So maybe there is the possibility of support for something like this?

I’m also posting this for discussion purposes to figure how to get this to work.

Use Case
My specific use case is I’m trying to make a plugin feature that will rename all scene nodes to unique names but if I run into an edit context error I want to store the node or enter the node context, rename the node and then exit that context.

This is somewhat related:

Isn’t this what Rename It plugin does?

It might and I can recommend it. Rename It currently supports renaming selected layers.

In my case this is a feature that I would use in an existing plugin to ensure all of the names of all layers are not the same. There are other use cases though. Naming a layer would, in my opinion, be a risk free change. You could rename all the layers in a document and not cause anything to break (unless there are other reasons).

In my plugin, a second use case is, I’d like to create a breadcrumb trail. If you have an element in a group selected you could select the parent container and exit out of the current edit context. I don’t think that’s possible right now. So if you could do something like document.applyEdits() then it might make it possible to exit from the existing context or the inverse.