Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jun 17, 2025

Description

Fixes #4258

This PR adds LaTeX math equation rendering support to the Roo Code chat window, allowing users to display mathematical equations beautifully formatted using KaTeX.

Changes Made

  • Added KaTeX dependencies (katex, rehype-katex, remark-math) to render LaTeX equations
  • Integrated remark-math and rehype-katex plugins in MarkdownBlock.tsx
  • Added KaTeX CSS styling for proper equation display
  • Updated Content Security Policy to allow KaTeX font loading with data: URLs
  • Configured Vite to handle KaTeX font assets properly
  • Updated .vscodeignore to include KaTeX fonts in the extension bundle

Testing

Tested with various LaTeX equations:

  • Inline math: $E = mc^2$ renders correctly inline
  • Display math: $$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$ renders as centered block equations
  • Complex equations render properly with all mathematical symbols

Verification of Acceptance Criteria

  • LaTeX equations render beautifully in the chat window
  • Both inline and display math modes are supported
  • No system prompt modifications (relies on models' existing LaTeX knowledge)
  • Works with various mathematical expressions and symbols

Screenshots

As shown in the issue, LaTeX equations now render properly in chat messages:

  • Inline equations appear seamlessly within text
  • Display equations are centered and properly formatted
  • Mathematical symbols and complex expressions render correctly
image

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • TypeScript types are properly handled
  • No breaking changes
  • Extension builds successfully
  • Tested with various LaTeX expressions

Important

Adds LaTeX math rendering in chat using KaTeX, updates dependencies, and configures asset handling and security policies.

  • Behavior:
    • Adds LaTeX rendering in chat using KaTeX in MarkdownBlock.tsx.
    • Supports inline and display math modes.
  • Dependencies:
    • Adds katex, rehype-katex, remark-math to package.json.
  • Configuration:
    • Updates Content Security Policy in ClineProvider.ts to allow data: URLs for fonts.
    • Configures Vite in vite.config.ts to handle KaTeX font assets.
    • Updates .vscodeignore to include KaTeX fonts in the extension bundle.
  • Styling:
    • Imports KaTeX CSS in index.css for styling equations.

This description was created by Ellipsis for 161eb33. You can customize this summary. It will automatically update as commits are pushed.

@hannesrudolph hannesrudolph requested review from cte, jr and mrubens as code owners June 17, 2025 17:19
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 17, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 17, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 17, 2025
Copy link
Collaborator Author

@hannesrudolph hannesrudolph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing LaTeX math rendering support! This is a valuable feature that many users have been requesting.

Overall Assessment

The implementation is clean and follows existing patterns in the codebase. The integration with the markdown rendering pipeline using remark-math and rehype-katex is well done, and the styling appropriately uses VSCode theme variables.

Summary of Suggestions

I've left several inline comments covering:

  • Bundle size considerations due to KaTeX's ~280KB footprint
  • Error handling for invalid LaTeX syntax
  • Security options to limit potentially dangerous LaTeX commands
  • Performance impact of font loading
  • Accessibility and configurability improvements
  • Test coverage to ensure stability

None of these are blocking issues, but addressing them would make this feature more robust and maintainable.

Testing Verification

Based on your PR description, you've tested:

  • ✅ Inline math ($E = mc^2$)
  • ✅ Display math blocks
  • ✅ Complex equations with various symbols
  • ✅ CSP configuration for font loading

Great work on this implementation! The feature works as described and will be a welcome addition for users who need mathematical notation in their conversations.

@hannesrudolph hannesrudolph moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 17, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 17, 2025
hannesrudolph and others added 6 commits June 19, 2025 10:02
Added a new setting `disableDiffVisualization` that allows users to disable
the diff view when editing files. When enabled, files will open directly in
the editor instead of showing a side-by-side diff view. This helps prevent
Language Server Protocol (LSP) crashes that can occur with very large files,
particularly affecting C# developers.

The changes made by Roo are still visible in the chat window.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Moved disableDiffVisualization from global settings to experimental settings
- Updated all references to access it through experiments instead
- Fixed test cases to include the new experiment
- Updated translations to reflect experimental nature
- Setting now properly affects ALL edit tools (write_to_file, apply_diff, insert_content, search_and_replace)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add KaTeX dependencies for LaTeX rendering
- Integrate remark-math and rehype-katex plugins in MarkdownBlock
- Add KaTeX CSS styling for proper equation display
- Update CSP to allow KaTeX font loading with data: URLs
- Configure Vite to handle KaTeX font assets
- Update .vscodeignore to include KaTeX fonts in extension bundle

Users can now write LaTeX equations using standard syntax:
- Inline math:  = mc^2$
- Display math: 95668\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}95668

Fixes #4258
- Removed DISABLE_DIFF_VISUALIZATION from experiment types and configurations
- Removed disableDiffVisualization parameter from Task and DiffViewProvider
- Removed all DISABLE_DIFF_VISUALIZATION translations from locale files
- Removed disable-diff-visualization changeset
- Keep only LaTeX rendering related changes in this PR
@daniel-lxs daniel-lxs force-pushed the feat/issue-4258-latex-rendering branch from 2dc38cd to 9c9f030 Compare June 19, 2025 15:13
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 19, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 19, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Made a style change and fixed the conflicts.

Before
image

After
image

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 19, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 19, 2025
@mrubens mrubens merged commit 85d73af into main Jun 20, 2025
23 of 24 checks passed
@mrubens mrubens deleted the feat/issue-4258-latex-rendering branch June 20, 2025 19:45
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 20, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 20, 2025
cte pushed a commit that referenced this pull request Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Feature Request: LaTeX Math Equation Rendering in Chat Box

4 participants