initial reversion commit

8e1dad680033c1bfb9e2c169b0eaecfb36643801

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

6 files changed, +58 -32Showing whitespace changes
public/index.html+21 -21
@@ -3089,14 +3089,14 @@
30893089 <small data-i18n="Story String">Story String</small>
30903090 <i class="editor_maximize fa-solid fa-maximize right_menu_button" data-for="context_story_string" title="Expand the editor" data-i18n="[title]Expand the editor"></i>
30913091 </label>
30923092 <div contenteditable="true"textarea id="context_story_string" class="text_pole textarea_compact autoSetHeight"></divtextarea>
30933093 <div class="flex-container">
30943094 <div class="flex1">
30953095 <label for="context_example_separator">
30963096 <small data-i18n="Example Separator">Example Separator</small>
30973097 </label>
30983098 <div>
30993099 <div contenteditable="true"textarea id="context_example_separator" class="text_pole textarea_compact autoSetHeight"></divtextarea>
31003100 </div>
31013101 </div>
31023102 <div class="flex1">
@@ -3104,7 +3104,7 @@
31043104 <small data-i18n="Chat Start">Chat Start</small>
31053105 </label>
31063106 <div>
31073107 <div contenteditable="true"textarea id="context_chat_start" class="text_pole textarea_compact autoSetHeight"></divtextarea>
31083108 </div>
31093109 </div>
31103110 </div>
@@ -3182,7 +3182,7 @@
31823182 </small>
31833183 </div>
31843184 <div>
31853185 <div contenteditable="true"textarea id="custom_stopping_strings" class="text_pole textarea_compact monospace autoSetHeight"></divtextarea>
31863186 </div>
31873187 <label class="checkbox_label" for="custom_stopping_strings_macro">
31883188 <input id="custom_stopping_strings_macro" type="checkbox" checked>
@@ -3241,7 +3241,7 @@
32413241 <small data-i18n="System Prompt">System Prompt</small>
32423242 <i class="editor_maximize fa-solid fa-maximize right_menu_button" data-for="instruct_system_prompt" title="Expand the editor" data-i18n="[title]Expand the editor"></i>
32433243 </label>
32443244 <div contenteditable="true"textarea id="instruct_system_prompt" class="text_pole textarea_compact autoSetHeight"></divtextarea>
32453245 </div>
32463246
32473247 <div>
@@ -3323,7 +3323,7 @@
33233323 </span>
33243324 </small>
33253325 <div>
33263326 <div contenteditable="true"textarea id="start_reply_with" class="text_pole textarea_compact autoSetHeight"></divtextarea>
33273327 </div>
33283328 <label class="checkbox_label" for="chat-show-reply-prefix-checkbox">
33293329 <input id="chat-show-reply-prefix-checkbox" type="checkbox" />
@@ -3353,7 +3353,7 @@
33533353 <small data-i18n="System Prompt Prefix">System Prompt Prefix</small>
33543354 </label>
33553355 <div>
33563356 <div contenteditable="true"textarea id="instruct_system_sequence_prefix" class="text_pole textarea_compact autoSetHeight"></divtextarea>
33573357 </div>
33583358 </div>
33593359 <div class="flexAuto" title="Inserted after a System prompt." data-i18n="[title]Inserted after a System prompt.">
@@ -3361,38 +3361,38 @@
33613361 <small data-i18n="System Prompt Suffix">System Prompt Suffix</small>
33623362 </label>
33633363 <div>
33643364 <div contenteditable="true"textarea id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></divtextarea>
33653365 </div>
33663366 </div>
33673367 </div>
33683368 <div class="flex-container">
33693369 <div class="flexAuto" title="Inserted before a User message and as a last prompt line when impersonating." data-i18n="[title]Inserted before a User message and as a last prompt line when impersonating.">
33703370 <small data-i18n="User Prefix">User Message Prefix</small>
33713371 <div contenteditable="true"textarea id="instruct_input_sequence" class="text_pole textarea_compact autoSetHeight"></divtextarea>
33723372 </div>
33733373 <div class="flexAuto" title="Inserted after a User message." data-i18n="[title]Inserted after a User message.">
33743374 <small data-i18n="User Suffix">User Message Suffix</small>
33753375 <div contenteditable="true"textarea id="instruct_input_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></divtextarea>
33763376 </div>
33773377 </div>
33783378 <div class="flex-container">
33793379 <div class="flexAuto" title="Inserted before an Assistant message and as a last prompt line when generating an AI reply." data-i18n="[title]Inserted before an Assistant message and as a last prompt line when generating an AI reply.">
33803380 <small data-i18n="Assistant Prefix">Assistant Message Prefix</small>
33813381 <div contenteditable="true"textarea id="instruct_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></divtextarea>
33823382 </div>
33833383 <div class="flexAuto" title="Inserted after an Assistant message." data-i18n="[title]Inserted after an Assistant message.">
33843384 <small data-i18n="Assistant Suffix">Assistant Message Suffix</small>
33853385 <div contenteditable="true"textarea id="instruct_output_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></divtextarea>
33863386 </div>
33873387 </div>
33883388 <div class="flex-container">
33893389 <div class="flexAuto" id="instruct_system_sequence_block" title="Inserted before a System (added by slash commands or extensions) message." data-i18n="[title]Inserted before a System (added by slash commands or extensions) message.">
33903390 <small data-i18n="System Prefix">System Message Prefix</small>
33913391 <div contenteditable="true"textarea id="instruct_system_sequence" class="text_pole textarea_compact autoSetHeight"></divtextarea>
33923392 </div>
33933393 <div class="flexAuto" id="instruct_system_suffix_block" title="Inserted after a System message." data-i18n="[title]Inserted after a System message.">
33943394 <small data-i18n="System Suffix">System Message Suffix</small>
33953395 <div contenteditable="true"textarea id="instruct_system_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></divtextarea>
33963396 </div>
33973397 </div>
33983398 <div class="flexBasis100p" title="If enabled, System Sequences will be the same as User Sequences." data-i18n="[title]If enabled, System Sequences will be the same as User Sequences.">
@@ -3408,37 +3408,37 @@
34083408 <div class="flex-container">
34093409 <div class="flexAuto" title="Inserted before the first Assistant's message." data-i18n="[title]Inserted before the first Assistant's message.">
34103410 <small data-i18n="First Assistant Prefix">First Assistant Prefix</small>
34113411 <div contenteditable="true"textarea id="instruct_first_output_sequence" class="text_pole textarea_compact autoSetHeight"></divtextarea>
34123412 </div>
34133413 <div class="flexAuto" title="Inserted before the last Assistant's message or as a last prompt line when generating an AI reply (except a neutral/system role)." data-i18n="[title]instruct_last_output_sequence">
34143414 <small data-i18n="Last Assistant Prefix">Last Assistant Prefix</small>
34153415 <div contenteditable="true"textarea id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></divtextarea>
34163416 </div>
34173417 </div>
34183418 <div class="flex-container">
34193419 <div class="flexAuto" title="Inserted before the first User's message." data-i18n="[title]Inserted before the first User's message.">
34203420 <small data-i18n="First User Prefix">First User Prefix</small>
34213421 <div contenteditable="true"textarea id="instruct_first_input_sequence" class="text_pole textarea_compact autoSetHeight"></divtextarea>
34223422 </div>
34233423 <div class="flexAuto" title="Inserted before the last User's message." data-i18n="[title]instruct_last_input_sequence">
34243424 <small data-i18n="Last User Prefix">Last User Prefix</small>
34253425 <div contenteditable="true"textarea id="instruct_last_input_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></divtextarea>
34263426 </div>
34273427 </div>
34283428 <div class="flex-container">
34293429 <div class="flexAuto" title="Will be inserted as a last prompt line when using system/neutral generation." data-i18n="[title]Will be inserted as a last prompt line when using system/neutral generation.">
34303430 <small data-i18n="System Instruction Prefix">System Instruction Prefix</small>
34313431 <div contenteditable="true"textarea id="instruct_last_system_sequence" class="text_pole textarea_compact autoSetHeight"></divtextarea>
34323432 </div>
34333433 <div class="flexAuto" title="If a stop sequence is generated, everything past it will be removed from the output (inclusive)." data-i18n="[title]If a stop sequence is generated, everything past it will be removed from the output (inclusive).">
34343434 <small data-i18n="Stop Sequence">Stop Sequence</small>
34353435 <div contenteditable="true"textarea id="instruct_stop_sequence" class="text_pole textarea_compact autoSetHeight"></divtextarea>
34363436 </div>
34373437 </div>
34383438 <div class="flex-container">
34393439 <div class="flexAuto" title="Will be inserted at the start of the chat history if it doesn't start with a User message." data-i18n="[title]Will be inserted at the start of the chat history if it doesn't start with a User message.">
34403440 <small data-i18n="User Filler Message">User Filler Message</small>
34413441 <div contenteditable="true"textarea id="instruct_user_alignment_message" class="text_pole textarea_compact autoSetHeight"></divtextarea>
34423442 </div>
34433443 </div>
34443444 </div>
public/script.js+8 -0
@@ -10577,6 +10577,9 @@ jQuery(async function () {
1057710577 stopScriptExecution();
1057810578 });
1057910579
10580+ const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
10581+ const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
10582+
1058010583 $('.drawer-toggle').on('click', function () {
1058110584 var icon = $(this).find('.drawer-icon');
1058210585 var drawer = $(this).parent().find('.drawer-content');
@@ -10616,10 +10619,13 @@ jQuery(async function () {
1061610619 }
1061710620
1061810621 // Set the height of "autoSetHeight" textareas within the drawer to their scroll height
10622+
10623+ if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
1061910624 $(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () {
1062010625 await resetScrollHeight($(this));
1062110626 return;
1062210627 });
10628+ }
1062310629
1062410630 } else if (drawerWasOpenAlready) { //to close manually
1062510631 icon.toggleClass('closedIcon openIcon');
@@ -10691,10 +10697,12 @@ jQuery(async function () {
1069110697 $(this).closest('.inline-drawer').find('.inline-drawer-content').stop().slideToggle();
1069210698
1069310699 // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height
10700+ if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
1069410701 $(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () {
1069510702 await resetScrollHeight($(this));
1069610703 return;
1069710704 });
10705+ }
1069810706 });
1069910707
1070010708 $(document).on('click', '.inline-drawer-maximize', function () {
public/scripts/instruct-mode.js+10 -4
@@ -7,7 +7,7 @@ import {
77 power_user,
88 context_presets,
99} from './power-user.js';
1010import { regexFromString, resetScrollHeight } from './utils.js';
1111
1212/**
1313 * @type {any[]} Instruct mode presets.
@@ -42,6 +42,9 @@ const controls = [
4242 { id: 'instruct_system_same_as_user', property: 'system_same_as_user', isCheckbox: true, trigger: true },
4343];
4444
45+const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
46+const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
47+
4548/**
4649 * Migrates instruct mode settings into the evergreen format.
4750 * @param {object} settings Instruct mode settings.
@@ -95,11 +98,14 @@ export async function loadInstructMode(data) {
9598 if (control.isCheckbox) {
9699 $element.prop('checked', power_user.instruct[control.property]);
97100 } else {
98101 $element[0].innerText = val(power_user.instruct[control.property]);
99102 }
100103
101104 $element.on('input', async function () {
102105 power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerTextval;
106+ if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
107+ await resetScrollHeight($(this));
108+ }
103109 saveSettingsDebounced();
104110 });
105111
@@ -663,7 +669,7 @@ jQuery(() => {
663669 if (control.isCheckbox) {
664670 $element.prop('checked', power_user.instruct[control.property]).trigger('input');
665671 } else {
666672 $element[0].innerText = val(power_user.instruct[control.property]);
667673 $element.trigger('input');
668674 }
669675 }
public/scripts/power-user.js+13 -7
@@ -105,6 +105,9 @@ export const persona_description_positions = {
105105 NONE: 9,
106106};
107107
108+const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
109+const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
110+
108111let power_user = {
109112 tokenizer: tokenizers.BEST_MATCH,
110113 token_padding: 64,
@@ -1740,20 +1743,23 @@ async function loadContextSettings() {
17401743 if (control.isCheckbox) {
17411744 $element.prop('checked', power_user.context[control.property]);
17421745 } else {
17431746 $element[0].innerText = val(power_user.context[control.property]);
17441747 }
17451748 console.log(`Setting ${$element.prop('id')} to ${power_user.context[control.property]}`);
17461749
17471750 // If the setting already exists, no need to duplicate it
17481751 // TODO: Maybe check the power_user object for the setting instead of a flag?
17491752 $element.on('input keyup', async function () {
17501753 const value = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerTextval();
17511754 if (control.isGlobalSetting) {
17521755 power_user[control.property] = value;
17531756 } else {
17541757 power_user.context[control.property] = value;
17551758 }
1756-
1759+ console.log(`Setting ${$element.prop('id')} to ${value}`);
1760+ if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
1761+ await resetScrollHeight($(this));
1762+ }
17571763 saveSettingsDebounced();
17581764 });
17591765 });
@@ -1793,7 +1799,7 @@ async function loadContextSettings() {
17931799 .prop('checked', control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])
17941800 .trigger('input');
17951801 } else {
17961802 $element[0].innerText = val(control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]);
17971803 $element.trigger('input');
17981804 }
17991805 }
@@ -3096,7 +3102,7 @@ $(document).ready(() => {
30963102 });
30973103
30983104 $('#start_reply_with').on('input', function () {
30993105 power_user.user_prompt_bias = String($(this)[0].innerTextval);
31003106 saveSettingsDebounced();
31013107 });
31023108
@@ -3628,7 +3634,7 @@ $(document).ready(() => {
36283634 });
36293635
36303636 $('#custom_stopping_strings').on('input', function () {
36313637 power_user.custom_stopping_strings = String($(this)[0].innerTextval).trim();
36323638 saveSettingsDebounced();
36333639 });
36343640
public/scripts/utils.js+5 -0
@@ -2027,9 +2027,14 @@ export function toggleDrawer(drawer, expand = true) {
20272027 content.style.display = 'none';
20282028 }
20292029
2030+ const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
2031+ const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
2032+
20302033 // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height
2034+ if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
20312035 content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight);
20322036 }
2037+}
20332038
20342039export async function fetchFaFile(name) {
20352040 const style = document.createElement('style');
public/style.css+1 -0
@@ -1176,6 +1176,7 @@ textarea {
11761176textarea.autoSetHeight {
11771177 max-height: 50vh;
11781178 max-height: 50dvh;
1179+ field-sizing: content;
11791180}
11801181
11811182input,