Merge branch 'staging' into fix/raw-quotes

This commit is contained in:
Cohee
2025-03-29 17:51:34 +02:00
6 changed files with 15 additions and 64 deletions

View File

@ -36,10 +36,10 @@ jobs:
for ISSUE in $(echo $issues | jq -r '.[]'); do for ISSUE in $(echo $issues | jq -r '.[]'); do
if [ "${{ github.ref }}" == "refs/heads/staging" ]; then if [ "${{ github.ref }}" == "refs/heads/staging" ]; then
LABEL="✅ Done (staging)" LABEL="✅ Done (staging)"
gh issue edit $ISSUE -R ${{ github.repository }} --add-label "$LABEL" gh issue edit $ISSUE -R ${{ github.repository }} --add-label "$LABEL" --remove-label "🧑‍💻 In Progress"
elif [ "${{ github.ref }}" == "refs/heads/release" ]; then elif [ "${{ github.ref }}" == "refs/heads/release" ]; then
LABEL="✅ Done" LABEL="✅ Done"
gh issue edit $ISSUE -R ${{ github.repository }} --add-label "$LABEL" gh issue edit $ISSUE -R ${{ github.repository }} --add-label "$LABEL" --remove-label "🧑‍💻 In Progress"
fi fi
echo "Added label '$LABEL' to issue #$ISSUE" echo "Added label '$LABEL' (and removed '🧑‍💻 In Progress' if present) in issue #$ISSUE"
done done

View File

@ -262,6 +262,6 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
for ISSUE in $(echo $final_issues | jq -r '.[]'); do for ISSUE in $(echo $final_issues | jq -r '.[]'); do
gh issue edit $ISSUE -R ${{ github.repository }} --add-label "✅ Done (staging)" gh issue edit $ISSUE -R ${{ github.repository }} --add-label "✅ Done (staging)" --remove-label "🧑‍💻 In Progress"
echo "Added label '✅ Done (staging)' to issue #$ISSUE" echo "Added label '✅ Done (staging)' (and removed '🧑‍💻 In Progress' if present) in issue #$ISSUE"
done done

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { DOMPurify, Popper } from '../lib.js'; import { DOMPurify } from '../lib.js';
import { event_types, eventSource, is_send_press, main_api, substituteParams } from '../script.js'; import { event_types, eventSource, is_send_press, main_api, substituteParams } from '../script.js';
import { is_group_generating } from './group-chats.js'; import { is_group_generating } from './group-chats.js';
@ -1440,36 +1440,8 @@ class PromptManager {
footerDiv.querySelector('select').selectedIndex = selectedPromptIndex; footerDiv.querySelector('select').selectedIndex = selectedPromptIndex;
// Add prompt export dialogue and options // Add prompt export dialogue and options
const exportForCharacter = await renderTemplateAsync('promptManagerExportForCharacter');
const exportPopup = await renderTemplateAsync('promptManagerExportPopup', { isGlobalStrategy: 'global' === this.configuration.promptOrder.strategy, exportForCharacter });
rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup);
// Destroy previous popper instance if it exists
if (this.exportPopper) {
this.exportPopper.destroy();
}
this.exportPopper = Popper.createPopper(
document.getElementById('prompt-manager-export'),
document.getElementById('prompt-manager-export-format-popup'),
{ placement: 'bottom' },
);
const showExportSelection = () => {
const popup = document.getElementById('prompt-manager-export-format-popup');
const show = popup.hasAttribute('data-show');
if (show) popup.removeAttribute('data-show');
else popup.setAttribute('data-show', '');
this.exportPopper.update();
};
footerDiv.querySelector('#prompt-manager-import').addEventListener('click', this.handleImport); footerDiv.querySelector('#prompt-manager-import').addEventListener('click', this.handleImport);
footerDiv.querySelector('#prompt-manager-export').addEventListener('click', showExportSelection); footerDiv.querySelector('#prompt-manager-export').addEventListener('click', this.handleFullExport);
rangeBlockDiv.querySelector('.export-promptmanager-prompts-full').addEventListener('click', this.handleFullExport);
rangeBlockDiv.querySelector('.export-promptmanager-prompts-character')?.addEventListener('click', this.handleCharacterExport);
} }
} }

