Use {{#each}}
key to provide component stability for AiAssistantPastSessionsList
#1795
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.
The issue here is that in the
host/app/components/ai-assistant/panel.gts
module, theAiAssistantPanel.aiSessionsRooms
getter. Specifically this getter returns a different array instance each time it's recomputed so that there is no component stability for theAIPastSessionsList
component that consumes this as an argument. each time there is a matrix event that is received (which happens via the /sync calls), a wholly new array is created, and hence the AIPastSessionsList component's {{#each}} is re-rendered for all the items in the array. The solution is to use thekey
property of the {{#each}} helper to guide ember on how to stabilize the rerenders, so that it knows what is new and what is the same in the array.Before:
![screencast 2024-10-30 09-22-56](https://private-user-images.githubusercontent.com/61075/385844319-73f3782a-f8c6-4338-8a7e-759e40b623b5.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNDQ0NzYsIm5iZiI6MTczOTI0NDE3NiwicGF0aCI6Ii82MTA3NS8zODU4NDQzMTktNzNmMzc4MmEtZjhjNi00MzM4LThhN2UtNzU5ZTQwYjYyM2I1LmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDAzMjI1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM4YTQyMGM5MGExOTI3M2E1MTdlMzAxODNlOWI2NjM4ZDA5MzkwZjM2YjhjYjRhMmRmODY4MGI4OWZlYzdlZDcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.aJ0fRDgt5YVaWrJYwdZnr5LjirXmWRswQR4RH8SVL0c)
After:
![thinking](https://private-user-images.githubusercontent.com/61075/385843924-65688e83-c33a-4d0f-81b5-09cd0816bd49.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNDQ0NzYsIm5iZiI6MTczOTI0NDE3NiwicGF0aCI6Ii82MTA3NS8zODU4NDM5MjQtNjU2ODhlODMtYzMzYS00ZDBmLTgxYjUtMDljZDA4MTZiZDQ5LmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDAzMjI1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0YzY5Zjg1MGE1OTlmZTFjYTUxYzQ3YjU4ZGQ2ZmJhZmM0MGNjZDUzNzEwMWRmNjIyZGRkYmRhNTQxMDM3NTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.wAeAv66h_hyf6w-9KKbguKulC4tsOOe10YNB_elDo1c)