Centralize first message retrigger on persona changes Moves retrigger logic to setUserAvatar entry point to avoid duplicate calls when updating personas Removes redundant triggers from name/avatar handlers Fixes #3774
| @@ -111,6 +111,7 @@ export function setUserAvatar(imgfile, { toastPersonaNameChange = true, navigate | |||
| 111 | reloadUserAvatar(); | 111 | reloadUserAvatar(); |
| 112 | updatePersonaUIStates({ navigateToCurrent: navigateToCurrent }); | 112 | updatePersonaUIStates({ navigateToCurrent: navigateToCurrent }); |
| 113 | selectCurrentPersona({ toastPersonaNameChange: toastPersonaNameChange }); | 113 | selectCurrentPersona({ toastPersonaNameChange: toastPersonaNameChange }); |
| 114 | retriggerFirstMessageOnEmptyChat(); | ||
| 114 | saveSettingsDebounced(); | 115 | saveSettingsDebounced(); |
| 115 | $('.zoomed_avatar[forchar]').remove(); | 116 | $('.zoomed_avatar[forchar]').remove(); |
| 116 | } | 117 | } |
| @@ -1782,7 +1783,6 @@ function setNameCallback({ mode = 'all' }, name) { | |||
| 1782 | if (!persona) persona = Object.entries(power_user.personas).find(([_, personaName]) => personaName.toLowerCase() === name.toLowerCase())?.[1]; | 1783 | if (!persona) persona = Object.entries(power_user.personas).find(([_, personaName]) => personaName.toLowerCase() === name.toLowerCase())?.[1]; |
| 1783 | if (persona) { | 1784 | if (persona) { |
| 1784 | autoSelectPersona(persona); | 1785 | autoSelectPersona(persona); |
| 1785 | retriggerFirstMessageOnEmptyChat(); | ||
| 1786 | return ''; | 1786 | return ''; |
| 1787 | } else if (mode === 'lookup') { | 1787 | } else if (mode === 'lookup') { |
| 1788 | toastr.warning(`Persona ${name} not found`); | 1788 | toastr.warning(`Persona ${name} not found`); |
| @@ -1793,7 +1793,6 @@ function setNameCallback({ mode = 'all' }, name) { | |||
| 1793 | if (['temp', 'all'].includes(mode)) { | 1793 | if (['temp', 'all'].includes(mode)) { |
| 1794 | // Otherwise, set just the name | 1794 | // Otherwise, set just the name |
| 1795 | setUserName(name); //this prevented quickReply usage | 1795 | setUserName(name); //this prevented quickReply usage |
| 1796 | retriggerFirstMessageOnEmptyChat(); | ||
| 1797 | } | 1796 | } |
| 1798 | 1797 | ||
| 1799 | return ''; | 1798 | return ''; |
| @@ -1944,9 +1943,6 @@ export async function initPersonas() { | |||
| 1944 | $(document).on('click', '#user_avatar_block .avatar-container', function () { | 1943 | $(document).on('click', '#user_avatar_block .avatar-container', function () { |
| 1945 | const imgfile = $(this).attr('data-avatar-id'); | 1944 | const imgfile = $(this).attr('data-avatar-id'); |
| 1946 | setUserAvatar(imgfile); | 1945 | setUserAvatar(imgfile); |
| 1947 | |||
| 1948 | // force firstMes {{user}} update on persona switch | ||
| 1949 | retriggerFirstMessageOnEmptyChat(); | ||
| 1950 | }); | 1946 | }); |
| 1951 | 1947 | ||
| 1952 | $('#persona_rename_button').on('click', () => renamePersona(user_avatar)); | 1948 | $('#persona_rename_button').on('click', () => renamePersona(user_avatar)); |