Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions webview-ui/src/components/chat/ChatTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand All @@ -76,6 +79,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
onCancel,
isBrowserSessionActive = false,
showBrowserDockToggle = false,
enablePrimaryButton = false,
onPrimaryButtonClick,
},
ref,
) => {
Expand Down Expand Up @@ -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()
}
}
}
}
Expand Down Expand Up @@ -566,6 +581,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
resetHistoryNavigation,
commands,
enterBehavior,
enablePrimaryButton,
onPrimaryButtonClick,
],
)

Expand Down
2 changes: 2 additions & 0 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
modeShortcutText={modeShortcutText}
isBrowserSessionActive={!!isBrowserSessionActive}
showBrowserDockToggle={showBrowserDockToggle}
enablePrimaryButton={enableButtons && !!primaryButtonText}
onPrimaryButtonClick={() => handlePrimaryButtonClick(inputValue, selectedImages)}
/>

{isProfileDisabled && (
Expand Down
Loading