in plugins/amazonq/mynah-ui/src/mynah-ui/ui/main.ts [505:557]
onCodeScanMessageReceived(tabID: string, chatItem: ChatItem, isLoading: boolean, clearPreviousItemButtons?: boolean, runReview?: boolean) {
if (runReview) {
quickActionHandler.handleCommand({ command: "/review" }, "")
return
}
if (chatItem.type === ChatItemType.ANSWER_PART) {
mynahUI.updateLastChatAnswer(tabID, {
...(chatItem.messageId !== undefined ? { messageId: chatItem.messageId } : {}),
...(chatItem.canBeVoted !== undefined ? { canBeVoted: chatItem.canBeVoted } : {}),
...(chatItem.codeReference !== undefined ? { codeReference: chatItem.codeReference } : {}),
...(chatItem.body !== undefined ? { body: chatItem.body } : {}),
...(chatItem.relatedContent !== undefined ? { relatedContent: chatItem.relatedContent } : {}),
...(chatItem.formItems !== undefined ? { formItems: chatItem.formItems } : {}),
...(chatItem.buttons !== undefined ? { buttons: chatItem.buttons } : { buttons: [] }),
// For loading animation to work, do not update the chat item type
...(chatItem.followUp !== undefined ? { followUp: chatItem.followUp } : {}),
})
if (!isLoading) {
mynahUI.updateStore(tabID, {
loadingChat: false,
})
} else {
mynahUI.updateStore(tabID, {
cancelButtonWhenLoading: false
})
}
}
if (
chatItem.type === ChatItemType.PROMPT ||
chatItem.type === ChatItemType.ANSWER_STREAM ||
chatItem.type === ChatItemType.ANSWER
) {
if (chatItem.followUp === undefined && clearPreviousItemButtons === true) {
mynahUI.updateLastChatAnswer(tabID, {
buttons: [],
followUp: { options: [] },
})
}
mynahUI.addChatItem(tabID, chatItem)
mynahUI.updateStore(tabID, {
loadingChat: chatItem.type !== ChatItemType.ANSWER
})
if (chatItem.type === ChatItemType.PROMPT) {
tabsStorage.updateTabStatus(tabID, 'busy')
} else if (chatItem.type === ChatItemType.ANSWER) {
tabsStorage.updateTabStatus(tabID, 'free')
}
}
},