From 459237c974dd05c8dc9bb1a1238bd123c8eb9654 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Mon, 22 Jun 2026 11:15:46 -0700 Subject: [PATCH] feat(dashboard): task description + summary render sanitized HTML + mermaid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract the markdown HTML/mermaid pipeline into shared markdownPipeline.tsx (sharedSanitizeSchema, sharedRehypePlugins, createMermaidCodeComponent). MailboxMessageContent now consumes it (unchanged behavior). TaskDetailModal's description + summary ReactMarkdown gain sharedRehypePlugins + the mermaid code component (merged with the existing file-path linkify), keeping the .markdown-body wrapper — so raw HTML renders, comments drop, scripts are sanitized, and mermaid blocks render. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../app/components/MailboxMessageContent.tsx | 70 ++------------ .../app/components/TaskDetailModal.tsx | 34 +++++-- .../TaskDetailModal.rendering.test.tsx | 64 +++++++++++++ .../app/components/markdownPipeline.tsx | 95 +++++++++++++++++++ 4 files changed, 193 insertions(+), 70 deletions(-) create mode 100644 packages/dashboard/app/components/markdownPipeline.tsx diff --git a/packages/dashboard/app/components/MailboxMessageContent.tsx b/packages/dashboard/app/components/MailboxMessageContent.tsx index 61b1d865a5..3316727f3a 100644 --- a/packages/dashboard/app/components/MailboxMessageContent.tsx +++ b/packages/dashboard/app/components/MailboxMessageContent.tsx @@ -1,52 +1,19 @@ import { memo } from "react"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; -import rehypeRaw from "rehype-raw"; -import rehypeSanitize, { defaultSchema } from "rehype-sanitize"; -import type { Options as SanitizeSchema } from "rehype-sanitize"; import type { Components } from "react-markdown"; import type { PluggableList } from "unified"; import { linkifyReactChildren } from "../utils/filePathLinkify"; -import { MermaidDiagram } from "./MermaidDiagram"; +import { sharedRehypePlugins, createMermaidCodeComponent } from "./markdownPipeline"; /* -FNXC:Markdown 2026-06-23-03:15: -GitHub PR/issue bodies + comments (and mailbox/chat) embed raw HTML (`
`, -``, ``, ``, tables), HTML comments (``), and ```mermaid -blocks. Previously raw HTML was escaped to literal text and mermaid showed as code. - -Pipeline (ORDER MATTERS): remark-gfm -> rehype-raw -> rehype-sanitize. -- rehype-raw parses embedded HTML into the hast tree so it renders as real elements. - It also DROPS HTML comments by default, so `` never appears in output. -- rehype-sanitize runs AFTER raw to strip XSS: ", + "", + "```mermaid", + "graph TD; A-->B;", + "```", + ].join("\n"); + + const { container } = render( + + + , + ); + + // Raw
/ renders as a real disclosure element. + const details = container.querySelector(".markdown-body details"); + expect(details).not.toBeNull(); + expect(details?.querySelector("summary")?.textContent).toBe("Disclosure title"); + expect(details?.textContent).toContain("Hidden detail body."); + + // HTML comment is dropped, never shown as literal text. + expect(container.textContent).not.toContain("secret comment"); + + //