var currentChatName = null; function setChatList() { var selectedChat = null; var chatList = gradioApp().querySelector('fieldset#history-select-dropdown'); selectedChat = chatList.querySelector(".wrap label.selected") if (!selectedChat) { currentChatName = null; return; } // if (userLogged) { // currentChatName = username + "/" + selectedChat.querySelector('span').innerText; // } else { currentChatName = selectedChat.querySelector('span').innerText; // } if (selectedChat.classList.contains('added-chat-btns')) { return; } chatList.querySelector('.chat-selected-btns')?.remove(); // remove old buttons chatList.querySelectorAll('.added-chat-btns').forEach(chat => chat.classList.remove('added-chat-btns')); var ChatSelectedBtns = document.createElement('div'); ChatSelectedBtns.classList.add('chat-selected-btns'); selectedChat.classList.add('added-chat-btns'); ChatSelectedBtns.innerHTML = selectedChatBtns; var renameBtn = ChatSelectedBtns.querySelector('#history-rename-btn'); renameBtn.addEventListener('click', function () { gradioApp().querySelector('#gr-history-save-btn').click(); }); var deleteBtn = ChatSelectedBtns.querySelector('#history-delete-btn'); deleteBtn.addEventListener('click', function () { gradioApp().querySelector('#gr-history-delete-btn').click(); }); selectedChat.appendChild(ChatSelectedBtns); return; } function saveChatHistory(a, b, c, d) { var fileName = b; fileName = prompt(renameChat_i18n, b); if (fileName && fileName.trim() !== "") { return [a, fileName, c, d]; } else { return [a, "", c, d]; } } const selectedChatBtns = ` `