mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Preserve neutral chat on reloading with commands (#2848)
* Preserve neutral chat on reloading * Restore neutral on deleting character with bulk
This commit is contained in:
@ -225,7 +225,7 @@ import { getBackgrounds, initBackgrounds, loadBackgroundSettings, background_set
|
||||
import { hideLoader, showLoader } from './scripts/loader.js';
|
||||
import { BulkEditOverlay, CharacterContextMenu } from './scripts/BulkEditOverlay.js';
|
||||
import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels, loadTabbyModels } from './scripts/textgen-models.js';
|
||||
import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId } from './scripts/chats.js';
|
||||
import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId, preserveNeutralChat, restoreNeutralChat } from './scripts/chats.js';
|
||||
import { initPresetManager } from './scripts/preset-manager.js';
|
||||
import { MacrosParser, evaluateMacros, getLastMessageId } from './scripts/macros.js';
|
||||
import { currentUser, setUserControls } from './scripts/user.js';
|
||||
@ -1846,6 +1846,7 @@ export async function deleteLastMessage() {
|
||||
}
|
||||
|
||||
export async function reloadCurrentChat() {
|
||||
preserveNeutralChat();
|
||||
await clearChat();
|
||||
chat.length = 0;
|
||||
|
||||
@ -1857,6 +1858,7 @@ export async function reloadCurrentChat() {
|
||||
}
|
||||
else {
|
||||
resetChatState();
|
||||
restoreNeutralChat();
|
||||
await getCharacters();
|
||||
await printMessages();
|
||||
await eventSource.emit(event_types.CHAT_CHANGED, getCurrentChatId());
|
||||
@ -5700,10 +5702,10 @@ export function deactivateSendButtons() {
|
||||
}
|
||||
|
||||
export function resetChatState() {
|
||||
// replaces deleted charcter name with system user since it will be displayed next.
|
||||
name2 = (this_chid === undefined && neutralCharacterName) ? neutralCharacterName : systemUserName;
|
||||
//unsets expected chid before reloading (related to getCharacters/printCharacters from using old arrays)
|
||||
this_chid = undefined;
|
||||
// replaces deleted charcter name with system user since it will be displayed next.
|
||||
name2 = systemUserName;
|
||||
// sets up system user to tell user about having deleted a character
|
||||
chat.splice(0, chat.length, ...SAFETY_CHAT);
|
||||
// resets chat metadata
|
||||
@ -8947,15 +8949,12 @@ export async function deleteCharacter(characterKey, { deleteChats = true } = {})
|
||||
* It also ensures to save the settings after all the operations.
|
||||
*/
|
||||
async function removeCharacterFromUI() {
|
||||
preserveNeutralChat();
|
||||
await clearChat();
|
||||
$('#character_cross').click();
|
||||
this_chid = undefined;
|
||||
characters.length = 0;
|
||||
name2 = systemUserName;
|
||||
chat.splice(0, chat.length, ...SAFETY_CHAT);
|
||||
chat_metadata = {};
|
||||
$('#character_cross').trigger('click');
|
||||
resetChatState();
|
||||
$(document.getElementById('rm_button_selected_ch')).children('h2').text('');
|
||||
this_chid = undefined;
|
||||
restoreNeutralChat();
|
||||
await getCharacters();
|
||||
await printMessages();
|
||||
saveSettingsDebounced();
|
||||
|
Reference in New Issue
Block a user