fix(tui): sync Mermaid renderer fixes - #41347
Open
kitlangton wants to merge 1 commit into
Open
Conversation
kitlangton
enabled auto-merge (squash)
August 9, 2026 01:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sync the v2 terminal Mermaid renderer with the latest OpenTUI renderer fixes and performance work.
This fixes corrupted state diagrams with branching and feedback, supports Mermaid connectors used in real model output, decodes HTML entities in labels, and brings over the spatial routing and canvas row-extent optimizations.
Before / After
Before: A lifecycle state diagram containing a main path, a side branch, two self-transitions, and a feedback edge placed
PromptSubmittedandPollingin overlapping bounds. TheCompleted -> Idlefeedback route also crossedMailboxPending, overwriting its frame and label. Valid-. label .-and<-->flowchart connectors fell back to source code instead of rendering.After: Fallback states keep their compact rank-based placement but move when that position collides. Bottom feedback approaches select a clear vertical corridor around unrelated states. Labeled undirected dashed and bidirectional connectors parse and render with the correct arrowheads.
How
packages/merman/src/state/layout.tsdetects and separates colliding horizontal fallback states.packages/merman/src/state/routing.tschooses collision-free bottom approach corridors for feedback and parallel routes.packages/merman/src/flowchart/parser.tsanddrawing.tssupport labeled undirected dashed edges and bidirectional arrowheads.packages/merman/src/core/spatial.tscentralizes semantic body, route, and label collision checks.packages/merman/src/core/canvas.tstracks visible row extents and fast-paths ASCII writes.Scope
OpenCode-specific
plugin.ts,palette.ts,markdown.ts, and color integration remain unchanged. The newer OpenTUI Markdown-renderable reuse path is not included because v2 currently uses@opentui/core0.4.5 and does not expose those APIs.Testing
cd packages/merman && bun run test(285 passing)cd packages/merman && bun run typecheckbun turbo typecheck --concurrency=3(33 packages passing)ses_01db49b85ffe6yLOdvjVuh2siNthrough the synced renderer with no failuresDemo
Real PTY capture of the corrected lifecycle fixture rendered by
@opencode-ai/merman:Flow
flowchart TD Diagram[Parsed state diagram] --> Place[Compact rank placement] Place --> Collision{State bounds collide?} Collision -->|Yes| Shift[Move fallback state past occupied bounds] Collision -->|No| Route[Plan transitions] Shift --> Route Route --> Approach{Bottom approach crosses a state?} Approach -->|Yes| Clear[Select nearest clear corridor] Approach -->|No| Draw[Draw route] Clear --> Draw