add chat history save and preload last messages