From 295a96d07853b29cbc5629ea508c85a7c6af6701 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Sat, 27 Dec 2025 13:00:10 +0000 Subject: [PATCH] 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 --- .../src/components/chat/ChatTextArea.tsx | 25 ++++++++++++++++--- webview-ui/src/components/chat/ChatView.tsx | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index 7fbc6587181..4c7bbd1a19e 100644 --- a/webview-ui/src/components/chat/ChatTextArea.tsx +++ b/webview-ui/src/components/chat/ChatTextArea.tsx @@ -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( @@ -76,6 +79,8 @@ export const ChatTextArea = forwardRef( onCancel, isBrowserSessionActive = false, showBrowserDockToggle = false, + enablePrimaryButton = false, + onPrimaryButtonClick, }, ref, ) => { @@ -487,19 +492,29 @@ export const ChatTextArea = forwardRef( // 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( resetHistoryNavigation, commands, enterBehavior, + enablePrimaryButton, + onPrimaryButtonClick, ], ) diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index a002abf8cfb..f53d20a766f 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -1612,6 +1612,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction handlePrimaryButtonClick(inputValue, selectedImages)} /> {isProfileDisabled && (