From 8e1dad680033c1bfb9e2c169b0eaecfb36643801 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Fri, 6 Sep 2024 01:48:21 +0900 Subject: [PATCH] initial reversion commit --- public/index.html | 44 ++++++++++++++++----------------- public/script.js | 24 ++++++++++++------ public/scripts/instruct-mode.js | 14 ++++++++--- public/scripts/power-user.js | 20 +++++++++------ public/scripts/utils.js | 7 +++++- public/style.css | 1 + 6 files changed, 68 insertions(+), 42 deletions(-) diff --git a/public/index.html b/public/index.html index dffe456df..fc67b8966 100644 --- a/public/index.html +++ b/public/index.html @@ -3089,14 +3089,14 @@ Story String -
+
-
+
@@ -3104,7 +3104,7 @@ Chat Start
-
+
@@ -3182,7 +3182,7 @@
-
+
-
+
@@ -3323,7 +3323,7 @@
-
+
-
+
@@ -3361,38 +3361,38 @@ System Prompt Suffix
-
+
User Message Prefix -
+
User Message Suffix -
+
Assistant Message Prefix -
+
Assistant Message Suffix -
+
System Message Prefix -
+
System Message Suffix -
+
@@ -3408,37 +3408,37 @@
First Assistant Prefix -
+
Last Assistant Prefix -
+
First User Prefix -
+
Last User Prefix -
+
System Instruction Prefix -
+
Stop Sequence -
+
User Filler Message -
+
@@ -6504,4 +6504,4 @@ - + \ No newline at end of file diff --git a/public/script.js b/public/script.js index 8d9197280..c501c437e 100644 --- a/public/script.js +++ b/public/script.js @@ -10577,6 +10577,9 @@ jQuery(async function () { stopScriptExecution(); }); + const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/'); + const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx)); + $('.drawer-toggle').on('click', function () { var icon = $(this).find('.drawer-icon'); var drawer = $(this).parent().find('.drawer-content'); @@ -10616,10 +10619,13 @@ jQuery(async function () { } // Set the height of "autoSetHeight" textareas within the drawer to their scroll height - $(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () { - await resetScrollHeight($(this)); - return; - }); + + if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + $(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () { + await resetScrollHeight($(this)); + return; + }); + } } else if (drawerWasOpenAlready) { //to close manually icon.toggleClass('closedIcon openIcon'); @@ -10691,10 +10697,12 @@ jQuery(async function () { $(this).closest('.inline-drawer').find('.inline-drawer-content').stop().slideToggle(); // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height - $(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () { - await resetScrollHeight($(this)); - return; - }); + if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + $(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () { + await resetScrollHeight($(this)); + return; + }); + } }); $(document).on('click', '.inline-drawer-maximize', function () { diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index a1bac800c..23edce78f 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -7,7 +7,7 @@ import { power_user, context_presets, } from './power-user.js'; -import { regexFromString } from './utils.js'; +import { regexFromString, resetScrollHeight } from './utils.js'; /** * @type {any[]} Instruct mode presets. @@ -42,6 +42,9 @@ const controls = [ { id: 'instruct_system_same_as_user', property: 'system_same_as_user', isCheckbox: true, trigger: true }, ]; +const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/'); +const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx)); + /** * Migrates instruct mode settings into the evergreen format. * @param {object} settings Instruct mode settings. @@ -95,11 +98,14 @@ export async function loadInstructMode(data) { if (control.isCheckbox) { $element.prop('checked', power_user.instruct[control.property]); } else { - $element[0].innerText = (power_user.instruct[control.property]); + $element.val(power_user.instruct[control.property]); } $element.on('input', async function () { - power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText; + power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this).val; + if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + await resetScrollHeight($(this)); + } saveSettingsDebounced(); }); @@ -663,7 +669,7 @@ jQuery(() => { if (control.isCheckbox) { $element.prop('checked', power_user.instruct[control.property]).trigger('input'); } else { - $element[0].innerText = (power_user.instruct[control.property]); + $element.val(power_user.instruct[control.property]); $element.trigger('input'); } } diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 93b974252..f57a15914 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -105,6 +105,9 @@ export const persona_description_positions = { NONE: 9, }; +const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/'); +const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx)); + let power_user = { tokenizer: tokenizers.BEST_MATCH, token_padding: 64, @@ -1740,20 +1743,23 @@ async function loadContextSettings() { if (control.isCheckbox) { $element.prop('checked', power_user.context[control.property]); } else { - $element[0].innerText = power_user.context[control.property]; + $element.val(power_user.context[control.property]); } console.log(`Setting ${$element.prop('id')} to ${power_user.context[control.property]}`); // If the setting already exists, no need to duplicate it // TODO: Maybe check the power_user object for the setting instead of a flag? - $element.on('input keyup', async function () { - const value = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText; + $element.on('input', async function () { + const value = control.isCheckbox ? !!$(this).prop('checked') : $(this).val(); if (control.isGlobalSetting) { power_user[control.property] = value; } else { power_user.context[control.property] = value; } - + console.log(`Setting ${$element.prop('id')} to ${value}`); + if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + await resetScrollHeight($(this)); + } saveSettingsDebounced(); }); }); @@ -1793,7 +1799,7 @@ async function loadContextSettings() { .prop('checked', control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]) .trigger('input'); } else { - $element[0].innerText = (control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]); + $element.val(control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]); $element.trigger('input'); } } @@ -3096,7 +3102,7 @@ $(document).ready(() => { }); $('#start_reply_with').on('input', function () { - power_user.user_prompt_bias = String($(this)[0].innerText); + power_user.user_prompt_bias = String($(this).val); saveSettingsDebounced(); }); @@ -3628,7 +3634,7 @@ $(document).ready(() => { }); $('#custom_stopping_strings').on('input', function () { - power_user.custom_stopping_strings = String($(this)[0].innerText).trim(); + power_user.custom_stopping_strings = String($(this).val).trim(); saveSettingsDebounced(); }); diff --git a/public/scripts/utils.js b/public/scripts/utils.js index 8f0ca59a7..025eb599e 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -2027,8 +2027,13 @@ export function toggleDrawer(drawer, expand = true) { content.style.display = 'none'; } + const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/'); + const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx)); + // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height - content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight); + if (chromeUaIdx == -1 || Number(chromeVersion) < 123) { + content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight); + } } export async function fetchFaFile(name) { diff --git a/public/style.css b/public/style.css index b75b776b8..e59fc75ef 100644 --- a/public/style.css +++ b/public/style.css @@ -1176,6 +1176,7 @@ textarea { textarea.autoSetHeight { max-height: 50vh; max-height: 50dvh; + field-sizing: content; } input,