[AI] Fix record chips not rendering inside markdown tables in AI chat (#19260)

closes
https://discord.com/channels/1130383047699738754/1480976327204016131

before - 

<img width="778" height="1259" alt="CleanShot 2026-04-02 at 18 33 03"
src="https://github.com/user-attachments/assets/66ee2fc7-a116-458e-86a6-2aa6806b9407"
/>


after -


<img width="758" height="1291" alt="CleanShot 2026-04-02 at 18 32 21"
src="https://github.com/user-attachments/assets/9e303ff5-d8f4-4c9e-83e7-9a8e6427673a"
/>
This commit is contained in:
nitin
2026-04-03 11:29:45 +02:00
committed by GitHub
parent c521ba29be
commit f01bcf60ee
@@ -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>
),