File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed
apps/saru/components/chat Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,6 @@ import Image from "next/image";
1919import { UseChatHelpers } from "@ai-sdk/react" ;
2020import { useDocument } from "@/hooks/use-document" ;
2121
22- const MENTION_RE = / @ \[ ( [ ^ \] ] + ) \] \( ( [ ^ ) ] + ) \) / g;
23-
2422function MentionChip ( { title, id } : { title : string ; id : string } ) {
2523 const { loadDocument } = useDocument ( ) ;
2624 return (
@@ -38,11 +36,11 @@ function MentionChip({ title, id }: { title: string; id: string }) {
3836}
3937
4038function MessageContent ( { content } : { content : string } ) {
41- if ( ! MENTION_RE . test ( content ) ) return < Markdown > { content } </ Markdown > ;
39+ if ( ! content . includes ( '@[' ) ) return < Markdown > { content } </ Markdown > ;
4240
4341 const parts : React . ReactNode [ ] = [ ] ;
4442 let last = 0 ;
45- for ( const match of content . matchAll ( new RegExp ( MENTION_RE . source , 'g' ) ) ) {
43+ for ( const match of content . matchAll ( / @ \[ ( [ ^ \] ] + ) \] \( ( [ ^ ) ] + ) \) / g ) ) {
4644 if ( match . index ! > last ) parts . push ( < Markdown key = { last } > { content . slice ( last , match . index ) } </ Markdown > ) ;
4745 parts . push ( < MentionChip key = { match . index } title = { match [ 1 ] } id = { match [ 2 ] } /> ) ;
4846 last = match . index ! + match [ 0 ] . length ;
You can’t perform that action at this time.
0 commit comments