The most convenient place to do this is in a shared docked view for the entire project. The change event on one of its custom properties, bound to the tag, will have the context needed to unconditionally open a popup.
Do not provide session ID or page ID when opening a popup from within a page context. (Also, show us the real call to system.perspective.openPopup(), not just a call to a library function that is "understood" to do it for you.)
I am biased toward UI tag bindings rather than messaging. Script in one place instead of two, and the "send" side is handled purely in java infrastructure.