From 9f0c2300d2d36e43c609fbf75d97e9d68a872c1e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 29 Sep 2024 16:24:40 +0300 Subject: [PATCH 1/3] Add connection map aliases --- public/script.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/public/script.js b/public/script.js index 6d93bc03b..2e8b8d736 100644 --- a/public/script.js +++ b/public/script.js @@ -8476,12 +8476,22 @@ const CONNECT_API_MAP = { selected: 'novel', button: '#api_button_novel', }, + 'koboldcpp': { + selected: 'textgenerationwebui', + button: '#api_button_textgenerationwebui', + type: textgen_types.KOBOLDCPP, + }, // KoboldCpp alias 'kcpp': { selected: 'textgenerationwebui', button: '#api_button_textgenerationwebui', type: textgen_types.KOBOLDCPP, }, + 'openai': { + selected: 'openai', + button: '#api_button_openai', + source: chat_completion_sources.OPENAI, + }, // OpenAI alias 'oai': { selected: 'openai', From 2f43c8e227205a31bb8adb1110ea9d549e4cef17 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:12:26 +0300 Subject: [PATCH 2/3] Fix /ask in neutral chats --- public/scripts/slash-commands.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index d9bdd4e7a..eb81a0218 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -2530,8 +2530,13 @@ async function askCharacter(args, text) { return; } - setCharacterId(prevChId); - setCharacterName(characters[prevChId].name); + if (prevChId !== undefined) { + setCharacterId(prevChId); + setCharacterName(characters[prevChId].name); + } else { + setCharacterId(undefined); + setCharacterName(neutralCharacterName); + } // Only force the new avatar if the character name is the same // This skips if an error was fired From 8061f453687bfc95edb3de7a3d6702dd48c42bd8 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:13:19 +0300 Subject: [PATCH 3/3] RossMods: Debounce online status display --- public/scripts/RossAscends-mods.js | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index 92278f35c..1a9e2d7d2 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -56,22 +56,25 @@ let counterNonce = Date.now(); const observerConfig = { childList: true, subtree: true }; const countTokensDebounced = debounce(RA_CountCharTokens, debounce_timeout.relaxed); +const countTokensShortDebounced = debounce(RA_CountCharTokens, debounce_timeout.short); +const checkStatusDebounced = debounce(RA_checkOnlineStatus, debounce_timeout.short); const observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { + if (!(mutation.target instanceof HTMLElement)) { + return; + } if (mutation.target.classList.contains('online_status_text')) { - RA_checkOnlineStatus(); + checkStatusDebounced(); } else if (mutation.target.parentNode === SelectedCharacterTab) { - setTimeout(RA_CountCharTokens, 200); + countTokensShortDebounced(); } else if (mutation.target.classList.contains('mes_text')) { - if (mutation.target instanceof HTMLElement) { - for (const element of mutation.target.getElementsByTagName('math')) { - element.childNodes.forEach(function (child) { - if (child.nodeType === Node.TEXT_NODE) { - child.textContent = ''; - } - }); - } + for (const element of mutation.target.getElementsByTagName('math')) { + element.childNodes.forEach(function (child) { + if (child.nodeType === Node.TEXT_NODE) { + child.textContent = ''; + } + }); } } }); @@ -159,8 +162,8 @@ export function shouldSendOnEnter() { export function humanizedDateTime() { const now = new Date(Date.now()); const dt = { - year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), - hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), + year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), + hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), }; for (const key in dt) { dt[key] = dt[key].toString().padStart(2, '0'); @@ -725,9 +728,7 @@ export function addSafariPatch() { export function initRossMods() { // initial status check - setTimeout(() => { - RA_checkOnlineStatus(); - }, 100); + checkStatusDebounced(); if (power_user.auto_load_chat) { RA_autoloadchat(); @@ -752,7 +753,7 @@ export function initRossMods() { setTimeout(() => RA_autoconnect(PrevAPI), 100); }); - $('#api_button').click(function () { setTimeout(RA_checkOnlineStatus, 100); }); + $('#api_button').on('click', () => checkStatusDebounced()); //toggle pin class when lock toggle clicked $(RPanelPin).on('click', function () {