fix(frontend): improve the <Input /> component
This rework of the current <Input /> component addresses three main issues.
-
It is completely independent, reusable, and no longer tied to the Redux state and dispatch, namely the
sendChatMessagedispatcher andinitializedfield. It is worth noting that before this change, theinitializedproperty was retrieved twice, once in the<Input />component, and another time in its parent. -
It is well tested (actually built via TDD) and covers all the cases the previous component tried to. I say tried to because there was a bug where the user could still send messages BEFORE the agent initialized via the "Enter" key (only the button itself was disabled during initialization, not the
textarea) -
It removes the need for the
useInputCompositionhook which at the time only managed one state and no side-effect, which means overall reduced complexity
It was not my initial motivation to re-create the component, but while trying to create the component tests for <ChatInterface /> and its children, I found that the components were overly complex, which in turn makes in more difficult to test and (more importantly) extend.
I propose this change, and if accepted, I will continue to rebuild the components alongside their tests in a way that will make it easy to understand and expand upon. Beginning with <ChatInterface />