Skip to content

Commit 319ed85

Browse files
committed
feat: add click-to-edit, ESC-to-cancel, and fix padding consistency
- Enable click-to-edit for past messages by making message text clickable - Add ESC key handler to cancel edit mode in ChatTextArea - Fix padding consistency between past and queued message editors - Adjust right padding for edit mode to accommodate cancel button Fixes #7788
1 parent 0ce4e89 commit 319ed85

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ export const ChatRowContent = ({
11741174
return (
11751175
<div className="bg-vscode-editor-background border rounded-xs p-1 overflow-hidden whitespace-pre-wrap">
11761176
{isEditing ? (
1177-
<div className="flex flex-col gap-2 p-2">
1177+
<div className="flex flex-col gap-2">
11781178
<ChatTextArea
11791179
inputValue={editedContent}
11801180
setInputValue={setEditedContent}
@@ -1195,7 +1195,15 @@ export const ChatRowContent = ({
11951195
</div>
11961196
) : (
11971197
<div className="flex justify-between">
1198-
<div className="flex-grow px-2 py-1 wrap-anywhere">
1198+
<div
1199+
className="flex-grow px-2 py-1 wrap-anywhere cursor-pointer hover:bg-vscode-list-hoverBackground rounded transition-colors"
1200+
onClick={(e) => {
1201+
e.stopPropagation()
1202+
if (!isStreaming) {
1203+
handleEditClick()
1204+
}
1205+
}}
1206+
title={t("chat:queuedMessages.clickToEdit")}>
11991207
<Mention text={message.text} withShadow />
12001208
</div>
12011209
<div className="flex">

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,15 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
10301030
updateHighlights()
10311031
}}
10321032
onFocus={() => setIsFocused(true)}
1033-
onKeyDown={handleKeyDown}
1033+
onKeyDown={(e) => {
1034+
// Handle ESC to cancel in edit mode
1035+
if (isEditMode && e.key === "Escape" && !e.nativeEvent?.isComposing) {
1036+
e.preventDefault()
1037+
onCancel?.()
1038+
return
1039+
}
1040+
handleKeyDown(e)
1041+
}}
10341042
onKeyUp={handleKeyUp}
10351043
onBlur={handleBlur}
10361044
onPaste={handlePaste}
@@ -1071,7 +1079,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
10711079
"resize-none",
10721080
"overflow-x-hidden",
10731081
"overflow-y-auto",
1074-
"pr-9",
1082+
isEditMode ? "pr-[72px]" : "pr-9",
10751083
"flex-none flex-grow",
10761084
"z-[2]",
10771085
"scrollbar-none",

0 commit comments

Comments
 (0)