diff --git a/public/index.html b/public/index.html index 58061ae80..f8b641bdd 100644 --- a/public/index.html +++ b/public/index.html @@ -90,6 +90,7 @@ + SillyTavern @@ -4385,6 +4386,7 @@
${characterName} +
@@ -4396,6 +4398,8 @@
+
+
diff --git a/public/scripts/chats.js b/public/scripts/chats.js new file mode 100644 index 000000000..d716a968f --- /dev/null +++ b/public/scripts/chats.js @@ -0,0 +1,73 @@ +// Move chat functions here from script.js (eventually) + +import { + chat, + getCurrentChatId, + hideSwipeButtons, + saveChatConditional, + showSwipeButtons, +} from "../script.js"; + +/** + * Mark message as hidden (system message). + * @param {number} messageId Message ID + * @param {JQuery} messageBlock Message UI element + * @returns + */ +export async function hideChatMessage(messageId, messageBlock) { + const chatId = getCurrentChatId(); + + if (!chatId || isNaN(messageId)) return; + + const message = chat[messageId]; + + if (!message) return; + + message.is_system = true; + messageBlock.attr('is_system', String(true)); + + // Reload swipes. Useful when a last message is hidden. + hideSwipeButtons(); + showSwipeButtons(); + + await saveChatConditional(); +} + +/** + * Mark message as visible (non-system message). + * @param {number} messageId Message ID + * @param {JQuery} messageBlock Message UI element + * @returns + */ +export async function unhideChatMessage(messageId, messageBlock) { + const chatId = getCurrentChatId(); + + if (!chatId || isNaN(messageId)) return; + + const message = chat[messageId]; + + if (!message) return; + + message.is_system = false; + messageBlock.attr('is_system', String(false)); + + // Reload swipes. Useful when a last message is hidden. + hideSwipeButtons(); + showSwipeButtons(); + + await saveChatConditional(); +} + +jQuery(function() { + $(document).on('click', '.mes_hide', async function() { + const messageBlock = $(this).closest('.mes'); + const messageId = Number(messageBlock.attr('mesid')); + await hideChatMessage(messageId, messageBlock); + }); + + $(document).on('click', '.mes_unhide', async function() { + const messageBlock = $(this).closest('.mes'); + const messageId = Number(messageBlock.attr('mesid')); + await unhideChatMessage(messageId, messageBlock); + }); +}) diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index 63aea9d3e..2e5f07c73 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -119,19 +119,9 @@ const promptTemplates = { } const helpString = [ - `${m('(argument)')} – requests SD to make an image. Supported arguments:`, - '', - `Anything else would trigger a "free mode" to make SD generate whatever you prompted.
- example: '/sd apple tree' would generate a picture of an apple tree.`, -].join('
'); + `${m('(argument)')} – requests SD to make an image. Supported arguments: ${m(j(Object.values(triggerWords).flat()))}.`, + `Anything else would trigger a "free mode" to make SD generate whatever you prompted. Example: '/sd apple tree' would generate a picture of an apple tree.`, +].join(' '); const defaultPrefix = 'best quality, absurdres, aesthetic,'; const defaultNegative = 'lowres, bad anatomy, bad hands, text, error, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry'; diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index d7d485fa4..c15d8198f 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -31,6 +31,7 @@ import { getRegexedString, regex_placement } from "./extensions/regex/engine.js" import { chat_styles, power_user } from "./power-user.js"; import { autoSelectPersona } from "./personas.js"; import { getContext } from "./extensions.js"; +import { hideChatMessage, unhideChatMessage } from "./chats.js"; export { executeSlashCommands, registerSlashCommand, @@ -40,7 +41,7 @@ export { class SlashCommandParser { constructor() { this.commands = {}; - this.helpStrings = []; + this.helpStrings = {}; } addCommand(command, callback, aliases, helpString = '', interruptsGeneration = false, purgeFromMessage = true) { @@ -63,7 +64,7 @@ class SlashCommandParser { let aliasesString = `(alias: ${aliases.map(x => `/${x}`).join(', ')})`; stringBuilder += aliasesString; } - this.helpStrings.push(stringBuilder); + this.helpStrings[command] = stringBuilder; } parse(text) { @@ -107,7 +108,12 @@ class SlashCommandParser { } getHelpString() { - const listItems = this.helpStrings.map(x => `
  • ${x}
  • `).join('\n'); + const listItems = Object + .entries(this.helpStrings) + .sort((a, b) => a[0].localeCompare(b[0])) + .map(x => x[1]) + .map(x => `
  • ${x}
  • `) + .join('\n'); return `

    Slash commands:

      ${listItems}
    Slash commands can be batched into a single input by adding a pipe character | at the end, and then writing a new slash command.