Skip to content

Commit 195f4eb

Browse files
roomote[bot]roomote-agenthannesrudolphdaniel-lxs
authored
feat: add click-to-edit, ESC-to-cancel, and fix padding consistency for chat messages (RooCodeInc#7790)
* 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 RooCodeInc#7788 * fix: adjust padding and layout for ChatTextArea in edit mode * refactor: replace hardcoded pr-[72px] with standard Tailwind pr-20 class --------- Co-authored-by: Roo Code <[email protected]> Co-authored-by: Hannes Rudolph <[email protected]> Co-authored-by: daniel-lxs <[email protected]>
1 parent 76c6745 commit 195f4eb

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,9 +1172,10 @@ export const ChatRowContent = ({
11721172
)
11731173
case "user_feedback":
11741174
return (
1175-
<div className="bg-vscode-editor-background border rounded-xs p-1 overflow-hidden whitespace-pre-wrap">
1175+
<div
1176+
className={`bg-vscode-editor-background border rounded-xs overflow-hidden whitespace-pre-wrap ${isEditing ? "p-0" : "p-1"}`}>
11761177
{isEditing ? (
1177-
<div className="flex flex-col gap-2 p-2">
1178+
<div className="flex flex-col gap-2">
11781179
<ChatTextArea
11791180
inputValue={editedContent}
11801181
setInputValue={setEditedContent}
@@ -1195,7 +1196,15 @@ export const ChatRowContent = ({
11951196
</div>
11961197
) : (
11971198
<div className="flex justify-between">
1198-
<div className="flex-grow px-2 py-1 wrap-anywhere">
1199+
<div
1200+
className="flex-grow px-2 py-1 wrap-anywhere cursor-pointer hover:bg-vscode-list-hoverBackground rounded transition-colors"
1201+
onClick={(e) => {
1202+
e.stopPropagation()
1203+
if (!isStreaming) {
1204+
handleEditClick()
1205+
}
1206+
}}
1207+
title={t("chat:queuedMessages.clickToEdit")}>
11991208
<Mention text={message.text} withShadow />
12001209
</div>
12011210
<div className="flex">

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -903,20 +903,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
903903
return (
904904
<div
905905
className={cn(
906-
"relative",
907-
"flex",
908-
"flex-col",
909-
"gap-1",
910-
"bg-editor-background",
911-
"px-1.5",
912-
"pb-1",
913-
"outline-none",
914-
"border",
915-
"border-none",
916-
"w-[calc(100%-16px)]",
917-
"ml-auto",
918-
"mr-auto",
919-
"box-border",
906+
"relative flex flex-col gap-1 bg-editor-background outline-none border border-none box-border",
907+
isEditMode ? "p-2 w-full" : "px-1.5 pb-1 w-[calc(100%-16px)] ml-auto mr-auto",
920908
)}>
921909
<div className="relative">
922910
<div
@@ -1005,11 +993,12 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
1005993
: isDraggingOver
1006994
? "border-2 border-dashed border-vscode-focusBorder"
1007995
: "border border-transparent",
1008-
"px-[8px]",
1009-
"py-1.5",
1010-
"pr-9",
996+
"pl-2",
997+
"py-2",
998+
isEditMode ? "pr-20" : "pr-9",
1011999
"z-10",
10121000
"forced-color-adjust-none",
1001+
"rounded",
10131002
)}
10141003
style={{
10151004
color: "transparent",
@@ -1030,7 +1019,15 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
10301019
updateHighlights()
10311020
}}
10321021
onFocus={() => setIsFocused(true)}
1033-
onKeyDown={handleKeyDown}
1022+
onKeyDown={(e) => {
1023+
// Handle ESC to cancel in edit mode
1024+
if (isEditMode && e.key === "Escape" && !e.nativeEvent?.isComposing) {
1025+
e.preventDefault()
1026+
onCancel?.()
1027+
return
1028+
}
1029+
handleKeyDown(e)
1030+
}}
10341031
onKeyUp={handleKeyUp}
10351032
onBlur={handleBlur}
10361033
onPaste={handlePaste}
@@ -1054,7 +1051,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
10541051
"text-vscode-editor-font-size",
10551052
"leading-vscode-editor-line-height",
10561053
"cursor-text",
1057-
"py-1.5 px-2",
1054+
"py-2 pl-2",
10581055
isFocused
10591056
? "border border-vscode-focusBorder outline outline-vscode-focusBorder"
10601057
: isDraggingOver
@@ -1071,7 +1068,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
10711068
"resize-none",
10721069
"overflow-x-hidden",
10731070
"overflow-y-auto",
1074-
"pr-9",
1071+
isEditMode ? "pr-20" : "pr-9",
10751072
"flex-none flex-grow",
10761073
"z-[2]",
10771074
"scrollbar-none",
@@ -1080,7 +1077,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
10801077
onScroll={() => updateHighlights()}
10811078
/>
10821079

1083-
<div className="absolute top-1 right-1 z-30">
1080+
<div className="absolute top-2 right-2 z-30">
10841081
<StandardTooltip content={t("chat:enhancePrompt")}>
10851082
<button
10861083
aria-label={t("chat:enhancePrompt")}
@@ -1102,7 +1099,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
11021099
</StandardTooltip>
11031100
</div>
11041101

1105-
<div className="absolute bottom-1 right-1 z-30">
1102+
<div className="absolute bottom-2 right-2 z-30">
11061103
{isEditMode && (
11071104
<StandardTooltip content={t("chat:cancel.title")}>
11081105
<button
@@ -1147,9 +1144,12 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
11471144

11481145
{!inputValue && (
11491146
<div
1150-
className="absolute left-2 z-30 pr-9 flex items-center h-8 font-vscode-font-family text-vscode-editor-font-size leading-vscode-editor-line-height"
1147+
className={cn(
1148+
"absolute left-2 z-30 flex items-center h-8 font-vscode-font-family text-vscode-editor-font-size leading-vscode-editor-line-height",
1149+
isEditMode ? "pr-20" : "pr-9",
1150+
)}
11511151
style={{
1152-
bottom: "0.25rem",
1152+
bottom: "0.75rem",
11531153
color: "color-mix(in oklab, var(--vscode-input-foreground) 50%, transparent)",
11541154
userSelect: "none",
11551155
pointerEvents: "none",

0 commit comments

Comments
 (0)