Skip to content

fix(agent): render dollar-delimited math correctly - #5988

Merged
404Wolf merged 5 commits into
mainfrom
cursor/agent-session-latex-6dff
Sep 3, 2026
Merged

404Wolf merged 5 commits into
mainfrom
cursor/agent-session-latex-6dff

Conversation

@404Wolf

@404Wolf 404Wolf commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • preserve the existing $...$ and $$...$$ math syntax
  • import single-line and multiline $$ equations as display math instead of forcing them inline
  • make static markdown honor each equation node's inline/display flag
  • give agent transcript math the existing horizontal-overflow container
  • add focused tests for inline $, single-line $$, and multiline $$

Scope

This intentionally does not add \(...\) or \[...\] parsing and does not change the shared math prompt.

Validation

  • bunx vitest run --project lexical-core ../../packages/lexical-core/tests/katex.test.ts — 3 passed
  • focused Biome check — passed
  • bun run type-check — passed
  • CI — 22 successful, 0 failed, 0 pending

Walkthrough

agent_dollar_math_rendering_stable.mp4

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Block $$ equations were forced inline (a leftover toggle), static
markdown ignored the node's inline flag, and coding-agent TeX
delimiters (\( \) / \[ \]) were not parsed. Agent replies now render
display math and those delimiters the same way chat already renders $$.

Co-authored-by: Wolf Mermelstein <wolf@404wolf.com>
@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: e84f4765-7ae7-4b34-93d8-c75adbc6fa9e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e4e439e2-ab6a-4f22-aeef-bf29b8cf0147

📥 Commits

Reviewing files that changed from the base of the PR and between aecb02f and 051a20c.

📒 Files selected for processing (8)
  • apps/web/src/features/block-agent/component/parts/TextPart.tsx
  • apps/web/src/features/block-agent/debug/Gallery.tsx
  • apps/web/src/index.css
  • apps/web/src/lib/core/component/LexicalMarkdown/component/core/StaticMarkdown.tsx
  • packages/lexical-core/tests/katex.test.ts
  • packages/lexical-core/transformers/index.ts
  • packages/lexical-core/transformers/katex.ts
  • packages/lexical-core/transformers/tables.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added support for rendering inline and block equations using $, $$, \(...\), and \[...\] syntax.
    • Agent responses now correctly display mathematical expressions in Markdown.
    • Equations inside Markdown tables are supported.
    • Block equations can scroll horizontally when needed.
  • Bug Fixes

    • Corrected equation rendering so block and inline formatting is preserved accurately.

Walkthrough

The change adds inline and block TeX equation transformers for Markdown, including \(...\) and \[...\] delimiters. Block equations now preserve their display state. The transformers are enabled in external, combined, and table parsing pipelines. Tests cover TeX, dollar-delimited, multiline, and internal XML equations. Agent markdown uses both transformer sets, renders equation state, supports horizontal scrolling for display math, and includes math examples in the gallery fixture.

Merge Risk: ⚪ Minimal · up to 051a2

This localized change adds LaTeX rendering support to agent transcripts while preserving the existing restricted KaTeX rendering path; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the conventional commits format with the valid feat: prefix, is 54 characters long, and accurately summarizes the LaTeX rendering changes.
Description check ✅ Passed The description clearly explains the LaTeX rendering changes, affected delimiters, UI updates, and test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Co-authored-by: Wolf Mermelstein <wolf@404wolf.com>
@404Wolf
404Wolf marked this pull request as ready for review August 27, 2026 16:09
cursoragent and others added 3 commits August 27, 2026 21:27
Typecheck failed because MultilineElementTransformer.replace passes
LexicalNode[] | null, not undefined.

Co-authored-by: Wolf Mermelstein <wolf@404wolf.com>
Align the multiline equation helper with Lexical's replace signature
so tsc accepts children, startMatch, and endMatch.

Co-authored-by: Wolf Mermelstein <wolf@404wolf.com>
Co-authored-by: Wolf Mermelstein <wolf@404wolf.com>
@cursor cursor Bot changed the title feat(agent): render LaTeX in agent session transcripts fix(agent): render dollar-delimited math correctly Sep 3, 2026
@404Wolf
404Wolf merged commit 6280d8c into main Sep 3, 2026
25 checks passed
@404Wolf
404Wolf deleted the cursor/agent-session-latex-6dff branch September 3, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants