1. Fix:Render not work normally when using terminal through serial port
2. Extract same logic in prompt to utils.