Skip to content

Commit 08ccbea

Browse files
hassoncsChris Hasson
andauthored
fix(chat): Prevent input clearing when clicking chat buttons (#1521)
The chat box is no longer cleared when clicking buttons Previously, we had a bug where if either of the buttons in the agent chat was clicked, the ChatTextArea would get cleared. Now, the text box will only get cleared if the message is sent as part of the response. Moved input clearing logic to only execute when a message is successfully sent, preventing the input field from clearing prematurely when clicking "yes" or "no" buttons in the chat interface. This improves user experience by retaining the input content if an action fails or requires further interaction Fixes #1520 Co-authored-by: Chris Hasson <[email protected]>
1 parent b7585ea commit 08ccbea

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

.changeset/calm-pears-fry.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"kilo-code": patch
3+
---
4+
5+
The chat box is no longer cleared when clicking buttons
6+
7+
Previously, if either of the buttons in the agent chat was clicked, the ChatTextArea would get cleared. Now, the ChatTextArea will only get cleared if a message is sent as part of the response.

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
658658
text: trimmedInput,
659659
images: images,
660660
})
661+
// Clear input state after sending
662+
setInputValue("")
663+
setSelectedImages([])
661664
} else {
662665
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonClicked" })
663666
}
664-
// Clear input state after sending
665-
setInputValue("")
666-
setSelectedImages([])
667667
break
668668
case "completion_result":
669669
case "resume_completed_task":
@@ -721,13 +721,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
721721
text: trimmedInput,
722722
images: images,
723723
})
724+
// Clear input state after sending
725+
setInputValue("")
726+
setSelectedImages([])
724727
} else {
725728
// Responds to the API with a "This operation failed" and lets it try again
726729
vscode.postMessage({ type: "askResponse", askResponse: "noButtonClicked" })
727730
}
728-
// Clear input state after sending
729-
setInputValue("")
730-
setSelectedImages([])
731731
break
732732
case "command_output":
733733
vscode.postMessage({ type: "terminalOperation", terminalOperation: "abort" })
@@ -1909,7 +1909,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
19091909
appearance="primary"
19101910
disabled={!enableButtons}
19111911
className={secondaryButtonText ? "flex-1 mr-[6px]" : "flex-[2] mr-0"}
1912-
onClick={() => handlePrimaryButtonClick(inputValue, selectedImages)}>
1912+
onClick={() => handlePrimaryButtonClick()}>
19131913
{primaryButtonText}
19141914
</VSCodeButton>
19151915
</StandardTooltip>
@@ -1931,7 +1931,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
19311931
appearance="secondary"
19321932
disabled={!enableButtons && !(isStreaming && !didClickCancel)}
19331933
className={isStreaming ? "flex-[2] ml-0" : "flex-1 ml-[6px]"}
1934-
onClick={() => handleSecondaryButtonClick(inputValue, selectedImages)}>
1934+
onClick={() => handleSecondaryButtonClick()}>
19351935
{isStreaming ? t("chat:cancel.title") : secondaryButtonText}
19361936
</VSCodeButton>
19371937
</StandardTooltip>

0 commit comments

Comments
 (0)