Merge pull request #1975 from Wolfsblvt/persona-switch-consistency

Persona retrigger first message consistency fix
This commit is contained in:
Cohee
2024-03-27 15:18:37 +02:00
committed by GitHub
2 changed files with 11 additions and 3 deletions

View File

@@ -5735,6 +5735,12 @@ export function setUserAvatar(imgfile) {
$('.zoomed_avatar[forchar]').remove(); $('.zoomed_avatar[forchar]').remove();
} }
export function retriggerFirstMessageOnEmptyChat() {
if (this_chid >= 0 && !selected_group && chat.length === 1) {
$('#firstmessage_textarea').trigger('input');
}
}
async function uploadUserAvatar(e) { async function uploadUserAvatar(e) {
const file = e.target.files[0]; const file = e.target.files[0];
@@ -8469,9 +8475,7 @@ jQuery(async function () {
setUserAvatar(imgfile); setUserAvatar(imgfile);
// force firstMes {{user}} update on persona switch // force firstMes {{user}} update on persona switch
if (this_chid >= 0 && !selected_group && chat.length === 1) { retriggerFirstMessageOnEmptyChat();
$('#firstmessage_textarea').trigger('input');
}
}); });
$(document).on('click', '#user_avatar_block .avatar_upload', function () { $(document).on('click', '#user_avatar_block .avatar_upload', function () {
$('#avatar_upload_overwrite').val(''); $('#avatar_upload_overwrite').val('');
@@ -9575,6 +9579,7 @@ jQuery(async function () {
const userName = String($('#your_name').val()).trim(); const userName = String($('#your_name').val()).trim();
setUserName(userName); setUserName(userName);
await updatePersonaNameIfExists(user_avatar, userName); await updatePersonaNameIfExists(user_avatar, userName);
retriggerFirstMessageOnEmptyChat();
}); });
$('#sync_name_button').on('click', async function () { $('#sync_name_button').on('click', async function () {

View File

@@ -22,6 +22,7 @@ import {
name1, name1,
reloadCurrentChat, reloadCurrentChat,
removeMacros, removeMacros,
retriggerFirstMessageOnEmptyChat,
saveChatConditional, saveChatConditional,
sendMessageAsUser, sendMessageAsUser,
sendSystemMessage, sendSystemMessage,
@@ -1340,12 +1341,14 @@ function setNameCallback(_, name) {
for (let persona of Object.values(power_user.personas)) { for (let persona of Object.values(power_user.personas)) {
if (persona.toLowerCase() === name.toLowerCase()) { if (persona.toLowerCase() === name.toLowerCase()) {
autoSelectPersona(name); autoSelectPersona(name);
retriggerFirstMessageOnEmptyChat();
return; return;
} }
} }
// Otherwise, set just the name // Otherwise, set just the name
setUserName(name); //this prevented quickReply usage setUserName(name); //this prevented quickReply usage
retriggerFirstMessageOnEmptyChat();
} }
async function setNarratorName(_, text) { async function setNarratorName(_, text) {