Message submitted twice when pressing Enter rapidly / double-clicking send
Version: 2.1.88
Description:
When pressing Enter twice rapidly (or double-clicking the send button), the same message is submitted twice, causing two separate API requests and two responses.
Steps to reproduce:
- Type any message in the input box
- Press Enter twice very quickly (or double-click the submit button)
- The message is sent twice
Root cause:
The submit handler fires synchronously on keypress without any debounce or in-flight guard. When the second Enter fires before React re-renders with the new "loading" state, a second submission goes through.
Suggested fix:
Add a ref-based flag (isSubmitting) that is set synchronously when the first submission fires, and reset when the response completes. A useRef prevents the stale-closure problem that a plain useState would have here.
Environment: macOS 25.2.0 (Darwin), zsh terminal, npm package installation
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