ui: extract helpers to write message with type or label
This provides a 'type' attribute to command-server clients, which seems
more solid than relying on 'ui.<type>' labels. In future patches,
type='progress' will be added to send raw progress information.