move write message type functions to chat.ui.