Merge pull request #3242 from SillyTavern/role-icons-for-PM add prompt role icons to prompt manager

f47c98f85d77fffc61e38988b6d55e58eb31ff1f

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

Signed
3 files changed, +30 -9Ignore whitespace
public/css/promptmanager.css+6 -1
@@ -28,6 +28,11 @@
28 color: var(--white50a);28 color: var(--white50a);
29}29}
3030
31#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt .completion_prompt_manager_prompt_name .fa-solid[data-role] {
32 vertical-align: unset;
33 margin-left: 3px;
34}
35
31#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt_invisible {36#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt_invisible {
32 display: none;37 display: none;
33}38}
@@ -260,7 +265,7 @@
260}265}
261266
262#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt .completion_prompt_manager_prompt_name .fa-solid.prompt-manager-overridden {267#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt .completion_prompt_manager_prompt_name .fa-solid.prompt-manager-overridden {
263 margin-left: 5px;268 margin-left: 3px;
264 color: var(--SmartThemeQuoteColor);269 color: var(--SmartThemeQuoteColor);
265 cursor: pointer;270 cursor: pointer;
266 opacity: 0.8;271 opacity: 0.8;
public/index.html+5 -1
@@ -6113,8 +6113,12 @@
6113 <label for="completion_prompt_manager_popup_entry_form_role">6113 <label for="completion_prompt_manager_popup_entry_form_role">
6114 <span data-i18n="Role">Role</span>6114 <span data-i18n="Role">Role</span>
6115 </label>6115 </label>
6116 <div class="text_muted" data-i18n="To whom this message will be attributed.">To whom this message will be attributed.</div>6116 <div class="text_muted">
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>
6117 <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role">6120 <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role">
6121 <option data-i18n="Unspecified" value="">Unspecified</option>
6118 <option data-i18n="System" value="system">System</option>6122 <option data-i18n="System" value="system">System</option>
6119 <option data-i18n="User" value="user">User</option>6123 <option data-i18n="User" value="user">User</option>
6120 <option data-i18n="AI Assistant" value="assistant">AI Assistant</option>6124 <option data-i18n="AI Assistant" value="assistant">AI Assistant</option>
public/scripts/PromptManager.js+19 -7
@@ -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 = 'system';433 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_role').value = '';
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 ?? 'system';1211 roleField.value = prompt.role ?? '';
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;
@@ -1518,7 +1518,7 @@ class PromptManager {
1518 let detachSpanHtml = '';1518 let detachSpanHtml = '';
1519 if (this.isPromptDeletionAllowed(prompt)) {1519 if (this.isPromptDeletionAllowed(prompt)) {
1520 detachSpanHtml = `1520 detachSpanHtml = `
1521 <span title="Remove" class="prompt-manager-detach-action caution fa-solid fa-chain-broken"></span>1521 <span title="Remove" class="prompt-manager-detach-action caution fa-solid fa-chain-broken fa-xs"></span>
1522 `;1522 `;
1523 } else {1523 } else {
1524 detachSpanHtml = '<span class="fa-solid"></span>';1524 detachSpanHtml = '<span class="fa-solid"></span>';
@@ -1527,7 +1527,7 @@ class PromptManager {
1527 let editSpanHtml = '';1527 let editSpanHtml = '';
1528 if (this.isPromptEditAllowed(prompt)) {1528 if (this.isPromptEditAllowed(prompt)) {
1529 editSpanHtml = `1529 editSpanHtml = `
1530 <span title="edit" class="prompt-manager-edit-action fa-solid fa-pencil"></span>1530 <span title="edit" class="prompt-manager-edit-action fa-solid fa-pencil fa-xs"></span>
1531 `;1531 `;
1532 } else {1532 } else {
1533 editSpanHtml = '<span class="fa-solid"></span>';1533 editSpanHtml = '<span class="fa-solid"></span>';
@@ -1543,6 +1543,7 @@ class PromptManager {
1543 }1543 }
15441544
1545 const encodedName = escapeHtml(prompt.name);1545 const encodedName = escapeHtml(prompt.name);
1546 const isRolePrompt = !!prompt.role;
1546 const isMarkerPrompt = prompt.marker && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE;1547 const isMarkerPrompt = prompt.marker && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE;
1547 const isSystemPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && !prompt.forbid_overrides;1548 const isSystemPrompt = !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;1549 const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides;
@@ -1550,16 +1551,27 @@ class PromptManager {
1550 const isInjectionPrompt = prompt.injection_position === INJECTION_POSITION.ABSOLUTE;1551 const isInjectionPrompt = prompt.injection_position === INJECTION_POSITION.ABSOLUTE;
1551 const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier);1552 const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier);
1552 const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : '';1553 const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : '';
1554
1555 //add role icons to the right of prompt name
1556 const promptRoles = {
1557 system: { roleIcon: 'fa-cog', roleTitle: 'Prompt will be sent as System' },
1558 assistant: { roleIcon: 'fa-robot', roleTitle: 'Prompt will be sent as Assistant' },
1559 user: { roleIcon: 'fa-user', roleTitle: 'Prompt will be sent as User' },
1560 };
1561 const roleIcon = isRolePrompt ? promptRoles[prompt.role]?.roleIcon : '';
1562 const roleTitle = isRolePrompt ? promptRoles[prompt.role]?.roleTitle : '';
1563
1553 listItemHtml += `1564 listItemHtml += `
1554 <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${prompt.identifier}">1565 <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${escapeHtml(prompt.identifier)}">
1555 <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}">1566 <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}">
1556 ${isMarkerPrompt ? '<span class="fa-fw fa-solid fa-thumb-tack" title="Marker"></span>' : ''}1567 ${isMarkerPrompt ? '<span class="fa-fw fa-solid fa-thumb-tack" title="Marker"></span>' : ''}
1557 ${isSystemPrompt ? '<span class="fa-fw fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''}1568 ${isSystemPrompt ? '<span class="fa-fw fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''}
1558 ${isImportantPrompt ? '<span class="fa-fw fa-solid fa-star" title="Important Prompt"></span>' : ''}1569 ${isImportantPrompt ? '<span class="fa-fw fa-solid fa-star" title="Important Prompt"></span>' : ''}
1559 ${isUserPrompt ? '<span class="fa-fw fa-solid fa-user" title="User Prompt"></span>' : ''}1570 ${isUserPrompt ? '<span class="fa-fw fa-solid fa-asterisk" title="Preset Prompt"></span>' : ''}
1560 ${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>' : ''}
1561 ${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>`}
1562 ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${prompt.injection_depth}</small>` : ''}1573 ${isRolePrompt ? `<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>` : ''}
1563 ${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>' : ''}
1564 </span>1576 </span>
1565 <span>1577 <span>