@devries-cameron20 / t3code-1 / commits / 5a4e998053
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): mermaid code toggle stays in place when switching views (#19601)

maria committed Oct 14, 2026 at 23:10 UTC 5a4e9980533705774dc3f45b35cacf76c3d78dbc
1 file changed +12 -9
apps/web/src/components/ChatMarkdown.tsx
+12 -9
@@ -849,7 +849,7 @@ function MarkdownCodeBlock({
849 theme,
850 onRunShellCommand,
851 isStreaming,
852 - leadingActions,
852 + viewToggle,
853 canWrap = true,
854 diagram = false,
855 children,
@@ -860,9 +860,10 @@ function MarkdownCodeBlock({
860 theme: "light" | "dark";
861 onRunShellCommand?: ((command: string) => void) | undefined;
862 isStreaming: boolean;
863 - leadingActions?: ReactNode;
863 + /** Switches between source and rendered content; sits left of copy in both views. */
864 + viewToggle?: ReactNode;
865 canWrap?: boolean;
865 - /** Renders content instead of code, with actions below it like tables. */
866 + /** Renders content frameless, with the code header's actions above it. */
867 diagram?: boolean;
868 children: ReactNode;
869 }) {
@@ -942,12 +943,14 @@ function MarkdownCodeBlock({
943
944 if (diagram) {
945 return (
945 - <div className="my-[0.65rem]" data-language={language}>
946 - {children}
947 - <div className="mt-0.5 flex items-center justify-between select-none">
948 - {leadingActions}
946 + // The transparent border and header padding match the code frame, so the
947 + // actions stay in place when switching views.
948 + <div className="my-[0.65rem] border border-transparent" data-language={language}>
949 + <div className="flex items-center justify-end gap-0.5 pt-1.5 pr-1.5 select-none">
950 + {viewToggle}
951 {copyButton}
952 </div>
953 + {children}
954 </div>
955 );
956 }
@@ -962,7 +965,6 @@ function MarkdownCodeBlock({
965 headerProps={THREAD_FIND_IGNORE_PROPS}
966 actions={
967 <span className="flex items-center gap-0.5" role="toolbar" aria-label="Code block actions">
965 - {leadingActions}
968 {canWrap ? (
969 <Tooltip>
970 <TooltipTrigger
@@ -1000,6 +1002,7 @@ function MarkdownCodeBlock({
1002 <TooltipPopup side="top">Run in terminal</TooltipPopup>
1003 </Tooltip>
1004 ) : null}
1005 + {viewToggle}
1006 {copyButton}
1007 </span>
1008 }
@@ -1043,7 +1046,7 @@ function MarkdownMermaidCodeBlock({
1046 isStreaming={isStreaming}
1047 canWrap={!showDiagram}
1048 diagram={showDiagram}
1046 - leadingActions={
1049 + viewToggle={
1050 isStreaming ? null : (
1051 <Tooltip>
1052 <TooltipTrigger