File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -980,6 +980,7 @@ function MarkdownCodeBlock({
980980 isStreaming,
981981 leadingActions,
982982 canWrap = true ,
983+ diagram = false ,
983984 children,
984985} : {
985986 code : string ;
@@ -990,6 +991,8 @@ function MarkdownCodeBlock({
990991 isStreaming : boolean ;
991992 leadingActions ?: ReactNode ;
992993 canWrap ?: boolean ;
994+ /** Renders content instead of code, with actions below it like tables. */
995+ diagram ?: boolean ;
993996 children : ReactNode ;
994997} ) {
995998 const [ copied , setCopied ] = useState ( false ) ;
@@ -1047,6 +1050,37 @@ function MarkdownCodeBlock({
10471050 [ ] ,
10481051 ) ;
10491052
1053+ const copyButton = (
1054+ < Tooltip >
1055+ < TooltipTrigger
1056+ render = {
1057+ < Button
1058+ type = "button"
1059+ variant = "ghost-muted"
1060+ size = "icon-xs"
1061+ onClick = { handleCopy }
1062+ aria-label = { copyLabel }
1063+ />
1064+ }
1065+ >
1066+ { copied ? < CheckIcon className = "size-3" /> : < CopyIcon className = "size-3" /> }
1067+ </ TooltipTrigger >
1068+ < TooltipPopup side = "top" > { copyLabel } </ TooltipPopup >
1069+ </ Tooltip >
1070+ ) ;
1071+
1072+ if ( diagram ) {
1073+ return (
1074+ < div className = "my-[0.65rem]" data-language = { language } >
1075+ { children }
1076+ < div className = "mt-0.5 flex items-center justify-between select-none" >
1077+ { leadingActions }
1078+ { copyButton }
1079+ </ div >
1080+ </ div >
1081+ ) ;
1082+ }
1083+
10501084 return (
10511085 < div
10521086 className = "chat-markdown-codeblock my-[0.65rem] overflow-hidden rounded-lg border border-border/70 bg-secondary leading-snug dark:border-transparent dark:bg-input/32"
@@ -1100,22 +1134,7 @@ function MarkdownCodeBlock({
11001134 < TooltipPopup side = "top" > Run in terminal</ TooltipPopup >
11011135 </ Tooltip >
11021136 ) : null }
1103- < Tooltip >
1104- < TooltipTrigger
1105- render = {
1106- < Button
1107- type = "button"
1108- variant = "ghost-muted"
1109- size = "icon-xs"
1110- onClick = { handleCopy }
1111- aria-label = { copyLabel }
1112- />
1113- }
1114- >
1115- { copied ? < CheckIcon className = "size-3" /> : < CopyIcon className = "size-3" /> }
1116- </ TooltipTrigger >
1117- < TooltipPopup side = "top" > { copyLabel } </ TooltipPopup >
1118- </ Tooltip >
1137+ { copyButton }
11191138 </ span >
11201139 </ div >
11211140 { children }
@@ -1153,6 +1172,7 @@ function MarkdownMermaidCodeBlock({
11531172 theme = { theme }
11541173 isStreaming = { isStreaming }
11551174 canWrap = { ! showDiagram }
1175+ diagram = { showDiagram }
11561176 leadingActions = {
11571177 isStreaming ? null : (
11581178 < Tooltip >
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ export function MermaidDiagram({
175175
176176 if ( result . status === "error" ) {
177177 return (
178- < div className = "px-3 pt-1 pb-3" >
178+ < div >
179179 < div className = "flex items-center justify-between gap-2" >
180180 < p className = "m-0 text-xs text-destructive" > Unable to render diagram: { result . message } </ p >
181181 { result . retryable ? (
@@ -200,7 +200,7 @@ export function MermaidDiagram({
200200 }
201201
202202 return (
203- < div className = "overflow-x-auto px-3 pt-2 pb-3 " >
203+ < div className = "overflow-x-auto" >
204204 < button
205205 type = "button"
206206 aria-label = "Expand diagram"
You can’t perform that action at this time.
0 commit comments