Converts agent assistant messages to styled text runs for the GUI.
Uses a hybrid approach:
- Regex-based Markdown parser for structure (headers, bold, italic,
inline code, lists, blockquotes, rules). This strips syntax markers
so the GUI shows clean rendered text, not raw
**or##. - Tree-sitter highlights overlaid on fenced code block content. This gives per-language syntax highlighting (Elixir, Python, etc.) inside code blocks, which the regex parser can't do.
The regex path always runs. Tree-sitter is layered on top for code blocks only when highlight spans are available.
Summary
Types
A line of styled runs.
All styled lines for a message.
A single styled text run: {text, fg_rgb, bg_rgb, flags} or {text, fg_rgb, bg_rgb, flags, url}.
Functions
Converts assistant message text to semantic markdown blocks for GUI code-card rendering.
Converts assistant message text to styled runs for the GUI.
Types
@type highlighter() :: (String.t(), String.t(), keyword() -> highlighter_result())
@type highlighter_result() :: {:ok, [String.t()], [Minga.Language.Highlight.Span.t()]} | :unsupported | :timeout | :unavailable | {:error, term()} | nil
@type styled_line() :: [styled_run()]
A line of styled runs.
@type styled_lines() :: [styled_line()]
All styled lines for a message.
@type styled_run() :: {String.t(), non_neg_integer(), non_neg_integer(), non_neg_integer()} | {String.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), String.t()}
A single styled text run: {text, fg_rgb, bg_rgb, flags} or {text, fg_rgb, bg_rgb, flags, url}.
Functions
@spec render_blocks( String.t(), MingaEditor.UI.Highlight.t() | nil, map(), non_neg_integer(), non_neg_integer(), keyword() ) :: [Minga.RenderModel.UI.AgentChat.MarkdownBlock.t()]
Converts assistant message text to semantic markdown blocks for GUI code-card rendering.
Inline code remains a styled-run flag inside paragraph/list/heading runs. Fenced code becomes an explicit MarkdownBlock code block; frontends should render cards from this block kind, not from 0x10.
@spec stylize( String.t(), MingaEditor.UI.Highlight.t() | nil, map(), non_neg_integer() ) :: styled_lines()
Converts assistant message text to styled runs for the GUI.
Always uses the regex-based Markdown parser for structure (strips syntax markers). When tree-sitter highlights are available, overlays per-language syntax highlighting onto fenced code block content lines.
buffer_byte_offset is the starting byte offset of this message's text within the full transcript markdown used for highlighting. Required for aligning tree-sitter spans with per-message line content.