The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
[AI] Fix record chips not rendering inside markdown tables in AI chat (#19260)
nitinf01bcf60eeee
diff --git a/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsx b/packages/twenty-front/src/modules/ai/components/LazyMarkdownRenderer.tsxindex 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)}</ParagraphComponent>),+ td: ({ children }) => (+ <td>{processChildrenForRecordLinks(children)}</td>+ ),+ th: ({ children }) => (+ <th>{processChildrenForRecordLinks(children)}</th>+ ),li: ({ children }) => (<li>{processChildrenForRecordLinks(children)}</li>),