Skip to content

Fix AI diagram generation for fenced Mermaid responses - #1452

Open
SwastidebDas wants to merge 1 commit into
nextcloud:mainfrom
SwastidebDas:fix/mermaid-code-fences
Open

SwastidebDas wants to merge 1 commit into
nextcloud:mainfrom
SwastidebDas:fix/mermaid-code-fences

Conversation

@SwastidebDas

Copy link
Copy Markdown

Summary

Fixes #1373.

AI-generated Mermaid diagrams can fail to render when the language model wraps its response in Markdown code fences, even though the generation task completes successfully.

Changes

  • Add a utility to remove mermaid Markdown code fences before passing the response to parseMermaidToExcalidraw.
  • Preserve valid Mermaid responses without code fences.
  • Display error messages in the AI diagram dialog instead of always showing a generic error.
  • Add regression tests for fenced responses, unfenced responses, Windows-style line endings, and incomplete code fences.

Testing

  • npx vitest run tests/integration/mermaidCodeFence.spec.mjs — 4 tests passed.
  • ESLint checks passed for all three modified/added files.
  • git diff --check passed.

Note: The full test suite was not verified successfully because the unrelated viewer-bundle.spec.mjs test timed out during its build step.

Signed-off-by: Swastideb Das <sdebpetrapole2001@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI diagram generation fails when the LLM wraps the Mermaid output in a markdown code fence

1 participant