Remove unspecified role, hide icons for non-custom prompts of non-system roles

e9c9dda3fb695399ed85aefbe9e9752c5fdb8411

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +6 -8Showing whitespace changes
public/index.html+0 -2
@@ -6115,10 +6115,8 @@
6115 </label>6115 </label>
6116 <div class="text_muted">6116 <div class="text_muted">
6117 <span data-i18n="To whom this message will be attributed.">To whom this message will be attributed.</span>6117 <span data-i18n="To whom this message will be attributed.">To whom this message will be attributed.</span>
6118 <span data-i18n="Unspecified = Prompt Manager decides.">Unspecified = Prompt Manager decides.</span>
6119 </div>6118 </div>
6120 <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role">6119 <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role">
6121 <option data-i18n="Unspecified" value="">Unspecified</option>
6122 <option data-i18n="System" value="system">System</option>6120 <option data-i18n="System" value="system">System</option>
6123 <option data-i18n="User" value="user">User</option>6121 <option data-i18n="User" value="user">User</option>
6124 <option data-i18n="AI Assistant" value="assistant">AI Assistant</option>6122 <option data-i18n="AI Assistant" value="assistant">AI Assistant</option>
public/scripts/PromptManager.js+6 -6
@@ -430,7 +430,7 @@ class PromptManager {
430 }430 }
431431
432 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_name').value = prompt.name;432 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_name').value = prompt.name;
433 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_role').value = '';433 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_role').value = 'system';
434 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_prompt').value = prompt.content ?? '';434 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_prompt').value = prompt.content ?? '';
435 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_position').value = prompt.injection_position ?? 0;435 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_position').value = prompt.injection_position ?? 0;
436 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_depth').value = prompt.injection_depth ?? DEFAULT_DEPTH;436 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_depth').value = prompt.injection_depth ?? DEFAULT_DEPTH;
@@ -1208,7 +1208,7 @@ class PromptManager {
1208 const forbidOverridesBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block');1208 const forbidOverridesBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block');
12091209
1210 nameField.value = prompt.name ?? '';1210 nameField.value = prompt.name ?? '';
1211 roleField.value = prompt.role ?? '';1211 roleField.value = prompt.role || 'system';
1212 promptField.value = prompt.content ?? '';1212 promptField.value = prompt.content ?? '';
1213 promptField.disabled = prompt.marker ?? false;1213 promptField.disabled = prompt.marker ?? false;
1214 injectionPositionField.value = prompt.injection_position ?? INJECTION_POSITION.RELATIVE;1214 injectionPositionField.value = prompt.injection_position ?? INJECTION_POSITION.RELATIVE;
@@ -1543,7 +1543,6 @@ class PromptManager {
1543 }1543 }
15441544
1545 const encodedName = escapeHtml(prompt.name);1545 const encodedName = escapeHtml(prompt.name);
1546 const isRolePrompt = !!prompt.role;
1547 const isMarkerPrompt = prompt.marker && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE;1546 const isMarkerPrompt = prompt.marker && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE;
1548 const isSystemPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && !prompt.forbid_overrides;1547 const isSystemPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && !prompt.forbid_overrides;
1549 const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides;1548 const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides;
@@ -1551,6 +1550,7 @@ class PromptManager {
1551 const isInjectionPrompt = prompt.injection_position === INJECTION_POSITION.ABSOLUTE;1550 const isInjectionPrompt = prompt.injection_position === INJECTION_POSITION.ABSOLUTE;
1552 const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier);1551 const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier);
1553 const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : '';1552 const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : '';
1553 const iconLookup = prompt.role === 'system' && (prompt.marker || prompt.system_prompt) ? '' : prompt.role;
15541554
1555 //add role icons to the right of prompt name1555 //add role icons to the right of prompt name
1556 const promptRoles = {1556 const promptRoles = {
@@ -1558,8 +1558,8 @@ class PromptManager {
1558 assistant: { roleIcon: 'fa-robot', roleTitle: 'Prompt will be sent as Assistant' },1558 assistant: { roleIcon: 'fa-robot', roleTitle: 'Prompt will be sent as Assistant' },
1559 user: { roleIcon: 'fa-user', roleTitle: 'Prompt will be sent as User' },1559 user: { roleIcon: 'fa-user', roleTitle: 'Prompt will be sent as User' },
1560 };1560 };
1561 const roleIcon = isRolePrompt ? promptRoles[prompt.role]?.roleIcon : '';1561 const roleIcon = promptRoles[iconLookup]?.roleIcon || '';
1562 const roleTitle = isRolePrompt ? promptRoles[prompt.role]?.roleTitle : '';1562 const roleTitle = promptRoles[iconLookup]?.roleTitle || '';
15631563
1564 listItemHtml += `1564 listItemHtml += `
1565 <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${escapeHtml(prompt.identifier)}">1565 <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${escapeHtml(prompt.identifier)}">
@@ -1570,7 +1570,7 @@ class PromptManager {
1570 ${isUserPrompt ? '<span class="fa-fw fa-solid fa-asterisk" title="Preset Prompt"></span>' : ''}1570 ${isUserPrompt ? '<span class="fa-fw fa-solid fa-asterisk" title="Preset Prompt"></span>' : ''}
1571 ${isInjectionPrompt ? '<span class="fa-fw fa-solid fa-syringe" title="In-Chat Injection"></span>' : ''}1571 ${isInjectionPrompt ? '<span class="fa-fw fa-solid fa-syringe" title="In-Chat Injection"></span>' : ''}
1572 ${this.isPromptInspectionAllowed(prompt) ? `<a title="${encodedName}" class="prompt-manager-inspect-action">${encodedName}</a>` : `<span title="${encodedName}">${encodedName}</span>`}1572 ${this.isPromptInspectionAllowed(prompt) ? `<a title="${encodedName}" class="prompt-manager-inspect-action">${encodedName}</a>` : `<span title="${encodedName}">${encodedName}</span>`}
1573 ${isRolePrompt ? `<span data-role="${escapeHtml(prompt.role)}" class="fa-xs fa-solid ${roleIcon}" title="${roleTitle}"></span>` : ''}1573 ${roleIcon ? `<span data-role="${escapeHtml(prompt.role)}" class="fa-xs fa-solid ${roleIcon}" title="${roleTitle}"></span>` : ''}
1574 ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${escapeHtml(prompt.injection_depth)}</small>` : ''}1574 ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${escapeHtml(prompt.injection_depth)}</small>` : ''}
1575 ${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''}1575 ${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''}
1576 </span>1576 </span>