There is no global undo stack. Each file has its own undo stack since most editing makes changes to one file and not any of the others. When you do a session change each file has the change made independently and the undo is saved to its stack. Of course files where nothing was changed have no undo, so globally undoing the last undo entry is a "bad thing".
In general changing files other than the current one is a "bad thing" except when explicitly instructed by the user (eg replace in session).