One thing Builder has done for a long time is make terminals work seamlessly even if distributed using container technologies. Because pseudo-terminals are steeped in esoteric UNIX history, it can be non-obvious how to make this work.
I’m in a place to help you not have to deal with that pain because I’ve already gone through it. So I created some utility code and a demo application that can be packaged with Flatpak. If it detects it’s running under Flatpak it will use a few techniques to get a user-preferred shell executed on the host with a PTY controlled by application.
Edit: The flatterm repository has been updated to use the brand new VTE_PTY_NO_CTTY
flag that was added in response to this blog post. Users of Vte from git (what will be 0.58) get to enjoy writing even less code.