Skip to content

An AI-powered search engine with a generative UI

fix: resolve code block rendering issues

Yoshiki Miuraf1d608063b77
diff --git a/components/collapsible-message.tsx b/components/collapsible-message.tsx
index d74323fe..d5aff90d 100644
--- a/components/collapsible-message.tsx
+++ b/components/collapsible-message.tsx
@@ -123,7 +123,7 @@ export function CollapsibleMessage({
) : (
<div
className={cn(
- 'flex-1 rounded-2xl',
+ 'flex-1 rounded-2xl w-full',
role === 'assistant' ? 'px-0' : 'px-3'
)}
>
diff --git a/components/message.tsx b/components/message.tsx
index 93b171f8..26c6e335 100644
--- a/components/message.tsx
+++ b/components/message.tsx
@@ -40,7 +40,10 @@ export function MarkdownMessage({
const customComponents = {
code(props: any) {
const { children, className, ...rest } = props
- const inline = !('data-language' in props)
+ // Check if it's inline code or code block based on className presence
+ // Code blocks have className like "language-javascript", inline code has no className
+ const match = /language-(\w+)/.exec(className || '')
+ const inline = !match
if (children && typeof children === 'string') {
if (children === '▍') {
@@ -48,7 +51,6 @@ export function MarkdownMessage({
}
const processedChildren = children.replace('`▍`', '▍')
- const match = /language-(\w+)/.exec(className || '')
if (inline) {
return (