-
Notifications
You must be signed in to change notification settings - Fork 43
chat: enter key full functionality (fixes #9428) #9445
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
Open
emmanuelbaa
wants to merge
26
commits into
master
Choose a base branch
from
9428-chat-enterKeyFunction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implements the standard chat behavior where the "Enter" key sends the message and "Shift + Enter" creates a new line. - Adds a `keydown` event listener to the chat textarea. - The event handler checks for the "Enter" key press without the "Shift" key. - Replicates the existing form validation from the send button to ensure empty messages or multiple submissions while processing are not allowed.
Implements the standard chat behavior where the "Enter" key sends the message and "Shift + Enter" creates a new line. - Adds a `keydown` event listener to the chat textarea. - The event handler checks for the "Enter" key press without the "Shift" key and sends the message. - Replicates the existing form validation from the send button to ensure empty messages or multiple submissions while processing are not allowed. Additionally, this change improves the user experience by providing immediate feedback when a message is sent. - The chat UI is now updated optimistically, adding the user's message to the conversation list and clearing the input field as soon as the message is sent, rather than waiting for the server response. This makes the chat feel more responsive.
…learning-exchange/planet into 9428-chat-enterKeyFunction
This commit introduces several key improvements to the chat feature to enhance user experience and fix bugs.
1. **Enter-to-Send Functionality:**
- Implements the standard chat behavior where the "Enter" key sends the message and "Shift + Enter" creates a new line.
- Adds a `keydown` event listener to the chat textarea to handle this logic.
- Replicates the existing form validation from the send button to prevent empty messages or multiple submissions.
2. **Immediate UI Feedback (Optimistic Update):**
- The chat UI is now updated optimistically. The user's message is added to the conversation list and the input field is cleared as soon as the message is submitted, rather than waiting for the server response. This makes the chat feel more responsive.
3. **Sidebar Conversation History Fix:**
- Fixes a bug where new conversations were not appearing in the sidebar history until after the first response was received.
- A signal is now sent to the `ChatService` as soon as a message is sent in a new conversation, ensuring the sidebar updates immediately.
- Fixes a subsequent bug where this signal was being sent twice.
4. **UI Rendering Fix:**
- Restores the `role: 'user'` property to the conversation object when performing an optimistic update, preventing potential UI rendering issues for user messages.
Mutugiii
requested changes
Dec 19, 2025
Member
Mutugiii
left a comment
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.
This brings about some regressions in the chat:
- On submit, we see the last created chat instead of the question asked
- Newly created chats are no longer showing up in the sidebar
- Enter submission disregards the chat disabled state
Member
Author
great reviews, i will work on that |
Modify the onKeyDown method in ChatWindowComponent to check the 'disabled' state of the chat before allowing submission via the Enter key. This prevents unintended submissions when the chat input is visually or programmatically disabled.
Refactor submitPrompt() and postSubmit() in ChatWindowComponent to: - Prevent premature clearing of conversation messages for new chats. - Ensure the sidebar is notified correctly when a new chat is created and saved. This addresses regressions where the last asked question was not displaying on submit, and the last chat was not showing in the sidebar.
Member
Author
|
please kindly review again |
This commit re-applies the fix for the issue where pressing Enter would submit a chat message even when the chat input was in a disabled state. The onKeyDown method in ChatWindowComponent now correctly checks the 'disabled' property before allowing submission.
…tempt) Re-addresses the regressions where the last asked question was not displaying on submit and the last chat was not showing in the sidebar. - Modified subscribeToSelectedConversation() to filter out unnecessary re-fetches from the database after a local update, preventing overwrites of the current conversation. - Corrected TypeScript error TS2339 by casting conversationId to any within the filter operator to allow access to the _id property. - Modified submitPrompt() to correctly handle new conversation initiation and postSubmit() to conditionally send new chat signals, preventing double conversation resets and ensuring correct chat display and sidebar updates.
Implements the standard chat behavior where the "Enter" key sends the message and "Shift + Enter" creates a new line. - Adds a `keydown` event listener to the chat textarea. - The event handler checks for the "Enter" key press without the "Shift" key. - Replicates the existing form validation from the send button to ensure empty messages or multiple submissions while processing are not allowed.
Implements the standard chat behavior where the "Enter" key sends the message and "Shift + Enter" creates a new line. - Adds a `keydown` event listener to the chat textarea. - The event handler checks for the "Enter" key press without the "Shift" key and sends the message. - Replicates the existing form validation from the send button to ensure empty messages or multiple submissions while processing are not allowed. Additionally, this change improves the user experience by providing immediate feedback when a message is sent. - The chat UI is now updated optimistically, adding the user's message to the conversation list and clearing the input field as soon as the message is sent, rather than waiting for the server response. This makes the chat feel more responsive.
This commit introduces several key improvements to the chat feature to enhance user experience and fix bugs.
1. **Enter-to-Send Functionality:**
- Implements the standard chat behavior where the "Enter" key sends the message and "Shift + Enter" creates a new line.
- Adds a `keydown` event listener to the chat textarea to handle this logic.
- Replicates the existing form validation from the send button to prevent empty messages or multiple submissions.
2. **Immediate UI Feedback (Optimistic Update):**
- The chat UI is now updated optimistically. The user's message is added to the conversation list and the input field is cleared as soon as the message is submitted, rather than waiting for the server response. This makes the chat feel more responsive.
3. **Sidebar Conversation History Fix:**
- Fixes a bug where new conversations were not appearing in the sidebar history until after the first response was received.
- A signal is now sent to the `ChatService` as soon as a message is sent in a new conversation, ensuring the sidebar updates immediately.
- Fixes a subsequent bug where this signal was being sent twice.
4. **UI Rendering Fix:**
- Restores the `role: 'user'` property to the conversation object when performing an optimistic update, preventing potential UI rendering issues for user messages.
Modify the onKeyDown method in ChatWindowComponent to check the 'disabled' state of the chat before allowing submission via the Enter key. This prevents unintended submissions when the chat input is visually or programmatically disabled.
Refactor submitPrompt() and postSubmit() in ChatWindowComponent to: - Prevent premature clearing of conversation messages for new chats. - Ensure the sidebar is notified correctly when a new chat is created and saved. This addresses regressions where the last asked question was not displaying on submit, and the last chat was not showing in the sidebar.
This commit re-applies the fix for the issue where pressing Enter would submit a chat message even when the chat input was in a disabled state. The onKeyDown method in ChatWindowComponent now correctly checks the 'disabled' property before allowing submission.
…tempt) Re-addresses the regressions where the last asked question was not displaying on submit and the last chat was not showing in the sidebar. - Modified subscribeToSelectedConversation() to filter out unnecessary re-fetches from the database after a local update, preventing overwrites of the current conversation. - Corrected TypeScript error TS2339 by casting conversationId to any within the filter operator to allow access to the _id property. - Modified submitPrompt() to correctly handle new conversation initiation and postSubmit() to conditionally send new chat signals, preventing double conversation resets and ensuring correct chat display and sidebar updates.
…learning-exchange/planet into 9428-chat-enterKeyFunction
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #9428
This commit introduces several key improvements to the chat feature to enhance user experience and fix bugs.
Enter-to-Send Functionality:
keydownevent listener to the chat textarea to handle this logic.Immediate UI Feedback (Optimistic Update):
Sidebar Conversation History Fix:
ChatServiceas soon as a message is sent in a new conversation, ensuring the sidebar updates immediately.UI Rendering Fix:
role: 'user'property to the conversation object when performing an optimistic update, preventing potential UI rendering issues for user messages.