Skip to content

fix: repair Mermaid labels and report validation accurately - #143

Merged
anhnh2002 merged 2 commits into
mainfrom
fix/141-mermaid-validation
Oct 28, 2026
Merged

anhnh2002 merged 2 commits into
mainfrom
fix/141-mermaid-validation

Conversation

@anhnh2002

@anhnh2002 anhnh2002 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

LLM-generated flowchart labels such as C{msg.error()?} can fail rendering and repeat the same error during agent retries. Add syntax guidance across generation/update prompts and the MCP skill, and repair unquoted classic rectangle/diamond labels only after a confirmed delimiter error and successful revalidation. Persist verified replacements and return the saved text; keep repairs within the original edit's undo history.

Validation now distinguishes confirmed syntax failures from unavailable validation. Check HTTP responses explicitly for pinned mermaid-py 0.8.0 (which does not raise on failed requests), handle newer exception-based versions, and retain complete parser diagnostics. Disabled validation, timeouts, and renderer outages warn without claiming syntax success or requesting syntax fixes.

Parent/repository overviews use the same validation before saving, with one correction attempt for remaining syntax errors. Unavailable validation continues with a warning. Automatic repair is limited to clear, single-line rectangle/diamond labels; ambiguous syntax is left for the agent.

The repair fixtures include the issue’s exact reproduction with an inline -- no --> edge, preserving the edge text while quoting its target label. Toolkit unit tests also cover CI environments without the CLI SDK by stubbing only SDK registration and executing the real editor implementation.

The syntax guidance reflects Mermaid 11.9.0: function calls, braces, brackets, commas, and double dashes are valid in sequence-message text; literal semicolons require #59;, and backticks do not escape them. Add a locked development-only Mermaid/jsdom harness and CI job to verify these cases with the viewer's actual parser version.

Validation:

  • Clean staged checkout: 471 Python tests passed (83 new regression cases).
  • All 83 focused regressions passed with both mermaid-py 0.8.0 and 0.8.4.
  • 37 shared fixtures passed against Mermaid 11.9.0.
  • Ruff lint and Ruff format checks passed on all 10 changed Python files; git diff --check passed.

Fixes #141

@anhnh2002
anhnh2002 merged commit 6612b36 into main Oct 28, 2026
3 checks passed
@anhnh2002
anhnh2002 deleted the fix/141-mermaid-validation branch October 28, 2026 07:15
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.

fix: LLM generates mermaid syntax that conflicts with parser delimiters

1 participant