Add "unset" value for PM prompt role, refactor icons display

227201a5fc981397792949033af8fc56ec1ce0ef

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

3 files changed, +17 -31Showing whitespace changes
public/css/promptmanager.css+4 -0
@@ -28,6 +28,10 @@
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+}
34+
3135#completion_prompt_manager #completion_prompt_manager_list .completion_prompt_manager_prompt_invisible {
3236 display: none;
3337}
public/index.html+1 -0
@@ -6115,6 +6115,7 @@
61156115 </label>
61166116 <div class="text_muted" data-i18n="To whom this message will be attributed.">To whom this message will be attributed.</div>
61176117 <select id="completion_prompt_manager_popup_entry_form_role" class="text_pole" name="role">
6118+ <option data-i18n="Default (unset)" value="">Default (unset)</option>
61186119 <option data-i18n="System" value="system">System</option>
61196120 <option data-i18n="User" value="user">User</option>
61206121 <option data-i18n="AI Assistant" value="assistant">AI Assistant</option>
public/scripts/PromptManager.js+12 -31
@@ -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;
@@ -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;
@@ -1552,36 +1553,16 @@ class PromptManager {
15521553 const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : '';
15531554
15541555 //add role icons to the right of prompt name
1555-
1556+ const promptRoles = {
1556- const hasRole = !!prompt.role;
1557+ system: { roleIcon: 'fa-cog', roleTitle: 'Prompt will be sent as System' },
1557- let roleIcon, roleTitle;
1558+ assistant: { roleIcon: 'fa-robot', roleTitle: 'Prompt will be sent as Assistant' },
1558- if (hasRole) {
1559+ user: { roleIcon: 'fa-user', roleTitle: 'Prompt will be sent as User' },
1559- switch (prompt.role) {
1560+ };
1560- case 'system':
1561+ const roleIcon = isRolePrompt ? promptRoles[prompt.role]?.roleIcon : '';
1561- roleIcon = 'fa-cog';
1562+ const roleTitle = isRolePrompt ? promptRoles[prompt.role]?.roleTitle : '';
1562- roleTitle = 'Prompt will be sent as System';
1563- break;
1564- case 'assistant':
1565- roleIcon = 'fa-robot';
1566- roleTitle = 'Prompt will be sent as Assistant';
1567- break;
1568- case 'user':
1569- roleIcon = 'fa-user';
1570- roleTitle = 'Prompt will be sent as User';
1571- }
1572-
1573- // not sure if this makes sense to include as 'markers' should not be sendable except by System, included in case I'm wrong.
1574- // if it shouldn't be changeable, we should remove that dropdown from editor for Marker prompts.
1575- /*
1576- if (isMarkerPrompt && prompt.role !== 'user' && prompt.role !== 'assistant' && prompt.role !== 'system') {
1577- roleIcon = 'fa-cog';
1578- roleTitle = 'ST Global Prompt is sent as System by default (but can be changed in Editor)';
1579- }
1580- */
1581- }
15821563
15831564 listItemHtml += `
15841565 <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass} ${importantClass}" data-pm-identifier="${escapeHtml(prompt.identifier)}">
15851566 <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}">
15861567 ${isMarkerPrompt ? '<span class="fa-fw fa-solid fa-thumb-tack" title="Marker"></span>' : ''}
15871568 ${isSystemPrompt ? '<span class="fa-fw fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''}
@@ -1589,8 +1570,8 @@ class PromptManager {
15891570 ${isUserPrompt ? '<span class="fa-fw fa-solid fa-user" title="Preset Prompt"></span>' : ''}
15901571 ${isInjectionPrompt ? '<span class="fa-fw fa-solid fa-syringe" title="In-Chat Injection"></span>' : ''}
15911572 ${this.isPromptInspectionAllowed(prompt) ? `<a title="${encodedName}" class="prompt-manager-inspect-action">${encodedName}</a>` : `<span title="${encodedName}">${encodedName}</span>`}
15921573 ${hasRoleisRolePrompt ? `<span data-role="${escapeHtml(prompt.role)}" class='"fa-xs fa-solid ${roleIcon}'" title='"${roleTitle}'"></span>` : ''}
15931574 ${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${escapeHtml(prompt.injection_depth)}</small>` : ''}
15941575 ${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''}
15951576 </span>
15961577 <span>