There are terminal libraries that do this:
https://github.com/vadimdemedes/ink
Which is what Claude Code CLI uses (or was using?) and it caused many issues such as flickering, thrashing, and latency.