From 7c098f9fd1de36a8945f66039bcde360533fbb42 Mon Sep 17 00:00:00 2001 From: balibabu Date: Wed, 28 May 2025 19:42:56 +0800 Subject: [PATCH] Fix: Display bug in the early stage of conversation chat #7904 (#7922) ### What problem does this PR solve? Fix: Display bug in the early stage of conversation chat #7904 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- web/src/pages/chat/utils.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/src/pages/chat/utils.ts b/web/src/pages/chat/utils.ts index 1a404eadb..2a21e6937 100644 --- a/web/src/pages/chat/utils.ts +++ b/web/src/pages/chat/utils.ts @@ -43,10 +43,17 @@ export const buildMessageItemReference = ( }; const oldReg = /(#{2}\d+\${2})/g; +const currentReg = /\[ID:(\d+)\]/g; + +function transformReg(substring: string) { + return `~~${substring.slice(4, -1)}==`; +} // To be compatible with the old index matching mode export const replaceTextByOldReg = (text: string) => { - return text?.replace(oldReg, function (substring) { - return `~~${substring.slice(2, -2)}==`; - }); + return text + ?.replace(currentReg, transformReg) + .replace(oldReg, (substring: string) => { + return `~~${substring.slice(2, -2)}==`; + }); };