-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
fix: textArea is disabled after chatHistory is loaded #180
fix: textArea is disabled after chatHistory is loaded #180
Conversation
@tjtanjin This is strange. Cypress test is passed on my machine with React 19 RC. Please let me know what I can do. 😅 |
Test cases are a little flaky. A re-run fixed it. With regard to your PR, I believe this will re-introduce the bugs fixed in v2.0.0-beta.15 🥹 Your current approach means that when chat history is loaded, the text area will be enabled/disabled based on settings. This is not always the case, because a conversation block also allows a |
Hey @yaminmomo15, I think it's worth considering the context of this feature: Firstly, the behavior we want to achieve is for text area to be disabled when chat history is loading, and then for it to resume its previous state once loading is done. This is so users don't end up sending stuffs into the chat window while chat history messages are also being added, which may have implications on scroll behavior. This was true in the early days of the library, but it has been a long time since then. Regardless, it is important to note that the previous state of the text area can be enabled or disabled, and this depends on the following:
This is why this existing PR will break, as it only relies on point 2. I've said a bunch above but instead of the existing solution, let's think over it again. What we're trying to achieve here is this:
To achieve this, we don't actually have to disable the text area. It suffices for us to prevent the users from sending input into the chat. There are currently 4 kinds of input (checkbox, options, text area and file uploads). Instead of disabling the text area (which is not a great experience if the user wants to just continue typing without sending yet), we catch and block submission actions (mainly via checking of
The checks can be targeted at blocking the above actions, but this involves looking into them which may be a fair bit of work if you are unfamiliar with the repository. That said, this is a cleaner and less intrusive approach, because a user should still be allowed to type even while chat history is loading. Let me know if you're still keen to explore this, because it will take some effort. Otherwise I can take this up as well. Appreciate the bug report! |
@tjtanjin There are other things worth noting. ChatHistoryButton will only appear after user refreshed the page. At the moment, refreshing the page will also reset the conversation path to "start" so the new approach only makes sense if there is a feature to continue the conversion. If you want to go with the new approach, it is best if I hand this back to you as it needs other features. |
I tested again and got your point now. I overlooked that fact that the ChatHistoryButton can also be clicked when the user is half way through a new conversion. chatDisabled also needs to be considered. I think it is better to go with the new approach. I will try it first before handing back to you. @tjtanjin |
Hey @yaminmomo15, before you try the new approach, can you do me a favor:
I say this because the decision to have this disable behavior with chat history was taken a long time ago and I frankly can't recall the actual reason for it. If there are no buggy behaviors, this might not even be necessary anymore. Edit: I'm happy to talk more on discord if this warrants a deeper discussion, if you have yet to join the discord and would prefer to talk there, feel free to reach out. |
Sure, I will disable that behavior and test to see if it can be removed without having bugs. |
I tested with the textAreaDisabled feature removed when chat history is loading. User interaction can continue normally and doesn't affect the loading chat history. And, loading the chat history doesn't interfere with the user interaction(typing, checkbox, options, sending, and file upload) either, so it makes sense to remove the feature to disable the user actions when chat history is loading. I have updated the PR with the changes. Please take a look and let me know. @tjtanjin |
c6cee87
to
574a8ff
Compare
@tjtanjin it's ready for review now. |
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.
LGTM, thank you for taking the time to check 😊
Description
setTextAreaDisabled(settings.chatInput?.disabled)
is not called when the chatHistory is loaded.Closes #172
What change does this PR introduce?
useEffect()
to callsetTextAreaDisabled(false)
after chatHistory is done loading.Please select the relevant option(s).
What is the proposed approach?
Checklist: