From 868778b07959986339bb72ac0a7b4e1b86b3c4ec Mon Sep 17 00:00:00 2001 From: EvilFear <52994635+Hakirus@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:27:03 -0400 Subject: [PATCH 1/7] Update index.js Quick Reply Mod --- .../scripts/extensions/quick-reply/index.js | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/quick-reply/index.js b/public/scripts/extensions/quick-reply/index.js index 44360bc34..e06891522 100644 --- a/public/scripts/extensions/quick-reply/index.js +++ b/public/scripts/extensions/quick-reply/index.js @@ -99,7 +99,14 @@ async function onQuickReplyEnabledInput() { saveSettingsDebounced(); } +// New function to handle input on quickActionEnabled +async function onQuickActionEnabledInput() { + extension_settings.quickReply.quickActionEnabled = $(this).prop('checked'); + saveSettingsDebounced(); +} + async function sendQuickReply(index) { + const existingText = $("#send_textarea").val(); const prompt = extension_settings.quickReply.quickReplySlots[index]?.mes || ''; if (!prompt) { @@ -107,8 +114,25 @@ async function sendQuickReply(index) { return; } - $("#send_textarea").val(prompt); - $("#send_but").trigger('click'); + let newText; + + if (existingText) { + // If existing text, add space after prompt + newText = existingText + ' ' + prompt + ' '; + } else { + // If no existing text, add prompt only + newText = prompt + ' '; + } + + $("#send_textarea").val(newText); + + // Set the focus back to the textarea + $("#send_textarea").focus(); + + // Only trigger send button if quickActionEnabled is not checked + if (!$("#quickActionEnabled").prop('checked')) { + $("#send_but").trigger('click'); + } } function addQuickReplyBar() { @@ -309,6 +333,10 @@ jQuery(async () => { Enable Quick Replies +
@@ -330,7 +358,9 @@ jQuery(async () => {
`; $('#extensions_settings2').append(settingsHtml); - + + // Add event handler for quickActionEnabled + $('#quickActionEnabled').on('input', onQuickActionEnabledInput); $('#quickReplyEnabled').on('input', onQuickReplyEnabledInput); $('#quickReplyNumberOfSlotsApply').on('click', onQuickReplyNumberOfSlotsInput); $("#quickReplyPresetSaveButton").on('click', saveQuickReplyPreset); From ef68dd07ac4d511fa9f4f95ac0bffe93d3b5b9b0 Mon Sep 17 00:00:00 2001 From: IkariDevGIT Date: Thu, 7 Sep 2023 16:02:34 +0200 Subject: [PATCH 2/7] Add command for opening the gallery --- public/scripts/extensions/gallery/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/scripts/extensions/gallery/index.js b/public/scripts/extensions/gallery/index.js index 4bdde9453..11f3dd4ff 100644 --- a/public/scripts/extensions/gallery/index.js +++ b/public/scripts/extensions/gallery/index.js @@ -7,7 +7,8 @@ import { import { selected_group } from "../../group-chats.js"; import { loadFileToDocument } from "../../utils.js"; import { loadMovingUIState } from '../../power-user.js'; -import { dragElement } from '../../RossAscends-mods.js' +import { dragElement } from '../../RossAscends-mods.js'; +import { registerSlashCommand } from "../../slash-commands.js"; const extensionName = "gallery"; const extensionFolderPath = `scripts/extensions/${extensionName}/`; @@ -386,3 +387,10 @@ function viewWithDragbox(items) { } } + +// Registers a simple command for opening the char gallery. +registerSlashCommand("show-gallery", showGalleryCommand, ["sg"], "Shows the gallery", true, true); + +function showGalleryCommand(args) { + showCharGallery(); +} From 470da71b3b99beb22d0d779271ebb95129f4051a Mon Sep 17 00:00:00 2001 From: EvilFear <52994635+Hakirus@users.noreply.github.com> Date: Thu, 7 Sep 2023 17:08:21 -0400 Subject: [PATCH 3/7] Update index.js --- public/scripts/extensions/quick-reply/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/quick-reply/index.js b/public/scripts/extensions/quick-reply/index.js index e06891522..34b8c7d8a 100644 --- a/public/scripts/extensions/quick-reply/index.js +++ b/public/scripts/extensions/quick-reply/index.js @@ -120,7 +120,7 @@ async function sendQuickReply(index) { // If existing text, add space after prompt newText = existingText + ' ' + prompt + ' '; } else { - // If no existing text, add prompt only + // If no existing text, add prompt only (with a trailing space) newText = prompt + ' '; } @@ -129,12 +129,14 @@ async function sendQuickReply(index) { // Set the focus back to the textarea $("#send_textarea").focus(); - // Only trigger send button if quickActionEnabled is not checked - if (!$("#quickActionEnabled").prop('checked')) { + // Only trigger send button if quickActionEnabled is not checked or + // the prompt starts with '/' + if (!$("#quickActionEnabled").prop('checked') || prompt.startsWith('/')) { $("#send_but").trigger('click'); } } + function addQuickReplyBar() { $('#quickReplyBar').remove(); let quickReplyButtonHtml = ''; From 40f95bf84287dd078e618c959ff334891c65824a Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 7 Sep 2023 22:28:53 +0300 Subject: [PATCH 4/7] Fix HypeBot plugin settings not saving --- public/scripts/extensions/hypebot/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/scripts/extensions/hypebot/index.js b/public/scripts/extensions/hypebot/index.js index 2fbd66764..a64fe5d9f 100644 --- a/public/scripts/extensions/hypebot/index.js +++ b/public/scripts/extensions/hypebot/index.js @@ -191,11 +191,13 @@ jQuery(() => { settings.enabled = $('#hypebot_enabled').prop('checked'); hypeBotBar.toggle(settings.enabled); abortController?.abort(); + Object.assign(extension_settings.hypebot, settings); saveSettingsDebounced(); }); $('#hypebot_name').val(settings.name).on('input', () => { settings.name = String($('#hypebot_name').val()); + Object.assign(extension_settings.hypebot, settings); saveSettingsDebounced(); }); From b5a6257352fd79131a74035c6a20eb75cd571b22 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:51:59 +0300 Subject: [PATCH 5/7] Forgot that groups exist --- server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server.js b/server.js index 4c0497669..989427b1c 100644 --- a/server.js +++ b/server.js @@ -2783,6 +2783,7 @@ app.post('/getgroups', jsonParser, (_, response) => { const group = json5.parse(fileContents); const groupStat = fs.statSync(filePath); group['date_added'] = groupStat.birthtimeMs; + group['create_date'] = humanizedISO8601DateTime(groupStat.birthtimeMs); let chat_size = 0; let date_last_chat = 0; From a96aad6073dacceffbca7765e32c499923a29ab8 Mon Sep 17 00:00:00 2001 From: ThisIsPIRI Date: Fri, 8 Sep 2023 18:31:30 +0900 Subject: [PATCH 6/7] Make API tokenization work again for ooba --- server.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 0ae0d38cb..2b0065486 100644 --- a/server.js +++ b/server.js @@ -4005,8 +4005,10 @@ app.post("/tokenize_via_api", jsonParser, async function (request, response) { headers: { "Content-Type": "application/json" } }; - if (main_api == 'textgenerationwebui' && request.body.use_mancer) { - args.headers = Object.assign(args.headers, get_mancer_headers()); + if (main_api == 'textgenerationwebui') { + if (request.body.use_mancer) { + args.headers = Object.assign(args.headers, get_mancer_headers()); + } const data = await postAsync(api_server + "/v1/token-count", args); return response.send({ count: data['results'][0]['tokens'] }); } From ab460199ab229079a933591e93bb8b747819e96b Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:36:00 +0300 Subject: [PATCH 7/7] #1117 Fix typing indicator and auto-scroll breaking mobile layout --- public/script.js | 34 ++++++++++++++++++++++++---------- public/scripts/group-chats.js | 10 +++------- public/style.css | 3 ++- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/public/script.js b/public/script.js index c3a2bfb36..078319658 100644 --- a/public/script.js +++ b/public/script.js @@ -5410,17 +5410,18 @@ function select_rm_info(type, charId, previousCharId = null) { $('#rm_print_characters_pagination').pagination('go', page); waitUntilCondition(() => document.querySelector(selector) !== null).then(() => { - const element = $(selector).parent().get(0); + const parent = $('#rm_print_characters_block'); + const element = $(selector).parent(); - if (!element) { + if (element.length === 0) { console.log(`Could not find element for character ${charId}`); return; } - element.scrollIntoView({ behavior: 'smooth', block: 'start' }); - $(element).addClass('flash animated'); + parent.scrollTop(element.position().top + parent.scrollTop()); + element.addClass('flash animated'); setTimeout(function () { - $(element).removeClass('flash animated'); + element.removeClass('flash animated'); }, 5000); }); } catch (e) { @@ -5429,16 +5430,29 @@ function select_rm_info(type, charId, previousCharId = null) { } if (type === 'group_create') { - //for groups, ${charId} = data.id from group-chats.js createGroup() - const element = $(`#rm_characters_block [grid="${charId}"]`).get(0); - element.scrollIntoView({ behavior: 'smooth', block: 'start' }); + // Find the page at which the character is located + const charData = getEntitiesList({ doFilter: true }); + const charIndex = charData.findIndex((x) => String(x?.item?.id) === String(charId)); + + if (charIndex === -1) { + console.log(`Could not find group ${charId} in the list`); + return; + } + + const perPage = Number(localStorage.getItem('Characters_PerPage')); + const page = Math.floor(charIndex / perPage) + 1; + $('#rm_print_characters_pagination').pagination('go', page); + const parent = $('#rm_print_characters_block'); + const selector = `#rm_print_characters_block [grid="${charId}"]`; try { - if (element !== undefined || element !== null) { + waitUntilCondition(() => document.querySelector(selector) !== null).then(() => { + const element = $(selector); + parent.scrollTop(element.position().top + parent.scrollTop()); $(element).addClass('flash animated'); setTimeout(function () { $(element).removeClass('flash animated'); }, 5000); - } else { console.log('didnt find the element'); } + }); } catch (e) { console.error(e); } diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js index ee75a3571..bb2439280 100644 --- a/public/scripts/group-chats.js +++ b/public/scripts/group-chats.js @@ -582,10 +582,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) { typingIndicator .find(".typing_indicator_name") .text(characters[chId].name); - $("#chat").append(typingIndicator); - typingIndicator.show(200, function () { - typingIndicator.get(0).scrollIntoView({ behavior: "smooth" }); - }); + typingIndicator.show(); } // TODO: This is awful. Refactor this @@ -681,9 +678,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) { } } } finally { - // hide and reapply the indicator to the bottom of the list - typingIndicator.hide(200); - $("#chat").append(typingIndicator); + typingIndicator.hide(); is_group_generating = false; $("#send_textarea").attr("disabled", false); @@ -1109,6 +1104,7 @@ function select_group_chats(groupId, skipAnimation) { $("#rm_group_restore_avatar").toggle(!!group && isValidImageUrl(group.avatar_url)); $("#rm_group_filter").val("").trigger("input"); $(`input[name="rm_group_activation_strategy"][value="${replyStrategy}"]`).prop('checked', true); + $("#rm_group_chat_name").val(groupName); if (!skipAnimation) { selectRightMenuWithAnimation('rm_group_chats_block'); diff --git a/public/style.css b/public/style.css index d9f73a354..ef21e17c7 100644 --- a/public/style.css +++ b/public/style.css @@ -2768,6 +2768,7 @@ body .ui-widget-content li:hover { margin: 10px; opacity: 0.85; text-shadow: 0px 0px calc(var(--shadowWidth) * 1px) var(--SmartThemeShadowColor); + order: 9999; } .typing_indicator:after { @@ -3608,4 +3609,4 @@ a { height: 100vh; z-index: 9999; } -} \ No newline at end of file +}