Update persona toasts

beced225a3cce6a5aad964f013c1d2cf79d9273b

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +31 -26Showing whitespace changes
public/scripts/personas.js+31 -26
@@ -670,13 +670,16 @@ async function bindUserNameToPersona(e) {
670670function selectCurrentPersona() {
671671 const personaName = power_user.personas[user_avatar];
672672 if (personaName) {
673673 const lockedPersonahasDifferentChatLock = chat_metadata['persona'] && chat_metadata['persona'] !== user_avatar;
674- if (lockedPersona && lockedPersona !== user_avatar && power_user.persona_show_notifications) {
674+ const hasDifferentDefaultLock = power_user.default_persona && power_user.default_persona !== user_avatar;
675- toastr.info(
675+
676- t`To permanently set "${personaName}" as the selected persona, unlock and relock it using the "Lock" button. Otherwise, the selection resets upon reloading the chat.`,
676+ if (hasDifferentChatLock || (!chat_metadata['persona'] && hasDifferentDefaultLock)) {
677- t`This chat is locked to a different persona (${power_user.personas[lockedPersona]}).`,
677+ const message = t`A different persona is locked to this chat, or you have a different default persona set. The currently selected persona will only be temporary, and resets on reload. Consider locking this persona to the chat if you want to permanently use it.`
678- { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true },
678+ + '<br /><br />'
679- );
679+ + t`Current Persona: ${power_user.personas[user_avatar]}`
680+ + (hasDifferentChatLock ? '<br />' + t`Chat persona: ${power_user.personas[chat_metadata['persona']]}` : '')
681+ + (hasDifferentDefaultLock ? '<br />' + t`Default persona: ${power_user.personas[power_user.default_persona]}` : '');
682+ toastr.info(message, t`Temporary Persona`, { escapeHtml: false, timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });
680683 }
681684
682685 if (personaName !== name1) {
@@ -715,7 +718,7 @@ function selectCurrentPersona() {
715718 chat_metadata['persona'] = user_avatar;
716719 console.log(`Auto locked persona to ${user_avatar}`);
717720 if (power_user.persona_show_notifications) {
718721 toastr.info(`Auto locked persona ${personaName} to current chat`, t`Persona Auto Lock`);
719722 }
720723 saveMetadataDebounced();
721724 }
@@ -823,7 +826,7 @@ async function lockPersona(type = 'chat') {
823826 if (power_user.persona_show_notifications) {
824827 toastr.info(
825828 t`Creating a new persona for currently selected user name and avatar...`,
826829 t`Persona not set forDoes thisNot avatarExist`,
827830 { timeOut: 10000, extendedTimeOut: 20000 },
828831 );
829832 }
@@ -849,7 +852,7 @@ async function lockPersona(type = 'chat') {
849852 chat_metadata['persona'] = user_avatar;
850853 saveMetadataDebounced();
851854 if (power_user.persona_show_notifications) {
852855 toastr.success(t`User persona ${name1} is locked to ${name2} in this chat`, t`Persona Locked`);
853856 }
854857 break;
855858 }
@@ -881,7 +884,7 @@ async function lockPersona(type = 'chat') {
881884 let additional = '';
882885 if (unlinkedCharacters.length)
883886 additional += `<br /><br />${t`Unlinked existing persona${unlinkedCharacters.length > 1 ? 's' : ''}: ${unlinkedCharacters.join(', ')}`}`;
884887 toastr.success(t`User persona ${name1} is locked to character ${name2}${additional}`, nullt`Persona Locked`, { escapeHtml: false });
885888 }
886889 }
887890 break;
@@ -903,7 +906,7 @@ async function deleteUserAvatar(e) {
903906
904907 if (avatarId == user_avatar) {
905908 console.warn(`User tried to delete their current avatar ${avatarId}`);
906909 toastr.warning(t`You cannot delete the avatar you are currently using`, t`Persona Warning`);
907910 return;
908911 }
909912
@@ -928,12 +931,12 @@ async function deleteUserAvatar(e) {
928931 delete power_user.persona_descriptions[avatarId];
929932
930933 if (avatarId === power_user.default_persona) {
931934 toastr.warning(t`The default persona was deleted. You will need to set a new default persona.`, t`Default personaPersona deletedDeleted`);
932935 power_user.default_persona = null;
933936 }
934937
935938 if (avatarId === chat_metadata['persona']) {
936939 toastr.warning(t`The locked persona was deleted. You will need to set a new persona for this chat.`, t`Persona deletedDeleted`);
937940 delete chat_metadata['persona'];
938941 await saveMetadata();
939942 }
@@ -1002,7 +1005,7 @@ async function onPersonaLoreButtonClick(event) {
10021005 const selectedLorebook = power_user.persona_description_lorebook;
10031006
10041007 if (!personaName) {
10051008 toastr.warning(t`You must bind a name to this persona before you can set a lorebook.`, t`Persona nameName notNot setSet`);
10061009 return;
10071010 }
10081011
@@ -1099,15 +1102,14 @@ async function toggleDefaultPersona(avatarId, { quiet: quiet = false } = {}) {
10991102
11001103 if (power_user.personas[avatarId] === undefined) {
11011104 console.warn(`No persona name found for avatar ${avatarId}`);
11021105 toastr.warning(t`You must bind a name to this persona before you can set it as the default.`, t`Persona nameName notNot setSet`);
11031106 return;
11041107 }
11051108
1106- const personaName = power_user.personas[avatarId];
11071109
11081110 if (avatarId === currentDefault) {
11091111 if (!quiet) {
11101112 const confirm = await Popup.show.confirm(t`Are you sure you want to remove the default persona?`, personaNamepower_user.personas[avatarId]);
11111113 if (!confirm) {
11121114 console.debug('User cancelled removing default persona');
11131115 return;
@@ -1116,12 +1118,15 @@ async function toggleDefaultPersona(avatarId, { quiet: quiet = false } = {}) {
11161118
11171119 console.log(`Removing default persona ${avatarId}`);
11181120 if (power_user.persona_show_notifications) {
11191121 toastr.info(t`This persona will no longer be used by default when you open a new chat.`, t`Default personaPersona removedRemoved`);
11201122 }
11211123 delete power_user.default_persona;
11221124 } else {
11231125 if (!quiet) {
1124- const confirm = await Popup.show.confirm(t`Are you sure you want to set \"${personaName}\" as the default persona?`, t`This name and avatar will be used for all new chats, as well as existing chats where the user persona is not locked.`);
1126+ const confirm = await Popup.show.confirm(t`Set Default Persona`,
1127+ t`Are you sure you want to set \"${power_user.personas[avatarId]}\" as the default persona?`
1128+ + '<br /><br />'
1129+ + t`This name and avatar will be used for all new chats, as well as existing chats where the user persona is not locked.`);
11251130 if (!confirm) {
11261131 console.debug('User cancelled setting default persona');
11271132 return;
@@ -1130,7 +1135,7 @@ async function toggleDefaultPersona(avatarId, { quiet: quiet = false } = {}) {
11301135
11311136 power_user.default_persona = avatarId;
11321137 if (power_user.persona_show_notifications) {
11331138 toastr.success(t`Set to ${power_user.personas[avatarId]}.This persona will be used by default when you open a new chat.`, t`Default persona set toPersona ${personaName}Set`);
11341139 }
11351140 }
11361141
@@ -1193,7 +1198,7 @@ async function setChatLockedPersona() {
11931198 if (connectedPersonas.length > 0) {
11941199 if (!power_user.persona_allow_multi_connections || connectedPersonas.length === 1) {
11951200 chatPersona = connectedPersonas[0];
11961201 toastr.warning(t`More than one persona is connected to this character. Using the first available persona for this chat.`, t`Automatic personaPersona selectionSelection`);
11971202 } else {
11981203 chatPersona = await askForPersonaSelection(t`Select Persona`,
11991204 t`Select one of multiple with this character connected persona to use for this chat`,
@@ -1230,7 +1235,7 @@ async function setChatLockedPersona() {
12301235 setUserAvatar(chatPersona);
12311236
12321237 if (power_user.persona_show_notifications) {
12331238 toastr.info(t`Auto-selected persona ${power_user.personas[chatPersona]} based on ${connectType} connection.`, t`Persona ManagementAuto Selected`);
12341239 }
12351240 }
12361241
@@ -1315,10 +1320,10 @@ async function onPersonasRestoreInput(e) {
13151320 }
13161321
13171322 if (warnings.length) {
13181323 toastr.success(t`Personas restored with warnings. Check console for details.`, t`Persona Management`);
13191324 console.warn(`PERSONA RESTORE REPORT\n====================\n${warnings.join('\n')}`);
13201325 } else {
13211326 toastr.success(t`Personas restored successfully.`, t`Persona Management`);
13221327 }
13231328
13241329 await getUserAvatars();
@@ -1360,7 +1365,7 @@ async function duplicatePersona(avatarId) {
13601365 const personaName = power_user.personas[avatarId];
13611366
13621367 if (!personaName) {
13631368 toastr.warning('Chosen avatar is not a persona', t`Persona Management`);
13641369 return;
13651370 }
13661371