View File

@ -111,6 +111,7 @@ export function setUserAvatar(imgfile, { toastPersonaNameChange = true, navigate
reloadUserAvatar(); reloadUserAvatar();
updatePersonaUIStates({ navigateToCurrent: navigateToCurrent }); updatePersonaUIStates({ navigateToCurrent: navigateToCurrent });
selectCurrentPersona({ toastPersonaNameChange: toastPersonaNameChange }); selectCurrentPersona({ toastPersonaNameChange: toastPersonaNameChange });
retriggerFirstMessageOnEmptyChat();
saveSettingsDebounced(); saveSettingsDebounced();
$('.zoomed_avatar[forchar]').remove(); $('.zoomed_avatar[forchar]').remove();
} }
@ -465,7 +466,7 @@ export function initPersona(avatarId, personaName, personaDescription) {
* @returns {Promise<boolean>} A promise that resolves to true if the character was converted, false otherwise. * @returns {Promise<boolean>} A promise that resolves to true if the character was converted, false otherwise.
*/ */
export async function convertCharacterToPersona(characterId = null) { export async function convertCharacterToPersona(characterId = null) {
if (null === characterId) characterId = this_chid; if (null === characterId) characterId = Number(this_chid);
const avatarUrl = characters[characterId]?.avatar; const avatarUrl = characters[characterId]?.avatar;
if (!avatarUrl) { if (!avatarUrl) {
@ -1243,7 +1244,7 @@ function getPersonaStates(avatarId) {
/** @type {PersonaConnection[]} */ /** @type {PersonaConnection[]} */
const connections = power_user.persona_descriptions[avatarId]?.connections; const connections = power_user.persona_descriptions[avatarId]?.connections;
const hasCharLock = !!connections?.some(c => const hasCharLock = !!connections?.some(c =>
(!selected_group && c.type === 'character' && c.id === characters[this_chid]?.avatar) (!selected_group && c.type === 'character' && c.id === characters[Number(this_chid)]?.avatar)
|| (selected_group && c.type === 'group' && c.id === selected_group)); || (selected_group && c.type === 'group' && c.id === selected_group));
return { return {
@ -1481,7 +1482,7 @@ async function loadPersonaForCurrentChat({ doRender = false } = {}) {
* @returns {string[]} - An array of persona keys that are connected to the given character key * @returns {string[]} - An array of persona keys that are connected to the given character key
*/ */
export function getConnectedPersonas(characterKey = undefined) { export function getConnectedPersonas(characterKey = undefined) {
characterKey ??= selected_group || characters[this_chid]?.avatar; characterKey ??= selected_group || characters[Number(this_chid)]?.avatar;
const connectedPersonas = Object.entries(power_user.persona_descriptions) const connectedPersonas = Object.entries(power_user.persona_descriptions)
.filter(([_, desc]) => desc.connections?.some(conn => conn.type === 'character' && conn.id === characterKey)) .filter(([_, desc]) => desc.connections?.some(conn => conn.type === 'character' && conn.id === characterKey))
.map(([key, _]) => key); .map(([key, _]) => key);
@ -1513,7 +1514,7 @@ export async function showCharConnections() {
console.log(`Unlocking persona ${personaId} from current character ${name2}`); console.log(`Unlocking persona ${personaId} from current character ${name2}`);
power_user.persona_descriptions[personaId].connections = connections.filter(c => { power_user.persona_descriptions[personaId].connections = connections.filter(c => {
if (menu_type == 'group_edit' && c.type == 'group' && c.id == selected_group) return false; if (menu_type == 'group_edit' && c.type == 'group' && c.id == selected_group) return false;
else if (c.type == 'character' && c.id == characters[this_chid]?.avatar) return false; else if (c.type == 'character' && c.id == characters[Number(this_chid)]?.avatar) return false;
return true; return true;
}); });
saveSettingsDebounced(); saveSettingsDebounced();
@ -1545,8 +1546,8 @@ export async function showCharConnections() {
export function getCurrentConnectionObj() { export function getCurrentConnectionObj() {
if (selected_group) if (selected_group)
return { type: 'group', id: selected_group }; return { type: 'group', id: selected_group };
if (characters[this_chid]?.avatar) if (characters[Number(this_chid)]?.avatar)
return { type: 'character', id: characters[this_chid]?.avatar }; return { type: 'character', id: characters[Number(this_chid)]?.avatar };
return null; return null;
} }
@ -1664,7 +1665,7 @@ async function syncUserNameToPersona() {
* Only works if only the first message is present, and not in group mode. * Only works if only the first message is present, and not in group mode.
*/ */
export function retriggerFirstMessageOnEmptyChat() { export function retriggerFirstMessageOnEmptyChat() {
if (this_chid >= 0 && !selected_group && chat.length === 1) { if (Number(this_chid) >= 0 && !selected_group && chat.length === 1) {
$('#firstmessage_textarea').trigger('input'); $('#firstmessage_textarea').trigger('input');
} }
} }
@ -1782,7 +1783,6 @@ function setNameCallback({ mode = 'all' }, name) {
if (!persona) persona = Object.entries(power_user.personas).find(([_, personaName]) => personaName.toLowerCase() === name.toLowerCase())?.[1]; if (!persona) persona = Object.entries(power_user.personas).find(([_, personaName]) => personaName.toLowerCase() === name.toLowerCase())?.[1];
if (persona) { if (persona) {
autoSelectPersona(persona); autoSelectPersona(persona);
retriggerFirstMessageOnEmptyChat();
return ''; return '';
} else if (mode === 'lookup') { } else if (mode === 'lookup') {
toastr.warning(`Persona ${name} not found`); toastr.warning(`Persona ${name} not found`);
@ -1793,7 +1793,6 @@ function setNameCallback({ mode = 'all' }, name) {
if (['temp', 'all'].includes(mode)) { if (['temp', 'all'].includes(mode)) {
// Otherwise, set just the name // Otherwise, set just the name
setUserName(name); //this prevented quickReply usage setUserName(name); //this prevented quickReply usage
retriggerFirstMessageOnEmptyChat();
} }
return ''; return '';
@ -1944,9 +1943,6 @@ export async function initPersonas() {
$(document).on('click', '#user_avatar_block .avatar-container', function () { $(document).on('click', '#user_avatar_block .avatar-container', function () {
const imgfile = $(this).attr('data-avatar-id'); const imgfile = $(this).attr('data-avatar-id');
setUserAvatar(imgfile); setUserAvatar(imgfile);
// force firstMes {{user}} update on persona switch
retriggerFirstMessageOnEmptyChat();
}); });
$('#persona_rename_button').on('click', () => renamePersona(user_avatar)); $('#persona_rename_button').on('click', () => renamePersona(user_avatar));
@ -1979,4 +1975,3 @@ export async function initPersonas() {
eventSource.on(event_types.CHAT_CHANGED, loadPersonaForCurrentChat); eventSource.on(event_types.CHAT_CHANGED, loadPersonaForCurrentChat);
switchPersonaGridView(); switchPersonaGridView();
} }

View File

@ -1,4 +0,0 @@
<div class="row">
<a class="export-promptmanager-prompts-character list-group-item" data-i18n="Export for character">Export for character</a>
<span class="tooltip fa-solid fa-info-circle" data-i18n="[title]Export prompts for this character, including their order." title="Export prompts for this character, including their order."></span>
</div>

View File

@ -1,12 +0,0 @@
<div id="prompt-manager-export-format-popup" class="list-group">
<div class="prompt-manager-export-format-popup-flex">
<div class="row">
<a class="export-promptmanager-prompts-full list-group-item" data-i18n="Export all">Export all</a>
<span class="tooltip fa-solid fa-info-circle" data-i18n="[title]Export all your prompts to a file" title="Export all your prompts to a file"></span>
</div>
{{#if isGlobalStrategy}}
{{else}}
{{{exportForCharacter}}}
{{/if}}
</div>
</div>