-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix: Preserve chat input when queueing messages #7869
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
Conversation
- Modified ChatView.tsx to not clear input field when queueing messages - Only clear selected images when queueing, preserving typed text - Input will be cleared when message is actually sent, not when queued - Fixes issue where unsent text was wiped when queued messages were sent Fixes #7861
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.
Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.
| console.log("queueMessage", text, images) | ||
| vscode.postMessage({ type: "queueMessage", text, images }) | ||
| setInputValue("") | ||
| // Don't clear the input when queueing - let the user continue typing |
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.
While this fix correctly addresses the issue, consider adding a test to verify that input text is preserved when messages are queued. The existing tests in ChatView.spec.tsx don't specifically cover this behavior.
You could add a test like:
| // Don't clear the input when queueing - let the user continue typing | |
| it("preserves input text when queueing messages", async () => { | |
| // Test that setInputValue("") is not called when sendingDisabled is true | |
| // and that only setSelectedImages([]) is called | |
| }) |
| if (sendingDisabled) { | ||
| try { | ||
| console.log("queueMessage", text, images) | ||
| vscode.postMessage({ type: "queueMessage", text, images }) |
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.
Consider this edge case: What happens if the user modifies the text after queueing but before the message is sent? The current implementation preserves the input, which is correct, but users might not realize their queued message contains different text than what's currently displayed.
Maybe the QueuedMessages component could show a preview of the queued text to make this clearer?
| vscode.postMessage({ type: "queueMessage", text, images }) | ||
| setInputValue("") | ||
| // Don't clear the input when queueing - let the user continue typing | ||
| // The input will be cleared when the message is actually sent |
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.
Nice comment explaining the behavior! Consider also documenting this input preservation feature in user-facing documentation or tooltips so users understand that they can continue typing while messages are queued.
Summary
This PR fixes issue #7861 where unsent text in the chatbox was being wiped when a queued message was sent.
Problem
When sending is disabled and messages are queued (e.g., waiting for approval), if a user:
The chatbox would be cleared, losing the unsent text the user was typing.
Solution
Modified
ChatView.tsxto not clear the input field when queueing messages. Now:Changes
handleSendMessagefunction inwebview-ui/src/components/chat/ChatView.tsxsetInputValue("")call whensendingDisabledis trueTesting
Related Issue
Fixes #7861
Important
Fixes issue #7861 by preserving chat input in
ChatView.tsxwhen messages are queued, clearing input only when the message is sent.ChatView.tsxwhen messages are queued.handleSendMessageinChatView.tsxto removesetInputValue("")whensendingDisabledis true.This description was created by
for 26befa6. You can customize this summary. It will automatically update as commits are pushed.