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
commit d53e645323
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -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 () {

View File

@ -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) {