feat: make Enter key trigger approval instead of denial when action buttons are visible

When action buttons (Approve/Reject, Save/Reject, Run/Reject) are visible:
- Enter now triggers the primary button action (Approve/Save/Run)
- Any content (text and/or images) in the input is sent along with the approval

This aligns with common UX patterns where Enter confirms/accepts the current action.

Closes #10350
This commit is contained in:
Roo Code 2025-12-27 13:00:10 +00:00
parent 13370a2ad1
commit 295a96d078
2 changed files with 23 additions and 4 deletions

View file

@ -54,6 +54,9 @@ interface ChatTextAreaProps {
// Browser session status
isBrowserSessionActive?: boolean
showBrowserDockToggle?: boolean
// Primary button action props - when action buttons are visible, Enter triggers approval
enablePrimaryButton?: boolean
onPrimaryButtonClick?: () => void
}
export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
@ -76,6 +79,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
onCancel,
isBrowserSessionActive = false,
showBrowserDockToggle = false,
enablePrimaryButton = false,
onPrimaryButtonClick,
},
ref,
) => {
@ -487,19 +492,29 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
// Handle Enter key based on enterBehavior setting
if (event.key === "Enter" && !isComposing) {
if (enterBehavior === "newline") {
// New behavior: Enter = newline, Shift+Enter or Ctrl+Enter = send
// New behavior: Enter = newline, Shift+Enter or Ctrl+Enter = send/approve
if (event.shiftKey || event.ctrlKey || event.metaKey) {
event.preventDefault()
resetHistoryNavigation()
onSend()
// When primary button is enabled (action buttons visible), trigger approval
if (enablePrimaryButton && onPrimaryButtonClick) {
onPrimaryButtonClick()
} else {
onSend()
}
}
// Otherwise, let Enter create newline (don't preventDefault)
} else {
// Default behavior: Enter = send, Shift+Enter = newline
// Default behavior: Enter = send/approve, Shift+Enter = newline
if (!event.shiftKey) {
event.preventDefault()
resetHistoryNavigation()
onSend()
// When primary button is enabled (action buttons visible), trigger approval
if (enablePrimaryButton && onPrimaryButtonClick) {
onPrimaryButtonClick()
} else {
onSend()
}
}
}
}
@ -566,6 +581,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
resetHistoryNavigation,
commands,
enterBehavior,
enablePrimaryButton,
onPrimaryButtonClick,
],
)

View file

@ -1612,6 +1612,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
modeShortcutText={modeShortcutText}
isBrowserSessionActive={!!isBrowserSessionActive}
showBrowserDockToggle={showBrowserDockToggle}
enablePrimaryButton={enableButtons && !!primaryButtonText}
onPrimaryButtonClick={() => handlePrimaryButtonClick(inputValue, selectedImages)}
/>
{isProfileDisabled && (