-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: add click-to-edit, ESC-to-cancel, and fix padding consistency for chat messages #7790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1172,9 +1172,10 @@ export const ChatRowContent = ({ | |||||||||||
| ) | ||||||||||||
| case "user_feedback": | ||||||||||||
| return ( | ||||||||||||
| <div className="bg-vscode-editor-background border rounded-xs p-1 overflow-hidden whitespace-pre-wrap"> | ||||||||||||
| <div | ||||||||||||
| className={`bg-vscode-editor-background border rounded-xs overflow-hidden whitespace-pre-wrap ${isEditing ? "p-0" : "p-1"}`}> | ||||||||||||
| {isEditing ? ( | ||||||||||||
| <div className="flex flex-col gap-2 p-2"> | ||||||||||||
| <div className="flex flex-col gap-2"> | ||||||||||||
| <ChatTextArea | ||||||||||||
| inputValue={editedContent} | ||||||||||||
| setInputValue={setEditedContent} | ||||||||||||
|
|
@@ -1195,7 +1196,15 @@ export const ChatRowContent = ({ | |||||||||||
| </div> | ||||||||||||
| ) : ( | ||||||||||||
| <div className="flex justify-between"> | ||||||||||||
| <div className="flex-grow px-2 py-1 wrap-anywhere"> | ||||||||||||
| <div | ||||||||||||
| className="flex-grow px-2 py-1 wrap-anywhere cursor-pointer hover:bg-vscode-list-hoverBackground rounded transition-colors" | ||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding an
Suggested change
|
||||||||||||
| onClick={(e) => { | ||||||||||||
| e.stopPropagation() | ||||||||||||
| if (!isStreaming) { | ||||||||||||
| handleEditClick() | ||||||||||||
| } | ||||||||||||
| }} | ||||||||||||
| title={t("chat:queuedMessages.clickToEdit")}> | ||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reuses the queued messages translation key. Would it be clearer to have a dedicated key like |
||||||||||||
| <Mention text={message.text} withShadow /> | ||||||||||||
| </div> | ||||||||||||
| <div className="flex"> | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -903,20 +903,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( | |||||
| return ( | ||||||
| <div | ||||||
| className={cn( | ||||||
| "relative", | ||||||
| "flex", | ||||||
| "flex-col", | ||||||
| "gap-1", | ||||||
| "bg-editor-background", | ||||||
| "px-1.5", | ||||||
| "pb-1", | ||||||
| "outline-none", | ||||||
| "border", | ||||||
| "border-none", | ||||||
| "w-[calc(100%-16px)]", | ||||||
| "ml-auto", | ||||||
| "mr-auto", | ||||||
| "box-border", | ||||||
| "relative flex flex-col gap-1 bg-editor-background outline-none border border-none box-border", | ||||||
| isEditMode ? "p-2 w-full" : "px-1.5 pb-1 w-[calc(100%-16px)] ml-auto mr-auto", | ||||||
| )}> | ||||||
| <div className="relative"> | ||||||
| <div | ||||||
|
|
@@ -1005,11 +993,12 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( | |||||
| : isDraggingOver | ||||||
| ? "border-2 border-dashed border-vscode-focusBorder" | ||||||
| : "border border-transparent", | ||||||
| "px-[8px]", | ||||||
| "py-1.5", | ||||||
| "pr-9", | ||||||
| "pl-2", | ||||||
| "py-2", | ||||||
| isEditMode ? "pr-[72px]" : "pr-9", | ||||||
| "z-10", | ||||||
| "forced-color-adjust-none", | ||||||
| "rounded", | ||||||
| )} | ||||||
| style={{ | ||||||
| color: "transparent", | ||||||
|
|
@@ -1030,7 +1019,15 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( | |||||
| updateHighlights() | ||||||
| }} | ||||||
| onFocus={() => setIsFocused(true)} | ||||||
| onKeyDown={handleKeyDown} | ||||||
| onKeyDown={(e) => { | ||||||
| // Handle ESC to cancel in edit mode | ||||||
| if (isEditMode && e.key === "Escape" && !e.nativeEvent?.isComposing) { | ||||||
| e.preventDefault() | ||||||
| onCancel?.() | ||||||
| return | ||||||
| } | ||||||
| handleKeyDown(e) | ||||||
| }} | ||||||
| onKeyUp={handleKeyUp} | ||||||
| onBlur={handleBlur} | ||||||
| onPaste={handlePaste} | ||||||
|
|
@@ -1054,7 +1051,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( | |||||
| "text-vscode-editor-font-size", | ||||||
| "leading-vscode-editor-line-height", | ||||||
| "cursor-text", | ||||||
| "py-1.5 px-2", | ||||||
| "py-2 pl-2", | ||||||
| isFocused | ||||||
| ? "border border-vscode-focusBorder outline outline-vscode-focusBorder" | ||||||
| : isDraggingOver | ||||||
|
|
@@ -1071,7 +1068,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>( | |||||
| "resize-none", | ||||||
| "overflow-x-hidden", | ||||||
| "overflow-y-auto", | ||||||
| "pr-9", | ||||||
| isEditMode ? "pr-[72px]" : "pr-9", | ||||||
|
||||||
| isEditMode ? "pr-[72px]" : "pr-9", | |
| isEditMode ? "pr-[4.5rem]" : "pr-9", |
This would make the spacing more maintainable and consistent with the design system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clickable message text container now calls handleEditClick correctly. Consider adding accessibility attributes (e.g., role='button' and an appropriate aria-label) to improve keyboard navigation and screen reader support.