I believe they "hack" accessibility hooks in the OS to position the floating window as if it was part of the app. That part is actually quite impressive and works well.
I imagine it's quite a bit of engineering effort to make that not janky. I wonder how hard it is to make cross platform. Maybe other OSes have easier hooks? Easier permissions for sure.