From 5a4e9980533705774dc3f45b35cacf76c3d78dbc Mon Sep 17 00:00:00 2001 From: maria Date: Wed, 14 Oct 2026 23:10:05 +0000 Subject: [PATCH] fix(web): mermaid code toggle stays in place when switching views (#19601) --- apps/web/src/components/ChatMarkdown.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/web/src/components/ChatMarkdown.tsx b/apps/web/src/components/ChatMarkdown.tsx index 821d1643ede09b1d2b22f25d5f382af82d8b2eed..dd0343ca990ec556219320c98648b70cc1aea99a 100644 --- a/apps/web/src/components/ChatMarkdown.tsx +++ b/apps/web/src/components/ChatMarkdown.tsx @@ -849,7 +849,7 @@ function MarkdownCodeBlock({ theme, onRunShellCommand, isStreaming, - leadingActions, + viewToggle, canWrap = true, diagram = false, children, @@ -860,9 +860,10 @@ function MarkdownCodeBlock({ theme: "light" | "dark"; onRunShellCommand?: ((command: string) => void) | undefined; isStreaming: boolean; - leadingActions?: ReactNode; + /** Switches between source and rendered content; sits left of copy in both views. */ + viewToggle?: ReactNode; canWrap?: boolean; - /** Renders content instead of code, with actions below it like tables. */ + /** Renders content frameless, with the code header's actions above it. */ diagram?: boolean; children: ReactNode; }) { @@ -942,12 +943,14 @@ function MarkdownCodeBlock({ if (diagram) { return ( -
- {children} -
- {leadingActions} + // The transparent border and header padding match the code frame, so the + // actions stay in place when switching views. +
+
+ {viewToggle} {copyButton}
+ {children}
); } @@ -962,7 +965,6 @@ function MarkdownCodeBlock({ headerProps={THREAD_FIND_IGNORE_PROPS} actions={ - {leadingActions} {canWrap ? ( Run in terminal ) : null} + {viewToggle} {copyButton} } @@ -1043,7 +1046,7 @@ function MarkdownMermaidCodeBlock({ isStreaming={isStreaming} canWrap={!showDiagram} diagram={showDiagram} - leadingActions={ + viewToggle={ isStreaming ? null : (