Currently, the app will crash if you attempt to create a sidebar from a CHANGE_ROLE robotext message. This is because when attempting to create the role, the threadInfo passed into robotextForMessageInfo from chat-selectors.js is undefined. The reason for this is in a pending sidebar, if you check the threadID, it is something like pending/sidebar/256|90231. Here, the 256|90231 corresponds to the source message that the sidebar is being created from, i.e. the message that the user clicks 'create thread' on.
To resolve this, we want to extend the RobotextParams to include a potentially null parentThreadInfo, and modify the call site in chat-selectors.js. To get the parentThreadInfo, we'd do the following:
- Parse out the source message ID from the pending sidebar thread ID
- Access messageStore.messages for the source message
- Read the threadID from the source message info
- Access the ThreadInfo from the threadInfos object using the newly found threadID
With this, we will now be able to access either the regular threadInfo or the parentThreadInfo in the CHANGE_ROLE message spec, no longer crashing the app. We can now re-allow sidebars to be created from CHANGE_ROLE messages as well.
One thing to note is the other callsite for robotextForMessageInfo is in getMessageTitle. Though when looking into what threadInfo is passed into it, it already receives the parentThreadInfo from createPendingSidebar. So I don't think we should have to update anything there.