diff --git a/public/index.html b/public/index.html index 71d3ea172..b97c18e41 100644 --- a/public/index.html +++ b/public/index.html @@ -1792,10 +1792,21 @@
-
+
+
+ +
+
+
+
+
+
-
+
+
+
+
diff --git a/public/script.js b/public/script.js index ae700b92b..ab1f60546 100644 --- a/public/script.js +++ b/public/script.js @@ -3216,7 +3216,9 @@ async function displayPastChats() { const template = $('#past_chat_template .select_chat_block_wrapper').clone(); template.find('.select_chat_block').attr('file_name', fileName); template.find('.avatar img').attr('src', avatarImg); - template.find('.select_chat_block_filename').text(fileName + " (" + file_size + ") (" + chat_items + " messages)"); + template.find('.select_chat_block_filename').text(fileName); + template.find('.chat_file_size').text(" (" + file_size + ")"); + template.find('.chat_messages_num').text(" (" + chat_items + " messages)"); template.find('.select_chat_block_mes').text(mes); template.find('.PastChat_cross').attr('file_name', fileName); @@ -3471,6 +3473,7 @@ function callPopup(text, type, inputValue = '') { break; case "del_world": case "del_group": + case "rename_chat": case "del_chat": default: $("#dialogue_popup_ok").text("Delete"); @@ -3678,6 +3681,8 @@ function isHordeGenerationNotAllowed() { return false; } + + window["SillyTavern"].getContext = function () { return { chat: chat, @@ -4275,7 +4280,7 @@ $(document).ready(function () { setTimeout(function () { $("#option_select_chat").click(); $("#options").hide(); - }, 100); + }, 200); } if (popup_type == "del_ch") { console.log( @@ -4587,6 +4592,37 @@ $(document).ready(function () { $("#renameCharButton").on('click', renameCharacter); + $(document).on("click", ".renameChatButton", async function () { + var old_filenamefull = $(this).closest('.select_chat_block_wrapper').find('.select_chat_block_filename').text(); + + var old_filename = old_filenamefull.substring(0, old_filenamefull.length - 6); + + const popupText = `

Enter the new name for the chat:

+ !!Using an existing filename will overwrite that file!!
+ No need to add '.jsonl' at the end.
+
`; + let newName = await callPopup(popupText, 'input', old_filename); + + if (!newName) { + console.log('no new name found, aborting'); + return; + } + + const newMetadata = { main_chat: characters[this_chid].chat }; + await saveChat(newName, newMetadata); + await saveChat(); //is this second save needed? + chat_file_for_del = old_filenamefull; + popup_type = 'del_chat'; + + setTimeout(function () { + callPopup('Confirm Delete of Old File After Rename'); + }, 200); + + + + + }); + $("#talkativeness_slider").on("input", function () { if (menu_type == "create") { create_save_talkativeness = $("#talkativeness_slider").val(); diff --git a/public/style.css b/public/style.css index 8c4eb8680..dbf85f5ea 100644 --- a/public/style.css +++ b/public/style.css @@ -1443,7 +1443,7 @@ input[type=search]:focus::-webkit-search-cancel-button { .avatar_div .menu_button, .form_create_bottom_buttons_block .menu_button, -#select_chat_popup .menu_button { +#select_chat_import .menu_button { font-weight: bold; padding: 5px; margin: 0; @@ -1639,11 +1639,21 @@ input[type=search]:focus::-webkit-search-cancel-button { margin: 0; } -#form_rename_world { +#form_rename_world, +#form_rename_chat { display: flex; align-items: center; - margin-right: 50px; + opacity: 0.8; + gap: 5px; +} + +#form_rename_world { + margin-right: 50px; +} + +#form_rename_chat { + flex: 1; } #form_rename_world input[type="submit"] { @@ -2343,12 +2353,26 @@ h5 { } .select_chat_block .avatar { - grid-row: span 2; } -.select_chat_block_filename { +#select_chat_name_wrapper { + display: flex; + gap: 5px; + flex-wrap: wrap; +} + +.select_chat_block_filename_item { opacity: 0.5; + width: fit-content; +} + +.select_chat_block_filename { + flex: 1 +} + +.renameChatButton { + cursor: pointer; } .select_chat_block_mes {