From 83f8c6623312632bf04811d015dbd7a902fbbef7 Mon Sep 17 00:00:00 2001 From: zhb <50901800+zhbdesign@users.noreply.github.com> Date: Thu, 9 Jul 2026 16:23:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmermaid=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E9=81=97=E6=BC=8F=E4=BA=86=20/=EF=BC=88=E6=96=9C=E6=9D=A0?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复mermaid渲染遗漏了 /(斜杠) --- desktop/src/components/chat/MermaidRenderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/src/components/chat/MermaidRenderer.tsx b/desktop/src/components/chat/MermaidRenderer.tsx index 8c5151dd..4489b05c 100644 --- a/desktop/src/components/chat/MermaidRenderer.tsx +++ b/desktop/src/components/chat/MermaidRenderer.tsx @@ -40,7 +40,7 @@ type MermaidThemeColors = { const FLOWCHART_START = /^\s*(?:graph|flowchart)\b/i const FLOWCHART_NODE_START = /^([A-Za-z][\w-]*)\[/ -const UNQUOTED_FLOWCHART_LABEL_UNSAFE = /|[{}[\]*]/i +const UNQUOTED_FLOWCHART_LABEL_UNSAFE = /|[{}[\]*\/]/i function isFlowchartDiagram(code: string) { const firstMeaningfulLine = code From 3e7c7de54a03627465dc3c093b5d91e051d98bfd Mon Sep 17 00:00:00 2001 From: zhb <50901800+zhbdesign@users.noreply.github.com> Date: Thu, 9 Jul 2026 17:54:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmermaid=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E9=81=97=E6=BC=8F=E4=BA=86=20/=EF=BC=88=E6=96=9C=E6=9D=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复mermaid渲染遗漏了 /(斜杠 --- .../chat/MermaidRenderer.integration.test.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/desktop/src/components/chat/MermaidRenderer.integration.test.tsx b/desktop/src/components/chat/MermaidRenderer.integration.test.tsx index eafb81c8..137491e6 100644 --- a/desktop/src/components/chat/MermaidRenderer.integration.test.tsx +++ b/desktop/src/components/chat/MermaidRenderer.integration.test.tsx @@ -58,6 +58,24 @@ describe('MermaidRenderer Mermaid integration', () => { expect(surface.innerHTML).not.toContain('onerror') }) + it('auto-quotes flowchart labels containing forward slashes to avoid lexical errors', async () => { + render( + D2[直接调用 dclService]', + ' D2 --> R[返回结果]', + ].join('\n')} + />, + ) + + const surface = await screen.findByTestId('mermaid-diagram-surface') + + expect(surface).toHaveTextContent('/api/dcl') + expect(surface).toHaveTextContent('直接调用 dclService') + expect(screen.queryByText('Mermaid Error')).not.toBeInTheDocument() + }) + it('renders generated flowchart labels with HTML breaks and structural characters', async () => { render(