Merge pull request #3731 from SillyTavern/fix-srw-trim Fix replacing user_prompt_bias on display

e3c465258e6bef90ce261e96cb7154051a738776

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

Signed
1 files changed, +3 -2Showing whitespace changes
public/script.js+3 -2
@@ -2069,8 +2069,9 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san
20692069 }
20702070
20712071 // Prompt bias replacement should be applied on the raw message
2072- if (!power_user.show_user_prompt_bias && ch_name && !isUser && !isSystem) {
2072+ const replacedPromptBias = power_user.user_prompt_bias && substituteParams(power_user.user_prompt_bias);
2073- mes = mes.replaceAll(substituteParams(power_user.user_prompt_bias), '');
2073+ if (!power_user.show_user_prompt_bias && ch_name && !isUser && !isSystem && replacedPromptBias && mes.startsWith(replacedPromptBias)) {
2074+ mes = mes.slice(replacedPromptBias.length);
20742075 }
20752076
20762077 if (!isSystem) {