diff --git a/client/src/components/Chat/Messages/Content/MarkdownComponents.tsx b/client/src/components/Chat/Messages/Content/MarkdownComponents.tsx index 2a47af30e4..1f2a3ff594 100644 --- a/client/src/components/Chat/Messages/Content/MarkdownComponents.tsx +++ b/client/src/components/Chat/Messages/Content/MarkdownComponents.tsx @@ -17,6 +17,16 @@ type TCodeProps = { children: React.ReactNode; }; +const isSingleLineCode = (children: React.ReactNode): boolean => { + if (typeof children === 'string') { + return !children.includes('\n'); + } + if (Array.isArray(children)) { + return children.every((child) => typeof child === 'string' && !child.includes('\n')); + } + return false; +}; + export const code: React.ElementType = memo(function MarkdownCode({ className, children, @@ -29,7 +39,7 @@ export const code: React.ElementType = memo(function MarkdownCode({ const lang = match && match[1]; const isMath = lang === 'math'; const isMermaid = lang === 'mermaid'; - const isSingleLine = typeof children === 'string' && children.split('\n').length === 1; + const isSingleLine = isSingleLineCode(children); const { getNextIndex, resetCounter } = useCodeBlockContext(); const blockIndex = useRef(getNextIndex(isMath || isMermaid || isSingleLine)).current; @@ -78,7 +88,7 @@ export const codeNoExecution: React.ElementType = memo(function MarkdownCodeNoEx } else if (lang === 'mermaid') { const content = typeof children === 'string' ? children : String(children); return {content}; - } else if (typeof children === 'string' && children.split('\n').length === 1) { + } else if (isSingleLineCode(children)) { return ( {children} diff --git a/client/src/components/Prompts/editor/Markdown.tsx b/client/src/components/Prompts/editor/Markdown.tsx index 3be7d3a702..19a039abd7 100644 --- a/client/src/components/Prompts/editor/Markdown.tsx +++ b/client/src/components/Prompts/editor/Markdown.tsx @@ -44,6 +44,9 @@ const processChildren = (children: React.ReactNode): React.ReactNode => { if (React.isValidElement(children)) { const element = children as React.ReactElement<{ children?: React.ReactNode }>; + if (typeof element.type !== 'string' || element.type === 'code') { + return children; + } if (element.props.children) { return React.cloneElement(element, { ...element.props, diff --git a/client/src/components/SidePanel/Agents/ActionsInput.tsx b/client/src/components/SidePanel/Agents/ActionsInput.tsx index d99b5e8672..82b7c7f07b 100644 --- a/client/src/components/SidePanel/Agents/ActionsInput.tsx +++ b/client/src/components/SidePanel/Agents/ActionsInput.tsx @@ -202,7 +202,7 @@ export default function ActionsInput({ return ( <> -
+
- {/* TODO: Implement examples functionality -
- -
- */}
-
-
+
+