Merge branch 'staging' of https://github.com/Cohee1207/SillyTavern into staging

da161b962863f9eccec32d1c426804a241af3a22

RossAscends <124905043+RossAscends@users.noreply.github.com>

3 files changed, +34 -18Ignore whitespace
public/script.js+10 -0
@@ -8476,12 +8476,22 @@ const CONNECT_API_MAP = {
8476 selected: 'novel',8476 selected: 'novel',
8477 button: '#api_button_novel',8477 button: '#api_button_novel',
8478 },8478 },
8479 'koboldcpp': {
8480 selected: 'textgenerationwebui',
8481 button: '#api_button_textgenerationwebui',
8482 type: textgen_types.KOBOLDCPP,
8483 },
8479 // KoboldCpp alias8484 // KoboldCpp alias
8480 'kcpp': {8485 'kcpp': {
8481 selected: 'textgenerationwebui',8486 selected: 'textgenerationwebui',
8482 button: '#api_button_textgenerationwebui',8487 button: '#api_button_textgenerationwebui',
8483 type: textgen_types.KOBOLDCPP,8488 type: textgen_types.KOBOLDCPP,
8484 },8489 },
8490 'openai': {
8491 selected: 'openai',
8492 button: '#api_button_openai',
8493 source: chat_completion_sources.OPENAI,
8494 },
8485 // OpenAI alias8495 // OpenAI alias
8486 'oai': {8496 'oai': {
8487 selected: 'openai',8497 selected: 'openai',
public/scripts/RossAscends-mods.js+17 -16
@@ -56,22 +56,25 @@ let counterNonce = Date.now();
5656
57const observerConfig = { childList: true, subtree: true };57const observerConfig = { childList: true, subtree: true };
58const countTokensDebounced = debounce(RA_CountCharTokens, debounce_timeout.relaxed);58const countTokensDebounced = debounce(RA_CountCharTokens, debounce_timeout.relaxed);
59const countTokensShortDebounced = debounce(RA_CountCharTokens, debounce_timeout.short);
60const checkStatusDebounced = debounce(RA_checkOnlineStatus, debounce_timeout.short);
5961
60const observer = new MutationObserver(function (mutations) {62const observer = new MutationObserver(function (mutations) {
61 mutations.forEach(function (mutation) {63 mutations.forEach(function (mutation) {
64 if (!(mutation.target instanceof HTMLElement)) {
65 return;
66 }
62 if (mutation.target.classList.contains('online_status_text')) {67 if (mutation.target.classList.contains('online_status_text')) {
63 RA_checkOnlineStatus();68 checkStatusDebounced();
64 } else if (mutation.target.parentNode === SelectedCharacterTab) {69 } else if (mutation.target.parentNode === SelectedCharacterTab) {
65 setTimeout(RA_CountCharTokens, 200);70 countTokensShortDebounced();
66 } else if (mutation.target.classList.contains('mes_text')) {71 } else if (mutation.target.classList.contains('mes_text')) {
67 if (mutation.target instanceof HTMLElement) {72 for (const element of mutation.target.getElementsByTagName('math')) {
68 for (const element of mutation.target.getElementsByTagName('math')) {73 element.childNodes.forEach(function (child) {
69 element.childNodes.forEach(function (child) {74 if (child.nodeType === Node.TEXT_NODE) {
70 if (child.nodeType === Node.TEXT_NODE) {75 child.textContent = '';
71 child.textContent = '';76 }
72 }77 });
73 });
74 }
75 }78 }
76 }79 }
77 });80 });
@@ -159,8 +162,8 @@ export function shouldSendOnEnter() {
159export function humanizedDateTime() {162export function humanizedDateTime() {
160 const now = new Date(Date.now());163 const now = new Date(Date.now());
161 const dt = {164 const dt = {
162 year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(),165 year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(),
163 hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(),166 hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(),
164 };167 };
165 for (const key in dt) {168 for (const key in dt) {
166 dt[key] = dt[key].toString().padStart(2, '0');169 dt[key] = dt[key].toString().padStart(2, '0');
@@ -725,9 +728,7 @@ export function addSafariPatch() {
725728
726export function initRossMods() {729export function initRossMods() {
727 // initial status check730 // initial status check
728 setTimeout(() => {731 checkStatusDebounced();
729 RA_checkOnlineStatus();
730 }, 100);
731732
732 if (power_user.auto_load_chat) {733 if (power_user.auto_load_chat) {
733 RA_autoloadchat();734 RA_autoloadchat();
@@ -752,7 +753,7 @@ export function initRossMods() {
752 setTimeout(() => RA_autoconnect(PrevAPI), 100);753 setTimeout(() => RA_autoconnect(PrevAPI), 100);
753 });754 });
754755
755 $('#api_button').click(function () { setTimeout(RA_checkOnlineStatus, 100); });756 $('#api_button').on('click', () => checkStatusDebounced());
756757
757 //toggle pin class when lock toggle clicked758 //toggle pin class when lock toggle clicked
758 $(RPanelPin).on('click', function () {759 $(RPanelPin).on('click', function () {
public/scripts/slash-commands.js+7 -2
@@ -2530,8 +2530,13 @@ async function askCharacter(args, text) {
2530 return;2530 return;
2531 }2531 }
25322532
2533 setCharacterId(prevChId);2533 if (prevChId !== undefined) {
2534 setCharacterName(characters[prevChId].name);2534 setCharacterId(prevChId);
2535 setCharacterName(characters[prevChId].name);
2536 } else {
2537 setCharacterId(undefined);
2538 setCharacterName(neutralCharacterName);
2539 }
25352540
2536 // Only force the new avatar if the character name is the same2541 // Only force the new avatar if the character name is the same
2537 // This skips if an error was fired2542 // This skips if an error was fired