diff --git a/public/css/rm-groups.css b/public/css/rm-groups.css
index 4bc82ee6b..e7cbb2c95 100644
--- a/public/css/rm-groups.css
+++ b/public/css/rm-groups.css
@@ -58,6 +58,11 @@
cursor: unset;
}
+#rm_group_buttons textarea {
+ margin: 0px;
+ min-width: 200px;
+}
+
#rm_group_members,
#rm_group_add_members {
margin-top: 0.25rem;
diff --git a/public/index.html b/public/index.html
index 352885649..98170d1a8 100644
--- a/public/index.html
+++ b/public/index.html
@@ -4360,24 +4360,44 @@
diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js
index 2b5267ff2..36f324b94 100644
--- a/public/scripts/group-chats.js
+++ b/public/scripts/group-chats.js
@@ -9,9 +9,11 @@ import {
saveBase64AsFile,
PAGINATION_TEMPLATE,
getBase64Async,
+ resetScrollHeight,
+ initScrollHeight,
} from './utils.js';
import { RA_CountCharTokens, humanizedDateTime, dragElement, favsToHotswap, getMessageTimeStamp } from './RossAscends-mods.js';
-import { loadMovingUIState, sortEntitiesList } from './power-user.js';
+import { power_user, loadMovingUIState, sortEntitiesList } from './power-user.js';
import {
chat,
@@ -351,6 +353,30 @@ export function getGroupCharacterCards(groupId, characterId) {
return null;
}
+ /** Runs the macro engine on a text, with custom replace @param {string} value @param {string} characterName @param {string} fieldName @returns {string} */
+ function customBaseChatReplace(value, fieldName, characterName) {
+ // 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);
+ }
+
+ /** Prepares text with prefix/suffix for a character field @param {string} value @param {string} characterName @param {string} fieldName @returns {string} */
+ function replaceAndPrepareForJoin(value, characterName, fieldName) {
+ value = value.trim();
+ if (!value) {
+ return '';
+ }
+
+ // 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' : '';
+ // Also run the macro replacement on the actual content
+ value = customBaseChatReplace(value, fieldName, characterName);
+
+ return `${prefix ? prefix + separator : ''}${value}${suffix ? separator + suffix : ''}`;
+ }
+
const scenarioOverride = chat_metadata['scenario'];
let descriptions = [];
@@ -372,10 +398,10 @@ export function getGroupCharacterCards(groupId, characterId) {
continue;
}
- descriptions.push(baseChatReplace(character.description.trim(), name1, character.name));
- personalities.push(baseChatReplace(character.personality.trim(), name1, character.name));
- scenarios.push(baseChatReplace(character.scenario.trim(), name1, character.name));
- mesExamplesArray.push(baseChatReplace(character.mes_example.trim(), name1, character.name));
+ descriptions.push(replaceAndPrepareForJoin(character.description, character.name, 'Description'));
+ personalities.push(replaceAndPrepareForJoin(character.personality, character.name, 'Personality'));
+ scenarios.push(replaceAndPrepareForJoin(character.scenario, character.name, 'Scenario'));
+ mesExamplesArray.push(replaceAndPrepareForJoin(character.mes_example, character.name, 'Example Messages'));
}
const description = descriptions.filter(x => x.length).join('\n');
@@ -1093,6 +1119,8 @@ async function onGroupGenerationModeInput(e) {
let _thisGroup = groups.find((x) => x.id == openGroupId);
_thisGroup.generation_mode = Number(e.target.value);
await editGroup(openGroupId, false, false);
+
+ toggleHiddenControls(_thisGroup);
}
}
@@ -1105,6 +1133,15 @@ async function onGroupAutoModeDelayInput(e) {
}
}
+async function onGroupGenerationModeTemplateInput(e) {
+ if (openGroupId) {
+ let _thisGroup = groups.find((x) => x.id == openGroupId);
+ const prop = $(e.target).attr('setting');
+ _thisGroup[prop] = String(e.target.value);
+ await editGroup(openGroupId, false, false);
+ }
+}
+
async function onGroupNameInput() {
if (openGroupId) {
let _thisGroup = groups.find((x) => x.id == openGroupId);
@@ -1270,6 +1307,14 @@ async function onHideMutedSpritesClick(value) {
}
}
+function toggleHiddenControls(group, generationMode = null) {
+ const isJoin = [group_generation_mode.APPEND, group_generation_mode.APPEND_DISABLED].includes(generationMode ?? group?.generation_mode);
+ $('#rm_group_generation_mode_join_prefix').parent().toggle(isJoin);
+ $('#rm_group_generation_mode_join_suffix').parent().toggle(isJoin);
+ initScrollHeight($('#rm_group_generation_mode_join_prefix'));
+ initScrollHeight($('#rm_group_generation_mode_join_suffix'));
+}
+
function select_group_chats(groupId, skipAnimation) {
openGroupId = groupId;
newGroupMembers = [];
@@ -1305,6 +1350,10 @@ function select_group_chats(groupId, skipAnimation) {
$('#rm_group_hidemutedsprites').prop('checked', group && group.hideMutedSprites);
$('#rm_group_automode_delay').val(group?.auto_mode_delay ?? DEFAULT_AUTO_MODE_DELAY);
+ $('#rm_group_generation_mode_join_prefix').val(group?.generation_mode_join_prefix ?? '').attr('setting', 'generation_mode_join_prefix');
+ $('#rm_group_generation_mode_join_suffix').val(group?.generation_mode_join_suffix ?? '').attr('setting', 'generation_mode_join_suffix');
+ toggleHiddenControls(group, generationMode);
+
// bottom buttons
if (openGroupId) {
$('#rm_group_submit').hide();
@@ -1338,6 +1387,11 @@ function select_group_chats(groupId, skipAnimation) {
$('#rm_group_automode_label').hide();
}
+ // Toggle textbox sizes, as input events have not fired here
+ $('#rm_group_chats_block .autoSetHeight').each(element => {
+ resetScrollHeight(element);
+ });
+
eventSource.emit('groupSelected', { detail: { id: openGroupId, group: group } });
}
@@ -1796,6 +1850,10 @@ function doCurMemberListPopout() {
}
jQuery(() => {
+ $(document).on('input', '#rm_group_chats_block .autoSetHeight', function () {
+ resetScrollHeight($(this));
+ });
+
$(document).on('click', '.group_select', function () {
const groupId = $(this).attr('chid') || $(this).attr('grid') || $(this).data('id');
openGroupById(groupId);
@@ -1823,6 +1881,8 @@ jQuery(() => {
$('#rm_group_activation_strategy').on('change', onGroupActivationStrategyInput);
$('#rm_group_generation_mode').on('change', onGroupGenerationModeInput);
$('#rm_group_automode_delay').on('input', onGroupAutoModeDelayInput);
+ $('#rm_group_generation_mode_join_prefix').on('input', onGroupGenerationModeTemplateInput);
+ $('#rm_group_generation_mode_join_suffix').on('input', onGroupGenerationModeTemplateInput);
$('#group_avatar_button').on('input', uploadGroupAvatar);
$('#rm_group_restore_avatar').on('click', restoreGroupAvatar);
$(document).on('click', '.group_member .right_menu_button', onGroupActionClick);