diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index 7fbc658718..4c7bbd1a19 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 a002abf8cf..f53d20a766 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 && (