mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
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:
parent
13370a2ad1
commit
295a96d078
2 changed files with 23 additions and 4 deletions
|
|
@ -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,
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1612,6 +1612,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
modeShortcutText={modeShortcutText}
|
||||
isBrowserSessionActive={!!isBrowserSessionActive}
|
||||
showBrowserDockToggle={showBrowserDockToggle}
|
||||
enablePrimaryButton={enableButtons && !!primaryButtonText}
|
||||
onPrimaryButtonClick={() => handlePrimaryButtonClick(inputValue, selectedImages)}
|
||||
/>
|
||||
|
||||
{isProfileDisabled && (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue