Enable Enter key to send debate messages#292
Enable Enter key to send debate messages#292vinayak302004 wants to merge 1 commit intoAOSSIE-Org:mainfrom
Conversation
📝 WalkthroughWalkthroughThe change adds an Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@frontend/src/Pages/DebateRoom.tsx`:
- Around line 863-868: The Enter handler on the Input should not send while
speech recognition is active and the Shift+Enter check is misleading for a
single-line <Input>; update the onKeyDown handler used around the Input
component so it first checks isRecognizing and returns early (do not call
sendMessage when isRecognizing is true), and remove or ignore the !e.shiftKey
clause since the shadcn/ui Input is single-line (if multiline later, switch to a
textarea and reintroduce the Shift+Enter logic); reference the existing
onKeyDown arrow handler, the isRecognizing flag, and the sendMessage() function
when making this change.
| onKeyDown={(e) => { | ||
| if (e.key === "Enter" && !e.shiftKey) { | ||
| e.preventDefault(); | ||
| sendMessage(); | ||
| } | ||
| }} |
There was a problem hiding this comment.
The Enter-to-send logic is correct; two minor observations.
-
Shift+Enter guard is a no-op here: The
<Input>component (shadcn/ui) renders a single-line<input>, which cannot produce newlines regardless. The!e.shiftKeycheck is harmless but the PR description's claim about "Shift+Enter inserts a newline" doesn't apply to this element. If multiline input is actually desired in the future, this would need to be a<textarea>instead. -
Enter fires during speech recognition: The input is
readOnly(notdisabled) whileisRecognizingis true (line 869), so theonKeyDownhandler still fires. Pressing Enter mid-dictation would callsendMessage()and send whatever partial transcript has accumulated infinalInput. Consider guarding against this:
Proposed fix
onKeyDown={(e) => {
- if (e.key === "Enter" && !e.shiftKey) {
+ if (e.key === "Enter" && !e.shiftKey && !isRecognizing) {
e.preventDefault();
sendMessage();
}
}}🤖 Prompt for AI Agents
In `@frontend/src/Pages/DebateRoom.tsx` around lines 863 - 868, The Enter handler
on the Input should not send while speech recognition is active and the
Shift+Enter check is misleading for a single-line <Input>; update the onKeyDown
handler used around the Input component so it first checks isRecognizing and
returns early (do not call sendMessage when isRecognizing is true), and remove
or ignore the !e.shiftKey clause since the shadcn/ui Input is single-line (if
multiline later, switch to a textarea and reintroduce the Shift+Enter logic);
reference the existing onKeyDown arrow handler, the isRecognizing flag, and the
sendMessage() function when making this change.
Closes #280
What changed
Why
Improves usability and matches standard chat behavior.
Summary by CodeRabbit