The easiest way to make this work is to render the TUI to stderr instead of stdout (see the backend methods which accept a writer e.g. https://docs.rs/ratatui/latest/ratatui/backend/struct.CrosstermBackend.html#method.new). The second easiest is to write explicitly to the tty device instead of stdin / stdout. E.g. open the /dev/tty
file and use that as the writer. (Notably, the Termwiz backend uses the tty by default IIRC).