diff --git a/public/script.js b/public/script.js index 38ed270cd..e56f4ec33 100644 --- a/public/script.js +++ b/public/script.js @@ -5735,6 +5735,12 @@ export function setUserAvatar(imgfile) { $('.zoomed_avatar[forchar]').remove(); } +export function retriggerFirstMessageOnEmptyChat() { + if (this_chid >= 0 && !selected_group && chat.length === 1) { + $('#firstmessage_textarea').trigger('input'); + } +} + async function uploadUserAvatar(e) { const file = e.target.files[0]; @@ -8469,9 +8475,7 @@ jQuery(async function () { setUserAvatar(imgfile); // force firstMes {{user}} update on persona switch - if (this_chid >= 0 && !selected_group && chat.length === 1) { - $('#firstmessage_textarea').trigger('input'); - } + retriggerFirstMessageOnEmptyChat(); }); $(document).on('click', '#user_avatar_block .avatar_upload', function () { $('#avatar_upload_overwrite').val(''); @@ -9575,6 +9579,7 @@ jQuery(async function () { const userName = String($('#your_name').val()).trim(); setUserName(userName); await updatePersonaNameIfExists(user_avatar, userName); + retriggerFirstMessageOnEmptyChat(); }); $('#sync_name_button').on('click', async function () { diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 76d4b11db..a6e0020ef 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -22,6 +22,7 @@ import { name1, reloadCurrentChat, removeMacros, + retriggerFirstMessageOnEmptyChat, saveChatConditional, sendMessageAsUser, sendSystemMessage, @@ -1340,12 +1341,14 @@ function setNameCallback(_, name) { for (let persona of Object.values(power_user.personas)) { if (persona.toLowerCase() === name.toLowerCase()) { autoSelectPersona(name); + retriggerFirstMessageOnEmptyChat(); return; } } // Otherwise, set just the name setUserName(name); //this prevented quickReply usage + retriggerFirstMessageOnEmptyChat(); } async function setNarratorName(_, text) {