Reprint non-tainted group chat on switching personas (#4603)

* fix: reprint non-tainted group chat on switching personas

* feat: mark chat as tainted when sending user message

* feat: mark chat as tainted when adding custom messages or captions

* feat: export createOrEditCharacter function and integrate it into retriggerFirstMessageOnEmptyChat

* fix: optimize loadPersonaForCurrentChat by storing current chat ID in a variable

* Improve conditions of first message retrigger

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
Wolfsblvt
2025-10-06 21:45:26 +02:00
committed by GitHub
parent befb2ffb78
commit 9463d1a152
5 changed files with 75 additions and 46 deletions
+2 -1
View File
@@ -1,6 +1,6 @@
import { ensureImageFormatSupported, getBase64Async, getFileExtension, isTrueBoolean, saveBase64AsFile } from '../../utils.js';
import { getContext, getApiUrl, doExtrasFetch, extension_settings, modules, renderExtensionTemplateAsync } from '../../extensions.js';
import { appendMediaToMessage, eventSource, event_types, getRequestHeaders, saveChatConditional, saveSettingsDebounced, substituteParamsExtended } from '../../../script.js';
import { appendMediaToMessage, chat_metadata, eventSource, event_types, getRequestHeaders, saveChatConditional, saveSettingsDebounced, substituteParamsExtended } from '../../../script.js';
import { getMessageTimeStamp } from '../../RossAscends-mods.js';
import { SECRET_KEYS, secret_state } from '../../secrets.js';
import { getMultimodalCaption } from '../shared.js';
@@ -174,6 +174,7 @@ async function sendCaptionedMessage(caption, image) {
inline_image: !!extension_settings.caption.show_in_chat,
},
};
chat_metadata['tainted'] = true;
context.chat.push(message);
const messageId = context.chat.length - 1;
await eventSource.emit(event_types.MESSAGE_SENT, messageId);