9 Commits
Author SHA1 Message Date
Eric Traut 9fcb1f5ed4 Support line breaks in Mermaid flowchart node labels (#54419)
## Why

Flowcharts with `<br>` tags in node labels previously fell back to source instead of rendering as terminal diagrams.

## What changed

Render `<br>`, `<br/>`, and `<br />` as line breaks in quoted and unquoted flowchart node labels. Apply the 40-display-cell label limit per line and keep the decision marker on the first line. Continue rejecting other HTML, break tags in edge labels, and labels containing only breaks or whitespace.

## Testing

Extend rendering snapshots across all four flowchart directions and cover per-line width limits and unsupported markup. Update TUI streaming tests to cover multiline rendering, resizing, source fallback, and preservation of the original source for copying.

GitOrigin-RevId: 61f2a84c8bb161ac4a1c26ddaa0569f52bfea749
2026-10-15 21:29:41 +00:00
Adam Perry @ OpenAI 3b6ab3471a Normalize formatting in docs, web assets, and sample scripts (#52256)
## What changed

- Reformat Markdown tables and lists, login pages, inline visualization HTML, and sample JavaScript scripts.
- Escape union-type pipes in Python SDK API tables so they render within their cells.
- Keep the formatting-recipe test focused on the working directory and formatter commands by removing assertions on comment text.

GitOrigin-RevId: ae46d5b40fd013553de8b5ccf2c41d76be65aba8
2026-10-08 20:11:43 +00:00
Eric Traut 44fe510ce3 Expand native Mermaid flowchart syntax support (#48895)
## What changed

- Default `flowchart` and `graph` to top-down layout when no direction is specified.
- Support solid and dashed edges with directed, undirected, or bidirectional endpoints: `-->`, `---`, `<-->`, `-.->`, `-.-`, and `<-.->`.
- Accept pipe labels on these edges and spaced directed infix labels such as `A -- send --> B` and `A -. retry .-> B`.
- Expand `&` groups into all source-to-target edges, including in chains. For example, `A & B --> C & D` creates four edges. Enforce the 24-edge limit after expansion and cap each group at 24 node references.

## Testing

Add coverage for equivalent syntax, edge styles and endpoints, malformed input, and expansion limits. Extend rendering snapshots across all four directions and the TUI native-renderer test with the new syntax.

GitOrigin-RevId: 6e51653ebf6b8b7e7e1edec0c2e09a5d9c8dec74
2026-09-28 06:30:53 +00:00
Eric Traut 659b35f131 Preserve punctuation and semicolons in Mermaid labels (#48814)
## Why

Splitting every statement at semicolons and rejecting label punctuation prevents rendering labels such as `A["Go []; &"]`, sequence messages containing `data[0] = {x: 1}`, and class members containing semicolons.

## What changed

- Split statements using diagram-specific rules, preserving semicolons inside flowchart labels, quoted tokens, and class member lines. Sequence quotes remain literal text.
- Respect quoted flowchart label delimiters and allow printable label punctuation, including literal ampersands and comparison operators.
- Reject unsupported entity escapes before statement splitting can truncate them, while retaining rejection of HTML markup and malformed labels.
- Document the supported syntax and require newlines between class members.

## Testing

Add parser assertions and update rendering snapshots for punctuation, quoted delimiters, and semicolons. Extend rejection coverage for entity escapes across diagram families, malformed quotes, and invalid class bodies.

GitOrigin-RevId: da94007a66c7c58444e6f0d6a1b409c8c7251941
2026-09-27 23:41:04 +00:00
Eric Traut 6e1ab4d294 Fix Mermaid shape, relationship, and state description parsing (#48489)
## What changed

- Reject unsupported flowchart shapes and Markdown strings so the terminal renderer preserves the source with an unsupported-feature notice instead of misrendering it. Keep ordinary quoted labels containing shape-like punctuation valid.
- Preserve class relationship targets beginning with `o`, such as `A --orange`, instead of consuming the first letter as an aggregation marker.
- Accumulate state aliases and descriptions in source order: use the first as the title and subsequent entries as body rows, preserving state identity and limiting body rows to 16.

## Testing

Add parser regressions for these cases and description limits, update class and state snapshots, and extend TUI snapshots to verify source preservation for unsupported flowchart syntax.

GitOrigin-RevId: c44d954312c77229a3752a0d9ada14e34a43a376
2026-09-26 17:26:07 +00:00
Eric Traut 9477081ccd Support quoted labels and ampersands in Mermaid flowcharts (#47678)
## Why

Flowcharts with labels such as `A["Review & confirm"]` fell back to source display instead of rendering a diagram.

## What changed

Accept double-quoted node and edge labels, strip the surrounding quotes, and allow literal ampersands in flowchart labels. Keep other diagram families' label restrictions and continue rejecting HTML, entity escapes, and malformed quotes.

## Testing

Add parser and renderer regression tests for quoted labels, literal ampersands, statement separators, and unsupported text, plus TUI coverage for rendered labels and entity source fallback.

GitOrigin-RevId: 9e61a04665f0266d369fa3595411c9a72f10cb9d
2026-09-23 22:09:41 +00:00
Eric Traut 2426ed7684 Support stadium nodes in Mermaid terminal diagrams (#46856)
## Why

Flowcharts containing stadium nodes such as `A([Start])` currently fall back to source text instead of rendering in the TUI.

## What changed

Parse stadium declarations and render them with rounded box corners in every supported flowchart direction. Track node shapes explicitly so repeated declarations must agree on both label and shape. Document the supported `([label])` syntax.

## Testing

Add parser and snapshot coverage for repeated references, conflicting declarations, malformed syntax, Unicode labels, mixed shapes, and width limits across all four directions. Add a TUI snapshot for a stadium flowchart and verify source fallback when the diagram is too wide or malformed.

GitOrigin-RevId: 5ebd8babfd25ab4429b3e6c408cb7be8d7f1bb8e
2026-09-20 17:36:48 +00:00
Eric Traut f915e0de07 Render Mermaid code blocks as diagrams in the TUI (#46054)
## What changed

- Render completed `mermaid` fences with `codex-mermaid`, using syntax-theme colors for nodes and edges.
- Keep source visible for unclosed, invalid, unsupported, or oversized diagrams, and preserve the original Mermaid for copying and raw mode.
- Keep streamed diagrams mutable until the next top-level block so closing fences and terminal resizing can update their display. Preserve scrollback progress across width and render-mode changes.

## Testing

Add renderer and streaming tests covering supported diagram families, nested fences, Unicode, theme colors, source fallbacks, resizing, raw-mode transitions, and original-source preservation. Verify that node connection ports retain node styling in all four flowchart directions.

GitOrigin-RevId: 9a759248110e6730d629d653061ff7e2ec5dc2c0
2026-09-16 23:26:00 +00:00
Eric Traut 7c709f0ffd Add a bounded Mermaid text renderer (#45817)
## What changed

Add `codex-mermaid`, a standalone crate that renders supported subsets of flowchart, sequence, state, class, and ER diagrams as Unicode text. Expose `render` for plain text and `render_spans` for semantic node, edge, and text spans that callers can style.

Enforce source, diagram, canvas, and display-width limits. Return errors for unsupported input or exceeded limits without producing partial diagrams, leaving source fallback to callers. Include documentation and a stdin rendering example.

## Testing

Add snapshots for each diagram family, checks for relationship endpoints, Unicode labels, semantic spans, truncated input, and size limits, plus edge reconstruction for all 512 directed three-node graphs in all four layout directions.

GitOrigin-RevId: 5b4e65d9152abce5d833e4e6b12113a5a21f700e
2026-09-16 00:38:34 +00:00