TextCommand commands (that is, commands that alter the state of the selection or the contents of a file) are allowed to be in macros, which is why your macro was empty.
A plugin can create a new
window at will, and it can create a new
view (tab) as well. So a plugin could, in response to a key binding, create a new window, create a
view inside of the new window and then set that view up to be mostly identical to the original, followed by closing the original. That would mimic the tab being detached into it's own window. This could also be done by creating the
view in an already existing window and then closing the original window, which would simulate putting the tab back into another window.
The caveat is the "mostly identical" part.
The API doesn't allow you to iterate over the list of things like settings, region keys, status line keys, etc. Instead it has a get/set/erase mentality instead. As such there are various things that you can't fully replicate in your duplicate view because you will be unable to collect all of the information you need.
Depending on your use case, that may or may not actually matter to you, though.