Skip to content

fix: render math formulas in chat minimap outline - #349

Open
zhudatou630 wants to merge 1 commit into
agegr:mainfrom
zhudatou630:fix/minimap-outline-math
Open

fix: render math formulas in chat minimap outline#349
zhudatou630 wants to merge 1 commit into
agegr:mainfrom
zhudatou630:fix/minimap-outline-math

Conversation

@zhudatou630

Copy link
Copy Markdown
Contributor

Summary

  • Chat minimap outline already parsed math with remark-math, but never ran rehype-katex, so headings with formulas showed raw LaTeX.
  • Reuse the existing preview pipeline (normalizeDisplayMath + markdownPreviewRehypePlugins) already used by markdown previews.
  • Add minimal outline KaTeX CSS so formulas fit the narrow history panel.

Root cause

AssistantOutline in ChatMinimap used markdownPreviewRemarkPlugins (includes remarkMath) without markdownPreviewRehypePlugins (includes rehype-katex). Math nodes fell through as code/text and the outline's code renderer flattened them to raw LaTeX.

Test plan

  • Open a session whose assistant answers include headings with $...$ / \(...\) math
  • Hover the right-side chat minimap so the history outline expands
  • Confirm formulas render as KaTeX (not raw source like f_{k,t+1} / \ln...)
  • Confirm non-math outline headings still look/work the same
  • Click a math-containing outline heading and confirm navigation still works

The minimap outline enabled remark-math but never ran rehype-katex,
so headings with formulas showed raw LaTeX. Reuse the existing
preview math pipeline and keep KaTeX sized for the narrow outline.
Copilot AI review requested due to automatic review settings August 2, 2026 01:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes math rendering in the chat minimap’s assistant outline by aligning its markdown rendering pipeline with the existing markdown preview pipeline, so headings containing LaTeX render as KaTeX rather than raw source.

Changes:

  • Add markdownPreviewRehypePlugins (incl. rehype-katex) to the minimap outline’s ReactMarkdown renderer.
  • Normalize display/inline math delimiters via normalizeDisplayMath() before parsing.
  • Add small KaTeX-specific CSS adjustments for the narrow outline panel.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
components/ChatMinimap.tsx Runs the same remark+rehype (KaTeX) pipeline as markdown previews and normalizes math delimiters before rendering outline content.
components/ChatMinimap.module.css Tweaks KaTeX sizing/display specifically within the minimap outline for better fit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 174 to 179
a: ({ children }) => <>{children}</>,
code: ({ children }) => <>{children}</>,
}}
>
{markdown}
{normalizeDisplayMath(markdown)}
</ReactMarkdown>
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.

2 participants