Skip to content

Commit f7eddbf

Browse files
Chris Hassonhassoncs
authored andcommitted
fix(chat): Prevent input clearing when clicking chat buttons
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
1 parent d62a260 commit f7eddbf

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
@@ -622,12 +622,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
622622
text: trimmedInput,
623623
images: images,
624624
})
625+
// Clear input state after sending
626+
setInputValue("")
627+
setSelectedImages([])
625628
} else {
626629
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonClicked" })
627630
}
628-
// Clear input state after sending
629-
setInputValue("")
630-
setSelectedImages([])
631631
break
632632
case "completion_result":
633633
case "resume_completed_task":
@@ -677,13 +677,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
677677
text: trimmedInput,
678678
images: images,
679679
})
680+
// Clear input state after sending
681+
setInputValue("")
682+
setSelectedImages([])
680683
} else {
681684
// Responds to the API with a "This operation failed" and lets it try again
682685
vscode.postMessage({ type: "askResponse", askResponse: "noButtonClicked" })
683686
}
684-
// Clear input state after sending
685-
setInputValue("")
686-
setSelectedImages([])
687687
break
688688
case "command_output":
689689
vscode.postMessage({ type: "terminalOperation", terminalOperation: "abort" })
@@ -1802,7 +1802,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
18021802
appearance="primary"
18031803
disabled={!enableButtons}
18041804
className={secondaryButtonText ? "flex-1 mr-[6px]" : "flex-[2] mr-0"}
1805-
onClick={() => handlePrimaryButtonClick(inputValue, selectedImages)}>
1805+
onClick={() => handlePrimaryButtonClick()}>
18061806
{primaryButtonText}
18071807
</VSCodeButton>
18081808
</StandardTooltip>
@@ -1824,7 +1824,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
18241824
appearance="secondary"
18251825
disabled={!enableButtons && !(isStreaming && !didClickCancel)}
18261826
className={isStreaming ? "flex-[2] ml-0" : "flex-1 ml-[6px]"}
1827-
onClick={() => handleSecondaryButtonClick(inputValue, selectedImages)}>
1827+
onClick={() => handleSecondaryButtonClick()}>
18281828
{isStreaming ? t("chat:cancel.title") : secondaryButtonText}
18291829
</VSCodeButton>
18301830
</StandardTooltip>

0 commit comments

Comments
 (0)