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

7d034cba1104f8063d6f70ea35d38d892a222f37

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

Signed
1 files changed, +8 -7Ignore whitespace
public/scripts/group-chats.js+8 -7
@@ -435,16 +435,18 @@ export function getGroupCharacterCards(groupId, characterId) {
435 * @param {string} value Value to replace435 * @param {string} value Value to replace
436 * @param {string} fieldName Name of the field436 * @param {string} fieldName Name of the field
437 * @param {string} characterName Name of the character437 * @param {string} characterName Name of the character
438 * @param {boolean} trim Whether to trim the value
438 * @returns {string} Replaced text439 * @returns {string} Replaced text
439 * */440 * */
440 function customBaseChatReplace(value, fieldName, characterName) {441 function customBaseChatReplace(value, fieldName, characterName, trim) {
441 if (!value) {442 if (!value) {
442 return '';443 return '';
443 }444 }
444445
445 // We should do the custom field name replacement first, and then run it through the normal macro engine with provided names446 // We should do the custom field name replacement first, and then run it through the normal macro engine with provided names
446 value = value.replace(/<FIELDNAME>/gi, fieldName);447 value = value.replace(/<FIELDNAME>/gi, fieldName);
447 return baseChatReplace(value.trim(), name1, characterName);448 value = trim ? value.trim() : value;
449 return baseChatReplace(value, name1, characterName);
448 }450 }
449451
450 /**452 /**
@@ -467,13 +469,12 @@ export function getGroupCharacterCards(groupId, characterId) {
467 }469 }
468470
469 // Prepare and replace prefixes471 // Prepare and replace prefixes
470 const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName);472 const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName, false);
471 const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName);473 const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName, false);
472 const separator = power_user.instruct.wrap ? '\n' : '';
473 // Also run the macro replacement on the actual content474 // Also run the macro replacement on the actual content
474 value = customBaseChatReplace(value, fieldName, characterName);475 value = customBaseChatReplace(value, fieldName, characterName, true);
475476
476 return `${prefix ? prefix + separator : ''}${value}${suffix ? separator + suffix : ''}`;477 return `${prefix}${value}${suffix}`;
477 }478 }
478479
479 const scenarioOverride = chat_metadata['scenario'];480 const scenarioOverride = chat_metadata['scenario'];