Basically reimplement https://github.com/coder/jetbrains-coder/pull/521 in the new branch