You use Gmail's undo feature as an example, but it doesn't work in the way you prescribe. It's the cheap & easy version of undo that doesn't require building your application around the command pattern: just implement a reasonable delay before making the irreversible change, and show the Undo action during this delay (which is really a "cancel the pending change" action).
No, it's not as clean or as good of an experience for your users, but it works great for applications such as email that perform fundamentally irreversible actions.