Skip to content

feat(ai): render LaTeX through AIComponentBuilders.math - #47

Draft
VelikovPetar wants to merge 1 commit into
mainfrom
feat/conversation-view-math-and-highlighting
Draft

VelikovPetar wants to merge 1 commit into
mainfrom
feat/conversation-view-math-and-highlighting

Conversation

@VelikovPetar

@VelikovPetar VelikovPetar commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds AIComponentBuilders.math, with AIMathProps (tex, style, inline). An AIMarkdownBody with no mathBuilder of its own now asks the nearest AIComponentFactory to render its LaTeX. With neither, it still shows the TeX source, as before.

AIComponentFactory(
  builders: AIComponentBuilders(
    math: (context, props) => Math.tex(
      props.tex,
      textStyle: props.style,
      mathStyle: props.inline ? MathStyle.text : MathStyle.display,
    ),
  ),
  child: AIConversationView(...),
)

Why

AIMarkdownBody only took a math engine through its own mathBuilder, and nothing above StreamingMessageView passed one on. So an AIConversationView's replies couldn't render LaTeX without replacing the whole reply row. A builder fits how code blocks and charts are already customised (AIComponentBuilders.codeBlock, chart). It reaches every markdown body under the factory, with no new parameters threaded through the conversation, its rows or their props. Code highlighting needs nothing new: AIComponentBuilders.codeBlock already covers it in a conversation.

Notes

  • A body's own mathBuilder still wins over the factory's.
  • Factory-rendered LaTeX is a small widget that reads the builders in its own build, like code fences do. Swapping the builders updates LaTeX already on screen without re-parsing.
  • Other platforms: neither the iOS nor the Android AI components render LaTeX today, and neither has a hook for it. This would be Flutter-only.

Testing

  • New tests:
    • AIMarkdownBody renders inline and block LaTeX through the factory, and swapping the builders updates it.
    • A body's own mathBuilder wins over the factory's.
    • AIConversationView renders a reply's LaTeX through AIComponentBuilders.math.
    • copyWith and merge carry math.
  • dart analyze --fatal-infos is clean.
  • The factory, conversation, markdown and streaming-message suites pass with CI=true.

🤖 Generated with Claude Code

@VelikovPetar
VelikovPetar marked this pull request as draft October 30, 2026 13:23
AIMarkdownBody took a math engine only through its own mathBuilder, which
nothing above StreamingMessageView passed on, so an AIConversationView's
replies could not render LaTeX at all. AIComponentBuilders.math now renders
it for any markdown body given no mathBuilder of its own, the same way code
blocks and charts are customised. A body's own mathBuilder still wins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@VelikovPetar
VelikovPetar force-pushed the feat/conversation-view-math-and-highlighting branch from 4158c30 to 4e394a2 Compare October 30, 2026 13:25
@VelikovPetar VelikovPetar changed the title feat(ai): pass mathBuilder and codeHighlighter through AIConversationView feat(ai): render LaTeX through AIComponentBuilders.math Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant