Merge branch 'staging' into hidden-reasoning-tracking

This commit is contained in:
Cohee
2025-02-12 20:00:52 +02:00
18 changed files with 253 additions and 108 deletions

View File

@ -270,6 +270,7 @@ import { initBulkEdit } from './scripts/bulk-edit.js';
import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js';
import { getContext } from './scripts/st-context.js';
import { extractReasoningFromData, initReasoning, PromptReasoning, ReasoningHandler, removeReasoningFromString, updateReasoningUI } from './scripts/reasoning.js';
import { accountStorage } from './scripts/util/AccountStorage.js';
// API OBJECT FOR EXTERNAL WIRING
globalThis.SillyTavern = {
@ -419,7 +420,7 @@ DOMPurify.addHook('uponSanitizeElement', (node, _, config) => {
const entityId = getCurrentEntityId();
const warningShownKey = `mediaWarningShown:${entityId}`;
if (localStorage.getItem(warningShownKey) === null) {
if (accountStorage.getItem(warningShownKey) === null) {
const warningToast = toastr.warning(
t`Use the 'Ext. Media' button to allow it. Click on this message to dismiss.`,
t`External media has been blocked`,
@ -430,7 +431,7 @@ DOMPurify.addHook('uponSanitizeElement', (node, _, config) => {
},
);
localStorage.setItem(warningShownKey, 'true');
accountStorage.setItem(warningShownKey, 'true');
}
}
});
@ -1490,7 +1491,7 @@ export async function printCharacters(fullRefresh = false) {
$('#rm_print_characters_pagination').pagination({
dataSource: entities,
pageSize: Number(localStorage.getItem(storageKey)) || per_page_default,
pageSize: Number(accountStorage.getItem(storageKey)) || per_page_default,
sizeChangerOptions: [10, 25, 50, 100, 250, 500, 1000],
pageRange: 1,
pageNumber: saveCharactersPage || 1,
@ -1534,7 +1535,7 @@ export async function printCharacters(fullRefresh = false) {
eventSource.emit(event_types.CHARACTER_PAGE_LOADED);
},
afterSizeSelectorChange: function (e) {
localStorage.setItem(storageKey, e.target.value);
accountStorage.setItem(storageKey, e.target.value);
},
afterPaging: function (e) {
saveCharactersPage = e;
@ -6839,10 +6840,11 @@ export async function getSettings() {
$('#your_name').val(name1);
}
accountStorage.init(settings?.accountStorage);
await setUserControls(data.enable_accounts);
// Allow subscribers to mutate settings
eventSource.emit(event_types.SETTINGS_LOADED_BEFORE, settings);
await eventSource.emit(event_types.SETTINGS_LOADED_BEFORE, settings);
//Load KoboldAI settings
koboldai_setting_names = data.koboldai_setting_names;
@ -7010,7 +7012,8 @@ function selectKoboldGuiPreset() {
export async function saveSettings(loopCounter = 0) {
if (!settingsReady) {
console.warn('Settings not ready, aborting save');
console.warn('Settings not ready, scheduling another save');
saveSettingsDebounced();
return;
}
@ -7031,6 +7034,7 @@ export async function saveSettings(loopCounter = 0) {
url: '/api/settings/save',
data: JSON.stringify({
firstRun: firstRun,
accountStorage: accountStorage.getState(),
currentVersion: currentVersion,
username: name1,
active_character: active_character,
@ -7486,7 +7490,7 @@ export function select_rm_info(type, charId, previousCharId = null) {
}
try {
const perPage = Number(localStorage.getItem('Characters_PerPage')) || per_page_default;
const perPage = Number(accountStorage.getItem('Characters_PerPage')) || per_page_default;
const page = Math.floor(charIndex / perPage) + 1;
const selector = `#rm_print_characters_block [title*="${avatarFileName}"]`;
$('#rm_print_characters_pagination').pagination('go', page);
@ -7518,7 +7522,7 @@ export function select_rm_info(type, charId, previousCharId = null) {
return;
}
const perPage = Number(localStorage.getItem('Characters_PerPage')) || per_page_default;
const perPage = Number(accountStorage.getItem('Characters_PerPage')) || per_page_default;
const page = Math.floor(charIndex / perPage) + 1;
$('#rm_print_characters_pagination').pagination('go', page);
const selector = `#rm_print_characters_block [grid="${charId}"]`;
@ -9384,6 +9388,9 @@ export async function deleteCharacter(characterKey, { deleteChats = true } = {})
continue;
}
accountStorage.removeItem(`AlertWI_${character.avatar}`);
accountStorage.removeItem(`AlertRegex_${character.avatar}`);
accountStorage.removeItem(`mediaWarningShown:${character.avatar}`);
delete tag_map[character.avatar];
select_rm_info('char_delete', character.name);
@ -9586,8 +9593,8 @@ function addDebugFunctions() {
});
registerDebugFunction('toggleRegenerateWarning', 'Toggle Ctrl+Enter regeneration confirmation', 'Toggle the warning when regenerating a message with a Ctrl+Enter hotkey.', () => {
localStorage.setItem('RegenerateWithCtrlEnter', localStorage.getItem('RegenerateWithCtrlEnter') === 'true' ? 'false' : 'true');
toastr.info('Regenerate warning is now ' + (localStorage.getItem('RegenerateWithCtrlEnter') === 'true' ? 'disabled' : 'enabled'));
accountStorage.setItem('RegenerateWithCtrlEnter', accountStorage.getItem('RegenerateWithCtrlEnter') === 'true' ? 'false' : 'true');
toastr.info('Regenerate warning is now ' + (accountStorage.getItem('RegenerateWithCtrlEnter') === 'true' ? 'disabled' : 'enabled'));
});
registerDebugFunction('copySetup', 'Copy ST setup to clipboard [WIP]', 'Useful data when reporting bugs', async () => {