diff --git a/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx b/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx index 40c005d1142..51cc1fb56b8 100644 --- a/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx +++ b/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx @@ -10,7 +10,13 @@ import { StyledSkeletonContainer, StyledTableScrollContainer, } from '@/ai/components/LazyMarkdownRendererStyledComponents'; -import { lazy, Suspense, useContext } from 'react'; +import { + cloneElement, + isValidElement, + lazy, + Suspense, + useContext, +} from 'react'; import Skeleton, { SkeletonTheme } from 'react-loading-skeleton'; import { isDefined } from 'twenty-shared/utils'; import { ThemeContext } from 'twenty-ui/theme-constants'; @@ -64,6 +70,16 @@ const processChildrenForRecordLinks = ( )); } + if (isValidElement<{ children?: React.ReactNode }>(children)) { + const childProps = children.props; + + if (isDefined(childProps.children)) { + return cloneElement(children, { + children: processChildrenForRecordLinks(childProps.children), + }); + } + } + return children; }; @@ -96,6 +112,12 @@ const MarkdownRenderer = lazy(async () => { {processChildrenForRecordLinks(children)} ), + td: ({ children }) => ( +