Add a React context to persist the chat input of each site in memory.
Update the logic of Assistant input to save/restore the chat input when navigating to other sites. As well as restore the input when navigating to the Assistant tab.
Add unit test to cover the case solved by the PR.
Bonus: Rename clearInput handlers/functions to clearConversation, which I feel is more accurate for the logic.
Testing Instructions
Run the app with the command npm start.
Log in to WPCOM with an account that has access to the Assistant feature (e.g. A8C account).
Select a site (Site A).
Navigate to the Assistant tab.
Observe the chat input is empty.
Type a prompt but don't submit it.
Navigate to another tab (e.g. Overview tab).
Navigate back to the Assistant tab.
Observe the previously typed prompt remains in the chat input.
Select another site (Site B).
Observe the chat input is empty.
Type a prompt but don't submit it.
Select Site A.
Observe the prompt typed for that site is in the chat input.
Select Site B.
Observe the prompt typed for that site is in the chat input.
Clear the conversation.
Observe the chat input is empty.
Pre-merge Checklist
[x] Have you checked for TypeScript, React or other console errors?
Related to 9208-gh-Automattic/dotcom-forge.
Proposed Changes
clearInput
handlers/functions toclearConversation
, which I feel is more accurate for the logic.Testing Instructions
npm start
.Pre-merge Checklist