From 7d034cba1104f8063d6f70ea35d38d892a222f37 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 18 Mar 2025 23:12:49 +0200 Subject: [PATCH] Remove forced newline separator from group join wrappers (#3722) * Remove forced newline separator from group join wrappers * Remove unnecessary ternary * Do not trim field wrappers --- public/scripts/group-chats.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js index 406724439..e068baf76 100644 --- a/public/scripts/group-chats.js +++ b/public/scripts/group-chats.js @@ -435,16 +435,18 @@ export function getGroupCharacterCards(groupId, characterId) { * @param {string} value Value to replace * @param {string} fieldName Name of the field * @param {string} characterName Name of the character + * @param {boolean} trim Whether to trim the value * @returns {string} Replaced text * */ - function customBaseChatReplace(value, fieldName, characterName) { + function customBaseChatReplace(value, fieldName, characterName, trim) { if (!value) { return ''; } // We should do the custom field name replacement first, and then run it through the normal macro engine with provided names value = value.replace(//gi, fieldName); - return baseChatReplace(value.trim(), name1, characterName); + value = trim ? value.trim() : value; + return baseChatReplace(value, name1, characterName); } /** @@ -467,13 +469,12 @@ export function getGroupCharacterCards(groupId, characterId) { } // Prepare and replace prefixes - const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName); - const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName); - const separator = power_user.instruct.wrap ? '\n' : ''; + const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName, false); + const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName, false); // Also run the macro replacement on the actual content - value = customBaseChatReplace(value, fieldName, characterName); + value = customBaseChatReplace(value, fieldName, characterName, true); - return `${prefix ? prefix + separator : ''}${value}${suffix ? separator + suffix : ''}`; + return `${prefix}${value}${suffix}`; } const scenarioOverride = chat_metadata['scenario'];