Skip to content

Commit 0b0af2f

Browse files
committed
fix(ui): Mermaid diagram rendering improvements - class arrows and mindmap parser
**Problems:** 1. Class diagram relationships rendered but arrows invisible 2. Mindmap root showed 'root((Project' instead of 'Project' **Solutions:** 1. **Class Diagram Relationship Arrows:** - ClassDiagramRenderer: Changed .stroke() to .fill() for RelationshipSymbol - Arrows with .closeSubpath() need .fill() to be visible (same pattern as flowchart fix) - Result: Inheritance/composition/association arrows now visible 2. **Mindmap Root Label Parsing:** - MermaidParser: Fixed parseMindmap() to handle double parentheses - Old: trimmingCharacters(in: CharacterSet(charactersIn: "()")) - removes all ( and ) - New: while loop to strip matching pairs of parentheses - Handles: 'root', 'root(text)', 'root((text))' correctly - Result: 'root((Project))' now displays as 'Project' **Files Modified:** - Sources/UserInterface/Chat/Mermaid/ClassDiagramRenderer.swift (line ~146) - Sources/UserInterface/Chat/Mermaid/MermaidParser.swift (line ~1000) **Testing:** ✅ Build: PASS ⏳ Class Diagram: Needs user testing with Animal/Dog example ⏳ Mindmap: Needs user testing with Project hierarchy **Known Remaining Issues:** - State diagram (#4) not rendering at all - Mindmap children still not visible (layout issue, not parser) - ER diagrams could use arrow indicators
1 parent a624bdb commit 0b0af2f

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Sources/UserInterface/Chat/Mermaid/ClassDiagramRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct ClassRelationshipView: View {
133133
at: toPos,
134134
angle: atan2(toPos.y - fromPos.y, toPos.x - fromPos.x)
135135
)
136-
.stroke(Color.accentColor.opacity(0.6), lineWidth: 2)
136+
.fill(Color.accentColor.opacity(0.6))
137137
}
138138
}
139139

Sources/UserInterface/Chat/Mermaid/MermaidParser.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,13 @@ struct MermaidParser {
994994
}
995995

996996
// Parse root node (remove parentheses if present)
997-
let rootLabel = rootLine.trimmingCharacters(in: .whitespaces)
998-
.trimmingCharacters(in: CharacterSet(charactersIn: "()"))
999-
.trimmingCharacters(in: .whitespaces)
997+
// Handle formats: "root", "root(text)", "root((text))"
998+
var rootLabel = rootLine.trimmingCharacters(in: .whitespaces)
999+
1000+
// Remove surrounding parentheses (single or double)
1001+
while rootLabel.hasPrefix("(") && rootLabel.hasSuffix(")") {
1002+
rootLabel = String(rootLabel.dropFirst().dropLast()).trimmingCharacters(in: .whitespaces)
1003+
}
10001004

10011005
// Parse hierarchy - build list of (label, level) pairs
10021006
var nodeData: [(label: String, level: Int)] = [(rootLabel, 0)]

0 commit comments

Comments
 (0)