"New Chat" button does not work when a user types too fast/too many and encounter 429s
Describe the bug After "New Chat" button, whose tooltip says "unsaved history will be lost", is clicked, the conversation continues and chatbot responds with answers to the prior user inputs. Maybe this is expected, but I would think it's better to cancel/discard on-the-fly responses from remote model providers
To Reproduce
- Use OPENROUTE.AI model, chat mode
- Start a new chat. Open developer tools, go to Network or Console tab as long as you can see 429 errors
- Start to type anything and enter "Enter". Repeat, quickly
- when you start to see a couple 429s, click "New Chat"
- Observe that the conversation continues..
Expected behavior I'd guess the system retries for 429 responses and tries to handle them when successful, when you are not clicking "New Chat". However, when I click "New Chat", I'd expect all prior messages would be discarded and a fresh new conversation is started.
Screenshots
https://github.com/logancyang/obsidian-copilot/assets/8389897/4a182c00-9c99-42ae-be4f-0c686934ef3f
Additional context
I see, it doesn't need fast and many inputs, New Chat doesn't disrupt any bot response right now. I think from this there are at least 2 issues:
- User shouldn't be able to send a new message before the bot finishes (to avoid 429)
- New Chat should disrupt all calls, basically it should first call the Stop button's handler and then clears the chat history.
This is a good first issue too.
Created this one to separate it from the 429 issue https://github.com/logancyang/obsidian-copilot/issues/293