| 1311 | 1311 | if (chatPersona) connectType = 'chat'; |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | + // If the persona panel is open when the chat changes, this is likely because a character was selected from that panel. |
| 1315 | + // In that case, we are not automatically switching persona - but need to make changes if there is any chat-bound connection |
| 1316 | + if (isPersonaPanelOpen()) { |
| 1317 | + if (chatPersona) { |
| 1318 | + // If the chat-bound persona is the currently selected one, we can simply exit out |
| 1319 | + if (chatPersona === user_avatar) { |
| 1320 | + return; |
| 1321 | + } |
| 1322 | + // Otherwise ask if we want to switch |
| 1323 | + const autoLock = power_user.persona_auto_lock; |
| 1324 | + const result = await Popup.show.confirm(t`Switch Persona?`, |
| 1325 | + t`You have a connected persona for the current chat (${power_user.personas[chatPersona]}). Do you want to stick to the current persona (${power_user.personas[user_avatar]}) ${(autoLock ? t`and lock that to the chat` : '')}, or switch to ${power_user.personas[chatPersona]} instead?`, |
| 1326 | + { okButton: autoLock ? t`Keep and Lock` : t`Keep`, cancelButton: t`Switch` }); |
| 1327 | + if (result === POPUP_RESULT.AFFIRMATIVE) { |
| 1328 | + if (autoLock) { |
| 1329 | + lockPersona('chat'); |
| 1330 | + } |
| 1331 | + return; |
| 1332 | + } |
| 1333 | + } else { |
| 1334 | + // If we don't have a chat-bound persona, we simply return and keep the current one we have |
| 1335 | + return; |
| 1336 | + } |
| 1337 | + } |
| 1338 | + |
| 1314 | 1339 | // Check if we have any persona connected to the current character |
| 1315 | 1340 | if (!chatPersona) { |
| 1316 | 1341 | const connectedPersonas = getConnectedPersonas(); |