diff --git a/AgentCompany-New/src/renderer/src/pages/chat/ChatMessageRow.tsx b/AgentCompany-New/src/renderer/src/pages/chat/ChatMessageRow.tsx index 79517b1f..ffa751ce 100644 --- a/AgentCompany-New/src/renderer/src/pages/chat/ChatMessageRow.tsx +++ b/AgentCompany-New/src/renderer/src/pages/chat/ChatMessageRow.tsx @@ -132,7 +132,7 @@ export function ChatMessageRow({ } function renderBody(body: string, mentions: ChatMentionRecord[], context: MessageContext): ReactNode { - if (mentions.length === 0) return body; + if (mentions.length === 0) return formatInline(body, "b"); const parts: ReactNode[] = []; const ordered = [...mentions].sort((a, b) => a.offsetStart - b.offsetStart); let lastIndex = 0; @@ -143,7 +143,7 @@ function renderBody(body: string, mentions: ChatMentionRecord[], context: Messag } const token = body.slice(mention.offsetStart, mention.offsetEnd); if (!token.startsWith("@")) throw new Error("Message mention token is invalid."); - if (mention.offsetStart > lastIndex) parts.push(body.slice(lastIndex, mention.offsetStart)); + if (mention.offsetStart > lastIndex) parts.push(...formatInline(body.slice(lastIndex, mention.offsetStart), `s${lastIndex}`)); const label = mentionLabel(mention, context); parts.push( lastIndex) nodes.push(text.slice(lastIndex, match.index)); + const key = `${keyPrefix}-${token++}`; + if (match[2] !== undefined) nodes.push({match[2]}); + else if (match[3] !== undefined) nodes.push({match[3]}); + else if (match[4] !== undefined) nodes.push({match[4]}); + else nodes.push({match[5]}); + lastIndex = pattern.lastIndex; + } + if (lastIndex < text.length) nodes.push(text.slice(lastIndex)); + return nodes; +} + function mentionLabel(mention: ChatMentionRecord, context: MessageContext): string { if (mention.targetType === "employee") { const employee = context.employees.find((item) => item.id === mention.targetId);