Just like in GUI, in a TUI you need some mechanism to make the rendering output (the characters) match the internal state of the application.
E.g., the user hit ESC -> internal state is CANCELED/WAIT FOR USER -> internal GUI representation now includes a prompt that asks the user to tell Claude what to do differently -> rendering output actually shows said prompt.
Just like in GUI, in a TUI you need some mechanism to make the rendering output (the characters) match the internal state of the application.
E.g., the user hit ESC -> internal state is CANCELED/WAIT FOR USER -> internal GUI representation now includes a prompt that asks the user to tell Claude what to do differently -> rendering output actually shows said prompt.
It solves the problem of if the UI changes, what characters on the terminal do we need to update to show the right thing to the user.