From 456e1124a3268646110331818b4fdec8d131c411 Mon Sep 17 00:00:00 2001 From: Yokayo Date: Tue, 21 May 2024 17:06:42 +0700 Subject: [PATCH 01/14] Revert "Remove prompt manager changes" This reverts commit a8c9fe4dceed9bbe8f66ac721489131de712ba76. Move HTML pieces to templates --- public/scripts/PromptManager.js | 107 +++++------------- .../promptManagerExportForCharacter.html | 4 + .../templates/promptManagerExportPopup.html | 12 ++ .../templates/promptManagerFooter.html | 11 ++ .../templates/promptManagerHeader.html | 12 ++ .../templates/promptManagerListHeader.html | 8 ++ 6 files changed, 78 insertions(+), 76 deletions(-) create mode 100644 public/scripts/templates/promptManagerExportForCharacter.html create mode 100644 public/scripts/templates/promptManagerExportPopup.html create mode 100644 public/scripts/templates/promptManagerFooter.html create mode 100644 public/scripts/templates/promptManagerHeader.html create mode 100644 public/scripts/templates/promptManagerListHeader.html diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index d45da25bf..bb7f90d90 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -6,6 +6,7 @@ import { Message, TokenHandler } from './openai.js'; import { power_user } from './power-user.js'; import { debounce, waitUntilCondition, escapeHtml } from './utils.js'; import { debounce_timeout } from './constants.js'; +import { renderTemplateAsync } from './templates.js' function debouncePromise(func, delay) { let timeoutId; @@ -702,16 +703,14 @@ class PromptManager { this.tryGenerate().finally(() => { this.profileEnd('filling context'); this.profileStart('render'); - this.renderPromptManager(); - this.renderPromptManagerListItems(); + this.renderPromptManager().then(() => this.renderPromptManagerListItems()); this.makeDraggable(); this.profileEnd('render'); }); } else { // Executed during live communication this.profileStart('render'); - this.renderPromptManager(); - this.renderPromptManagerListItems(); + this.renderPromptManager().then(() => this.renderPromptManagerListItems()); this.makeDraggable(); this.profileEnd('render'); } @@ -1338,7 +1337,7 @@ class PromptManager { /** * Empties, then re-assembles the container containing the prompt list. */ - renderPromptManager() { + async renderPromptManager() { let selectedPromptIndex = 0; const existingAppendSelect = document.getElementById(`${this.configuration.prefix}prompt_manager_footer_append_prompt`); if (existingAppendSelect instanceof HTMLSelectElement) { @@ -1354,19 +1353,9 @@ class PromptManager { `; const totalActiveTokens = this.tokenUsage; - - promptManagerDiv.insertAdjacentHTML('beforeend', ` -
- ${this.error ? errorDiv : ''} -
-
- Prompts -
-
Total Tokens: ${totalActiveTokens}
-
- -
- `); + + const headerHtml = await renderTemplateAsync('promptManagerHeader', {error: this.error, errorDiv, prefix: this.configuration.prefix, totalActiveTokens}); + promptManagerDiv.insertAdjacentHTML('beforeend', headerHtml); this.listElement = promptManagerDiv.querySelector(`#${this.configuration.prefix}prompt_manager_list`); @@ -1384,22 +1373,9 @@ class PromptManager { selectedPromptIndex = 0; } - const footerHtml = ` - - `; - const rangeBlockDiv = promptManagerDiv.querySelector('.range-block'); const headerDiv = promptManagerDiv.querySelector('.completion_prompt_manager_header'); + const footerHtml = await renderTemplateAsync('promptManagerFooter', {promptsHtml, prefix: this.configuration.prefix}); headerDiv.insertAdjacentHTML('afterend', footerHtml); rangeBlockDiv.querySelector('#prompt-manager-reset-character').addEventListener('click', this.handleCharacterReset); @@ -1410,23 +1386,9 @@ class PromptManager { footerDiv.querySelector('select').selectedIndex = selectedPromptIndex; // Add prompt export dialogue and options - const exportForCharacter = ` -
- Export for character - -
`; - const exportPopup = ` -
-
-
- Export all - -
- ${'global' === this.configuration.promptOrder.strategy ? '' : exportForCharacter} -
-
- `; - + + const exportForCharacter = await renderTemplateAsync('promptManagerExportForCharacter'); + let exportPopup = await renderTemplateAsync('promptManagerExportPopup', {isGlobalStrategy: 'global' === this.configuration.promptOrder.strategy, exportForCharacter}); rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup); // Destroy previous popper instance if it exists @@ -1460,43 +1422,36 @@ class PromptManager { /** * Empties, then re-assembles the prompt list */ - renderPromptManagerListItems() { + async renderPromptManagerListItems() { if (!this.serviceSettings.prompts) return; const promptManagerList = this.listElement; promptManagerList.innerHTML = ''; const { prefix } = this.configuration; - - let listItemHtml = ` -
  • - Name - - Tokens -
  • -
  • -
    -
  • - `; - - this.getPromptsForCharacter(this.activeCharacter).forEach(prompt => { + + const that = this; + + let listItem = await renderTemplateAsync('promptManagerListHeader', {prefix}); + + this.getPromptsForCharacter(this.activeCharacter).forEach(async function(prompt) { if (!prompt) return; - const listEntry = this.getPromptOrderEntry(this.activeCharacter, prompt.identifier); + const listEntry = that.getPromptOrderEntry(that.activeCharacter, prompt.identifier); const enabledClass = listEntry.enabled ? '' : `${prefix}prompt_manager_prompt_disabled`; const draggableClass = `${prefix}prompt_manager_prompt_draggable`; const markerClass = prompt.marker ? `${prefix}prompt_manager_marker` : ''; - const tokens = this.tokenHandler?.getCounts()[prompt.identifier] ?? 0; + const tokens = that.tokenHandler?.getCounts()[prompt.identifier] ?? 0; // Warn the user if the chat history goes below certain token thresholds. let warningClass = ''; let warningTitle = ''; - const tokenBudget = this.serviceSettings.openai_max_context - this.serviceSettings.openai_max_tokens; - if (this.tokenUsage > tokenBudget * 0.8 && + const tokenBudget = that.serviceSettings.openai_max_context - that.serviceSettings.openai_max_tokens; + if (that.tokenUsage > tokenBudget * 0.8 && 'chatHistory' === prompt.identifier) { - const warningThreshold = this.configuration.warningTokenThreshold; - const dangerThreshold = this.configuration.dangerTokenThreshold; + const warningThreshold = that.configuration.warningTokenThreshold; + const dangerThreshold = that.configuration.dangerTokenThreshold; if (tokens <= dangerThreshold) { warningClass = 'fa-solid tooltip fa-triangle-exclamation text_danger'; @@ -1510,7 +1465,7 @@ class PromptManager { const calculatedTokens = tokens ? tokens : '-'; let detachSpanHtml = ''; - if (this.isPromptDeletionAllowed(prompt)) { + if (that.isPromptDeletionAllowed(prompt)) { detachSpanHtml = ` `; @@ -1519,7 +1474,7 @@ class PromptManager { } let editSpanHtml = ''; - if (this.isPromptEditAllowed(prompt)) { + if (that.isPromptEditAllowed(prompt)) { editSpanHtml = ` `; @@ -1528,7 +1483,7 @@ class PromptManager { } let toggleSpanHtml = ''; - if (this.isPromptToggleAllowed(prompt)) { + if (that.isPromptToggleAllowed(prompt)) { toggleSpanHtml = ` `; @@ -1541,9 +1496,9 @@ class PromptManager { const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides; const isUserPrompt = !prompt.marker && !prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE; const isInjectionPrompt = !prompt.marker && prompt.injection_position === INJECTION_POSITION.ABSOLUTE; - const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier); + const isOverriddenPrompt = Array.isArray(that.overriddenPrompts) && that.overriddenPrompts.includes(prompt.identifier); const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; - listItemHtml += ` + listItem += `
  • ${prompt.marker ? '' : ''} @@ -1551,7 +1506,7 @@ class PromptManager { ${isImportantPrompt ? '' : ''} ${isUserPrompt ? '' : ''} ${isInjectionPrompt ? '' : ''} - ${this.isPromptInspectionAllowed(prompt) ? `${encodedName}` : encodedName} + ${that.isPromptInspectionAllowed(prompt) ? `${encodedName}` : encodedName} ${isInjectionPrompt ? `@ ${prompt.injection_depth}` : ''} ${isOverriddenPrompt ? '' : ''} @@ -1568,7 +1523,7 @@ class PromptManager { `; }); - promptManagerList.insertAdjacentHTML('beforeend', listItemHtml); + promptManagerList.insertAdjacentHTML('beforeend', listItem); // Now that the new elements are in the DOM, you can add the event listeners. Array.from(promptManagerList.getElementsByClassName('prompt-manager-detach-action')).forEach(el => { diff --git a/public/scripts/templates/promptManagerExportForCharacter.html b/public/scripts/templates/promptManagerExportForCharacter.html new file mode 100644 index 000000000..11d592aaf --- /dev/null +++ b/public/scripts/templates/promptManagerExportForCharacter.html @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/public/scripts/templates/promptManagerExportPopup.html b/public/scripts/templates/promptManagerExportPopup.html new file mode 100644 index 000000000..2141c6092 --- /dev/null +++ b/public/scripts/templates/promptManagerExportPopup.html @@ -0,0 +1,12 @@ +
    +
    +
    + Export all + +
    + {{#if isGlobalStrategy}} + {{else}} + {{exportForCharacter}} + {{/if}} +
    +
    \ No newline at end of file diff --git a/public/scripts/templates/promptManagerFooter.html b/public/scripts/templates/promptManagerFooter.html new file mode 100644 index 000000000..51302d059 --- /dev/null +++ b/public/scripts/templates/promptManagerFooter.html @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/public/scripts/templates/promptManagerHeader.html b/public/scripts/templates/promptManagerHeader.html new file mode 100644 index 000000000..bcdf51251 --- /dev/null +++ b/public/scripts/templates/promptManagerHeader.html @@ -0,0 +1,12 @@ +
    + {{#if error}} + {{errorDiv}} + {{/if}} +
    +
    + Prompts +
    +
    Total Tokens: {{totalActiveTokens}}
    +
    +
      +
      \ No newline at end of file diff --git a/public/scripts/templates/promptManagerListHeader.html b/public/scripts/templates/promptManagerListHeader.html new file mode 100644 index 000000000..24cb29526 --- /dev/null +++ b/public/scripts/templates/promptManagerListHeader.html @@ -0,0 +1,8 @@ +
    • + Name + + Tokens +
    • +
    • +
      +
    • \ No newline at end of file From 7efe9cf209bc49a2e53d194e3112993ce218d557 Mon Sep 17 00:00:00 2001 From: Yokayo Date: Tue, 21 May 2024 17:40:14 +0700 Subject: [PATCH 02/14] More localizable strings --- public/index.html | 41 ++++++++++++--------------------------- public/locales/ru-ru.json | 18 +++++++++++++---- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/public/index.html b/public/index.html index 55be1e155..9060ad690 100644 --- a/public/index.html +++ b/public/index.html @@ -1694,13 +1694,13 @@
      -
      @@ -4381,22 +4381,7 @@ - -
      -
      - - -
      -
      - - -
      -
      @@ -4454,8 +4439,8 @@
      - - + + @@ -5640,9 +5625,7 @@
      Language: -
      + SillyTavern is aimed at advanced users. @@ -6296,11 +6279,11 @@
      -
      -
      -
      -
      +
      +
      +
      +
      @@ -6402,4 +6385,4 @@ - + \ No newline at end of file diff --git a/public/locales/ru-ru.json b/public/locales/ru-ru.json index 1a3a1bc4a..7d73a774b 100644 --- a/public/locales/ru-ru.json +++ b/public/locales/ru-ru.json @@ -381,7 +381,7 @@ "Delete": "Удалить", "Cancel": "Отменить", "Advanced Defininitions": "Расширенное описание", - "Personality summary": "Сводка по личности", + "Personality summary": "Резюме по личности", "A brief description of the personality": "Краткое описание личности", "Scenario": "Сценарий", "Circumstances and context of the dialogue": "Обстоятельства и контекст диалога", @@ -627,7 +627,7 @@ "Most chats": "Больше всего чатов", "Least chats": "Меньше всего чатов", "Back": "Назад", - "Prompt Overrides": "Индивидуальный промпт", + "Prompt Overrides": "Индивидуальные промпты", "(For OpenAI/Claude/Scale APIs, Window/OpenRouter, and Instruct Mode)": "(для API OpenAI/Claude/Scale, Window/OpenRouter, а также режима Instruct)", "Insert {{original}} into either box to include the respective default prompt from system settings.": "Введите {{original}} в любое поле, чтобы вставить соответствующий промпт из системных настроек", "Main Prompt": "Основной промпт", @@ -872,7 +872,7 @@ "Assistant Prefill": "Префилл для ассистента", "Start Claude's answer with...": "Начать ответ Клода с...", "Use system prompt (Claude 2.1+ only)": "Использовать системный промпт (только Claude 2.1+)", - "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Отправлять системный промпт для поддерживаемых моделей. Если отключено, сообщение пользователя добавляется в начало промпта.", + "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Отправлять системный промпт для поддерживаемых моделей. Если отключено, в начало промпта добавляется сообщение пользователя.", "Prompts": "Промпты", "Total Tokens:": "Всего токенов:", "Insert prompt": "Вставить промпт", @@ -1273,5 +1273,15 @@ "To change your user avatar, use the buttons below or select a default persona in the Persona Management menu.": "Чтобы сменить аватарку, используйте кнопки ниже, либо выберите персону по умолчанию в меню управления персоной.", "These characters are the winners of character design contests and have outstandable quality.": "Персонажи наивысшего качества, одержавшие победу в конкурсе персонажей.", "Featured Characters": "Рекомендуемые персонажи", - "These characters are the finalists of character design contests and have remarkable quality.": "Персонажи отличного качества, финалисты конкурса персонажей." + "These characters are the finalists of character design contests and have remarkable quality.": "Персонажи отличного качества, финалисты конкурса персонажей.", + "Inline Image Quality": "Качество inline-изображений", + "openai_inline_image_quality_auto": "Автоопределение", + "openai_inline_image_quality_low": "Низкое", + "openai_inline_image_quality_high": "Высокое", + "Assistant Impersonation Prefill": "Префилл для ассистента при перевоплощении", + "Hide Chat Avatars": "Не показывать аватарки в чате", + "Hide avatars in chat messages.": "Скрыть аватарки сбоку от сообщений в чате", + "Flat": "Стандартный", + "Toggle character info panel": "Показать / скрыть инфо-панель", + "(For Chat Completion and Instruct Mode)": "(для Chat Completion и режима Instruct)" } From d2ce1e17b3182c471a770c00ba9cb3d798bf983a Mon Sep 17 00:00:00 2001 From: Yokayo Date: Tue, 21 May 2024 17:49:44 +0700 Subject: [PATCH 03/14] Wait this was not supposed to happen --- public/index.html | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/public/index.html b/public/index.html index 9060ad690..55be1e155 100644 --- a/public/index.html +++ b/public/index.html @@ -1694,13 +1694,13 @@
      -
      @@ -4381,7 +4381,22 @@ + +
      +
      + + +
      +
      + + +
      +
      @@ -4439,8 +4454,8 @@
      - - + + @@ -5625,7 +5640,9 @@
      Language:
      + + + SillyTavern is aimed at advanced users. @@ -6279,11 +6296,11 @@
      +
      +
      +
      +
      -
      -
      -
      -
      @@ -6385,4 +6402,4 @@ - \ No newline at end of file + From 0275f2ec1559b84d399c730eba14b32ec413850f Mon Sep 17 00:00:00 2001 From: Yokayo Date: Tue, 21 May 2024 17:53:05 +0700 Subject: [PATCH 04/14] Redo localizable strings --- public/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index 55be1e155..aaccc77de 100644 --- a/public/index.html +++ b/public/index.html @@ -1694,13 +1694,13 @@
      -
      @@ -4454,8 +4454,8 @@ - - + + From 97965b2de523295822b25de451cf7fd98d7d1b95 Mon Sep 17 00:00:00 2001 From: Yokayo Date: Thu, 23 May 2024 17:16:16 +0700 Subject: [PATCH 05/14] Fix templates --- public/scripts/templates/promptManagerFooter.html | 2 +- public/scripts/templates/promptManagerListHeader.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/scripts/templates/promptManagerFooter.html b/public/scripts/templates/promptManagerFooter.html index 51302d059..4e062dca4 100644 --- a/public/scripts/templates/promptManagerFooter.html +++ b/public/scripts/templates/promptManagerFooter.html @@ -1,6 +1,6 @@ diff --git a/public/scripts/templates/promptManagerExportPopup.html b/public/scripts/templates/promptManagerExportPopup.html index 2141c6092..0beae5446 100644 --- a/public/scripts/templates/promptManagerExportPopup.html +++ b/public/scripts/templates/promptManagerExportPopup.html @@ -6,7 +6,7 @@ {{#if isGlobalStrategy}} {{else}} - {{exportForCharacter}} + {{{exportForCharacter}}} {{/if}} - \ No newline at end of file + diff --git a/public/scripts/templates/promptManagerFooter.html b/public/scripts/templates/promptManagerFooter.html index 4e062dca4..ccd328c62 100644 --- a/public/scripts/templates/promptManagerFooter.html +++ b/public/scripts/templates/promptManagerFooter.html @@ -8,4 +8,4 @@ - \ No newline at end of file + diff --git a/public/scripts/templates/promptManagerListHeader.html b/public/scripts/templates/promptManagerListHeader.html index 808fbed3b..29d81965c 100644 --- a/public/scripts/templates/promptManagerListHeader.html +++ b/public/scripts/templates/promptManagerListHeader.html @@ -5,4 +5,4 @@

    • -
    • \ No newline at end of file + From 0ebac0e2af6fcd3831a1632a4c96a99b6186b9e3 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 24 May 2024 22:15:28 +0300 Subject: [PATCH 10/14] Pretty print PM exports --- public/scripts/PromptManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index a1085682e..2015e6ce0 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -1559,7 +1559,7 @@ class PromptManager { data: data, }; - const serializedObject = JSON.stringify(promptExport); + const serializedObject = JSON.stringify(promptExport, null, 4); const blob = new Blob([serializedObject], { type: 'application/json' }); const url = URL.createObjectURL(blob); const downloadLink = document.createElement('a'); From 1ed1e18304a7e1ff6adeafc9fee0bb123314d85e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 24 May 2024 22:23:04 +0300 Subject: [PATCH 11/14] Revert async forEach executor --- public/scripts/PromptManager.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index 2015e6ce0..102ea9e70 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -1432,28 +1432,26 @@ class PromptManager { const { prefix } = this.configuration; - const that = this; - let listItem = await renderTemplateAsync('promptManagerListHeader', { prefix }); - this.getPromptsForCharacter(this.activeCharacter).forEach(async function(prompt) { + this.getPromptsForCharacter(this.activeCharacter).forEach(prompt => { if (!prompt) return; - const listEntry = that.getPromptOrderEntry(that.activeCharacter, prompt.identifier); + const listEntry = this.getPromptOrderEntry(this.activeCharacter, prompt.identifier); const enabledClass = listEntry.enabled ? '' : `${prefix}prompt_manager_prompt_disabled`; const draggableClass = `${prefix}prompt_manager_prompt_draggable`; const markerClass = prompt.marker ? `${prefix}prompt_manager_marker` : ''; - const tokens = that.tokenHandler?.getCounts()[prompt.identifier] ?? 0; + const tokens = this.tokenHandler?.getCounts()[prompt.identifier] ?? 0; // Warn the user if the chat history goes below certain token thresholds. let warningClass = ''; let warningTitle = ''; - const tokenBudget = that.serviceSettings.openai_max_context - that.serviceSettings.openai_max_tokens; - if (that.tokenUsage > tokenBudget * 0.8 && + const tokenBudget = this.serviceSettings.openai_max_context - this.serviceSettings.openai_max_tokens; + if (this.tokenUsage > tokenBudget * 0.8 && 'chatHistory' === prompt.identifier) { - const warningThreshold = that.configuration.warningTokenThreshold; - const dangerThreshold = that.configuration.dangerTokenThreshold; + const warningThreshold = this.configuration.warningTokenThreshold; + const dangerThreshold = this.configuration.dangerTokenThreshold; if (tokens <= dangerThreshold) { warningClass = 'fa-solid tooltip fa-triangle-exclamation text_danger'; @@ -1467,7 +1465,7 @@ class PromptManager { const calculatedTokens = tokens ? tokens : '-'; let detachSpanHtml = ''; - if (that.isPromptDeletionAllowed(prompt)) { + if (this.isPromptDeletionAllowed(prompt)) { detachSpanHtml = ` `; @@ -1476,7 +1474,7 @@ class PromptManager { } let editSpanHtml = ''; - if (that.isPromptEditAllowed(prompt)) { + if (this.isPromptEditAllowed(prompt)) { editSpanHtml = ` `; @@ -1485,7 +1483,7 @@ class PromptManager { } let toggleSpanHtml = ''; - if (that.isPromptToggleAllowed(prompt)) { + if (this.isPromptToggleAllowed(prompt)) { toggleSpanHtml = ` `; @@ -1498,7 +1496,7 @@ class PromptManager { const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides; const isUserPrompt = !prompt.marker && !prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE; const isInjectionPrompt = !prompt.marker && prompt.injection_position === INJECTION_POSITION.ABSOLUTE; - const isOverriddenPrompt = Array.isArray(that.overriddenPrompts) && that.overriddenPrompts.includes(prompt.identifier); + const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier); const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; listItem += `
    • @@ -1508,7 +1506,7 @@ class PromptManager { ${isImportantPrompt ? '' : ''} ${isUserPrompt ? '' : ''} ${isInjectionPrompt ? '' : ''} - ${that.isPromptInspectionAllowed(prompt) ? `${encodedName}` : encodedName} + ${this.isPromptInspectionAllowed(prompt) ? `${encodedName}` : encodedName} ${isInjectionPrompt ? `@ ${prompt.injection_depth}` : ''} ${isOverriddenPrompt ? '' : ''} From 5c3ad3e0bc66609807137db0b6e8694b0aa89005 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 24 May 2024 22:23:55 +0300 Subject: [PATCH 12/14] Let's make the diff even cleaner! --- public/scripts/PromptManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index 102ea9e70..1faec140e 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -1432,7 +1432,7 @@ class PromptManager { const { prefix } = this.configuration; - let listItem = await renderTemplateAsync('promptManagerListHeader', { prefix }); + let listItemHtml = await renderTemplateAsync('promptManagerListHeader', { prefix }); this.getPromptsForCharacter(this.activeCharacter).forEach(prompt => { if (!prompt) return; @@ -1498,7 +1498,7 @@ class PromptManager { const isInjectionPrompt = !prompt.marker && prompt.injection_position === INJECTION_POSITION.ABSOLUTE; const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier); const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; - listItem += ` + listItemHtml += `
    • ${prompt.marker ? '' : ''} @@ -1523,7 +1523,7 @@ class PromptManager { `; }); - promptManagerList.insertAdjacentHTML('beforeend', listItem); + promptManagerList.insertAdjacentHTML('beforeend', listItemHtml); // Now that the new elements are in the DOM, you can add the event listeners. Array.from(promptManagerList.getElementsByClassName('prompt-manager-detach-action')).forEach(el => { From a717e2ace8bb26be4b1f6aa0d1e9001d586a713a Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 24 May 2024 22:25:18 +0300 Subject: [PATCH 13/14] Prefer const --- public/scripts/PromptManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index 1faec140e..9be84ae70 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -1390,7 +1390,7 @@ class PromptManager { // Add prompt export dialogue and options const exportForCharacter = await renderTemplateAsync('promptManagerExportForCharacter'); - let exportPopup = await renderTemplateAsync('promptManagerExportPopup', { isGlobalStrategy: 'global' === this.configuration.promptOrder.strategy, exportForCharacter }); + const exportPopup = await renderTemplateAsync('promptManagerExportPopup', { isGlobalStrategy: 'global' === this.configuration.promptOrder.strategy, exportForCharacter }); rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup); // Destroy previous popper instance if it exists From 761f903fdbb6c5ffc5040ab1705a1d50ea08587d Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 24 May 2024 22:27:24 +0300 Subject: [PATCH 14/14] Expand rightmost column a bit --- public/css/promptmanager.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/promptmanager.css b/public/css/promptmanager.css index 6cf4dd0d0..178682998 100644 --- a/public/css/promptmanager.css +++ b/public/css/promptmanager.css @@ -19,7 +19,7 @@ #completion_prompt_manager #completion_prompt_manager_list li { display: grid; - grid-template-columns: 4fr 80px 40px; + grid-template-columns: 4fr 80px 45px; margin-bottom: 0.5em; width: 100% }