nlux icon indicating copy to clipboard operation
nlux copied to clipboard

Chat UI Messages and Avatar re-render on every keystroke

Open lohit8846 opened this issue 1 year ago β€’ 3 comments

We are seeing issues with the Chat UI component re-rendering every time a character is typed into the input box. This is causing both the Avatar and ResponseRenderer to to render and it's an unusable UI since the avatar image needs to reload and Response renders again

@salmenus This is similar the issue reported here https://github.com/nlkitai/nlux/issues/112 but the extend of the issue is greater than just avatar as even for any response rendering, this causes issues

I did a deeper dive using a react profiler and found the reason why memo of any kind is not working. I was able to confirm the issue using this basic react playground example to make sure it was not any code that is specific to me

https://docs.nlkit.com/nlux/examples/react-js-ai-assistant

The profiler shows that on every key press this hook is causing issues and the reason react.memo does not work is because by the time it gets to Avatar and Renderer. It says "This is the first time component rendered" So memo does not work. This indicates the library has an issue with handling the keystrokes

CleanShot 2024-07-28 at 10 37 08@2x

CleanShot 2024-07-28 at 10 36 44@2x

lohit8846 avatar Jul 28 '24 17:07 lohit8846

Thanks for reporting this issue @lohit8846 and for detailed description. I'm investigating.

salmenus avatar Jul 31 '24 14:07 salmenus

Hi Salmenus, du you have Fix for this Issue? Thank you very much

wissam-coder avatar Feb 12 '25 09:02 wissam-coder

Hello, is this project overall still maintained? I also am encountering this issue with custom Renderer

dom-dashbot avatar Aug 15 '25 22:08 dom-dashbot