feat(chat): change Enter key to approve actions instead of reject

When action approval buttons are visible (like Approve/Save/Run Command):
- Empty input + Enter: now approves the action (previously did nothing)
- Text input + Enter: now approves with the text as feedback (previously rejected)

This change makes the Enter key behavior more intuitive:
- Enter always confirms/approves the current action
- Users can still provide optional feedback text before approving

Fixes #10350
This commit is contained in:
Roo Code 2025-12-27 12:57:38 +00:00
parent 13370a2ad1
commit 8cd8b01877
2 changed files with 16 additions and 4 deletions

View file

@ -42,6 +42,7 @@ interface ChatTextAreaProps {
selectedImages: string[]
setSelectedImages: React.Dispatch<React.SetStateAction<string[]>>
onSend: () => void
onAccept?: () => void // Called when Enter should trigger approval (when action buttons are visible)
onSelectImages: () => void
shouldDisableImages: boolean
onHeightChange?: (height: number) => void
@ -66,6 +67,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
selectedImages,
setSelectedImages,
onSend,
onAccept,
onSelectImages,
shouldDisableImages,
onHeightChange,
@ -486,20 +488,23 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
// Handle Enter key based on enterBehavior setting
if (event.key === "Enter" && !isComposing) {
// Determine the action handler: use onAccept if provided (for approval behavior), otherwise onSend
const actionHandler = onAccept ?? onSend
if (enterBehavior === "newline") {
// New behavior: Enter = newline, Shift+Enter or Ctrl+Enter = send
// New behavior: Enter = newline, Shift+Enter or Ctrl+Enter = send/accept
if (event.shiftKey || event.ctrlKey || event.metaKey) {
event.preventDefault()
resetHistoryNavigation()
onSend()
actionHandler()
}
// Otherwise, let Enter create newline (don't preventDefault)
} else {
// Default behavior: Enter = send, Shift+Enter = newline
// Default behavior: Enter = send/accept, Shift+Enter = newline
if (!event.shiftKey) {
event.preventDefault()
resetHistoryNavigation()
onSend()
actionHandler()
}
}
}
@ -550,6 +555,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
},
[
onSend,
onAccept,
showContextMenu,
searchQuery,
selectedMenuIndex,

View file

@ -1600,6 +1600,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
selectedImages={selectedImages}
setSelectedImages={setSelectedImages}
onSend={() => handleSendMessage(inputValue, selectedImages)}
onAccept={
// When action buttons are visible, Enter should trigger approval (primary button click)
enableButtons && primaryButtonText
? () => handlePrimaryButtonClick(inputValue, selectedImages)
: undefined
}
onSelectImages={selectImages}
shouldDisableImages={shouldDisableImages}
onHeightChange={() => {