Commit 58d1448
committed
fix(ui): Critical Mermaid parser bugs - class/state diagram contamination
**Problems:**
1. Mindmap root showing 'root((Project))' instead of 'Project'
2. Class diagram contaminated with state diagram nodes (Idle, Loading)
3. Parser treating '-->' (state) as '--' (class association)
**Root Causes:**
1. **Mindmap Parser Bug:**
- Format: 'root((Project))' = node 'root' with label 'Project' in circle shape
- Old code tried to strip parentheses from START of string
- But 'root((Project))' starts with 'r' not '('
- Result: Label never extracted
2. **Class Diagram Parser Contamination:**
- State diagrams use '-->' for transitions
- Class diagrams use '--' for associations
- Parser checked contains('--') which MATCHES '-->'!
- Result: 'Idle --> Loading' parsed as class relationship
- Created ghost nodes in class diagram
**Solutions:**
1. **Mindmap Parser:**
- Find first '(' and last ')'
- Extract text between them
- Strip remaining parentheses
- Result: 'root((Project))' → 'Project'
2. **Class Diagram Parser:**
- Check for '-->' explicitly
- Only parse '--' if NOT part of '-->'
- Result: State transitions no longer contaminate class diagrams
**Files Modified:**
- Sources/UserInterface/Chat/Mermaid/MermaidParser.swift (lines ~1000, ~630)
**Testing:**
✅ Build: PASS
⏳ Mindmap: Should now show 'Project' not 'root((Project))'
⏳ Class Diagram: Should ONLY show Animal/Dog, NOT Idle/Loading
⏳ State Diagram: Needs investigation why not rendering
**Impact:**
This fixes cross-diagram contamination - each diagram type now parses correctly without picking up syntax from other types.1 parent 0b0af2f commit 58d1448
1 file changed
Lines changed: 14 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| 629 | + | |
| 630 | + | |
629 | 631 | | |
630 | | - | |
| 632 | + | |
| 633 | + | |
631 | 634 | | |
632 | 635 | | |
633 | 636 | | |
| |||
993 | 996 | | |
994 | 997 | | |
995 | 998 | | |
996 | | - | |
997 | | - | |
| 999 | + | |
| 1000 | + | |
998 | 1001 | | |
999 | 1002 | | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
1003 | 1011 | | |
1004 | 1012 | | |
1005 | 1013 | | |
| |||
0 commit comments