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 -9Showing whitespace changes
public/css/promptmanager.css+6 -1
@@ -28,6 +28,11 @@
2828 color: var(--white50a);
2929}
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+
3136#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt_invisible {
3237 display: none;
3338}
@@ -260,7 +265,7 @@
260265}
261266
262267#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt .completion_prompt_manager_prompt_name .fa-solid.prompt-manager-overridden {
263268 margin-left: 5px3px;
264269 color: var(--SmartThemeQuoteColor);
265270 cursor: pointer;
266271 opacity: 0.8;
public/index.html+5 -1
@@ -6113,8 +6113,12 @@
61136113 <label for="completion_prompt_manager_popup_entry_form_role">
61146114 <span data-i18n="Role">Role</span>
61156115 </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>
61176120 <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role">
6121+ <option data-i18n="Unspecified" value="">Unspecified</option>
61186122 <option data-i18n="System" value="system">System</option>
61196123 <option data-i18n="User" value="user">User</option>
61206124 <option data-i18n="AI Assistant" value="assistant">AI Assistant</option>
public/scripts/PromptManager.js+19 -7
@@ -430,7 +430,7 @@ class PromptManager {
430430 }
431431
432432 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_name').value = prompt.name;
433433 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_role').value = 'system';
434434 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_prompt').value = prompt.content ?? '';
435435 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_position').value = prompt.injection_position ?? 0;
436436 document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_depth').value = prompt.injection_depth ?? DEFAULT_DEPTH;
@@ -1208,7 +1208,7 @@ class PromptManager {
12081208 const forbidOverridesBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block');
12091209
12101210 nameField.value = prompt.name ?? '';
12111211 roleField.value = prompt.role ?? 'system';
12121212 promptField.value = prompt.content ?? '';
12131213 promptField.disabled = prompt.marker ?? false;
12141214 injectionPositionField.value = prompt.injection_position ?? INJECTION_POSITION.RELATIVE;
@@ -1518,7 +1518,7 @@ class PromptManager {
15181518 let detachSpanHtml = '';
15191519 if (this.isPromptDeletionAllowed(prompt)) {
15201520 detachSpanHtml = `
15211521 <span title="Remove" class="prompt-manager-detach-action caution fa-solid fa-chain-broken fa-xs"></span>
15221522 `;
15231523 } else {
15241524 detachSpanHtml = '<span class="fa-solid"></span>';
@@ -1527,7 +1527,7 @@ class PromptManager {
15271527 let editSpanHtml = '';
15281528 if (this.isPromptEditAllowed(prompt)) {
15291529 editSpanHtml = `
15301530 <span title="edit" class="prompt-manager-edit-action fa-solid fa-pencil fa-xs"></span>
15311531 `;
15321532 } else {
15331533 editSpanHtml = '<span class="fa-solid"></span>';
@@ -1543,6 +1543,7 @@ class PromptManager {
15431543 }
15441544
15451545 const encodedName = escapeHtml(prompt.name);
1546+ const isRolePrompt = !!prompt.role;
15461547 const isMarkerPrompt = prompt.marker && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE;
15471548 const isSystemPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && !prompt.forbid_overrides;
15481549 const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides;
@@ -1550,16 +1551,27 @@ class PromptManager {
15501551 const isInjectionPrompt = prompt.injection_position === INJECTION_POSITION.ABSOLUTE;
15511552 const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier);
15521553 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+
15531564 listItemHtml += `
15541565 <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${escapeHtml(prompt.identifier)}">
15551566 <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}">
15561567 ${isMarkerPrompt ? '<span class="fa-fw fa-solid fa-thumb-tack" title="Marker"></span>' : ''}
15571568 ${isSystemPrompt ? '<span class="fa-fw fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''}
15581569 ${isImportantPrompt ? '<span class="fa-fw fa-solid fa-star" title="Important Prompt"></span>' : ''}
15591570 ${isUserPrompt ? '<span class="fa-fw fa-solid fa-userasterisk" title="UserPreset Prompt"></span>' : ''}
15601571 ${isInjectionPrompt ? '<span class="fa-fw fa-solid fa-syringe" title="In-Chat Injection"></span>' : ''}
15611572 ${this.isPromptInspectionAllowed(prompt) ? `<a title="${encodedName}" class="prompt-manager-inspect-action">${encodedName}</a>` : `<span title="${encodedName}">${encodedName}</span>`}
15621573 ${isInjectionPromptisRolePrompt ? `<smallspan classdata-role="${escapeHtml(prompt-manager.role)}" class="fa-injectionxs fa-depthsolid ${roleIcon}">@ title="${prompt.injection_depthroleTitle}"></smallspan>` : ''}
1574+ ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${escapeHtml(prompt.injection_depth)}</small>` : ''}
15631575 ${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''}
15641576 </span>
15651577 <span>