Skip to content

Desktop app does not render inline LaTeX math ($...$) #39170

Closed as duplicate

Description

@Maxwell0622

Description

When using the opencode Desktop app (Windows), block-level LaTeX math enclosed in $$...$$ renders correctly, but inline math enclosed in $...$ is displayed as raw LaTeX source code instead of being rendered.

Steps to reproduce:

  1. Ask the AI agent to output inline math, e.g., $E = mc^2$
  2. Observe that it appears as literal $E = mc^2$ text
  3. Compare with block math $$...$$, which renders properly

Expected behavior:
Inline math $...$ should be rendered the same way as block math $$...$$.

Environment:

  • opencode Desktop (latest version)
  • Occurs on all platforms

The issue is likely in the Markdown renderer — it only applies math rendering to fenced $$ blocks but does not handle inline $ delimiters. This is a common oversight in Markdown math implementations; libraries like KaTeX or MathJax handle both out of the box.

Plugins

No response

OpenCode version

Latest

Steps to reproduce

No response

Screenshot and/or share link

Image

Operating System

Windows11

Terminal

No response

Activity

  1. github-actions commented on Jul 27, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please search existing issues before submitting to help us keep the tracker tidy. If your issue is distinct (e.g., specifically about inline $...$ vs block $$...$$ rendering asymmetry rather than math not rendering at all), please note what makes it different from the issues above.

  2. bisuwuss-netizen commented on Aug 3, 2026

    @bisuwuss-netizen

    Confirmed on macOS as well.

    Environment

    • OpenCode Desktop: 1.18.11
    • Bundle ID: ai.opencode.desktop
    • macOS: 26.5.2 (25F84)
    • Architecture: Apple Silicon (arm64)

    Reproduction

    1. Open a Desktop conversation.
    2. Ask the model to include inline LaTeX in normal prose, for example:
      • $v_\pi(s) = \mathbb{E}_\pi[G_t \mid S_t=s]$
      • $R_{t+1} + \gamma V(S_{t+1})$
    3. The expressions are shown as literal LaTeX source instead of rendered math.

    Markdown headings, lists, and other formatting render normally; the problem is specifically noticeable for math delimiters in assistant messages.

    Expected behavior

    Inline $...$ expressions should render as math in the Desktop UI (for example via KaTeX), with consistent support for standard block math as well.

    This is particularly disruptive in math-heavy tutoring and technical explanations because subscripts, Greek symbols, expectations, and longer equations become difficult to read.

  3. pradnX commented on Aug 30, 2026

    @pradnX
    $ opencode --version
    1.18.25
    

    ~/.config/opencode/AGENTS.md

    $ cat ~/.config/opencode/AGENTS.md
    # Global Engineering Guidelines
    
     # MATH & SYMBOL FORMATTING:
     - DO NOT use LaTeX formatting (e.g., $ ... $ or $$ ... $$) for math, symbols, or equations.
       You must use standard plain text and native Unicode characters (e.g.,
       use ≈ instead of \approx, or x^2 instead of $x^2$).
    

    This fails for me - despite instructions in agent.

  4. beihaixingchen commented on Sep 9, 2026

    @beihaixingchen

    Related reproduction on the Desktop GUI: display math delimited with \[...\] is also rendered as raw LaTeX instead of KaTeX. This happens frequently with OpenAI models, which often emit \[...\] for standalone equations.

    Example assistant output:

    \[
    \text{weight}=\operatorname{softmax}\left(\frac{q_{\text{new}}K_{\text{all}}^\top}{\sqrt{d_k}}\right)
    \]

    Expected: the expression should render as display math in the Desktop UI.
    Actual: the complete \[...\] source is shown as plain text, while some inline expressions using \(...\) render correctly.

    The current GUI parser in packages/ui/src/context/marked-parser.tsx already uses KaTeX. Its inline tokenizer recognizes \(...\), and its block tokenizer recognizes $$ blocks only when the opening and closing delimiters are on separate lines. It does not include a tokenizer for \[...\].

    The GUI path uses this parser through packages/session-ui/src/components/markdown.worker.ts, so this looks like a small Markdown tokenizer coverage gap rather than a missing rendering dependency. Supporting \[...\] as display-math delimiters would make the existing KaTeX integration handle the format produced by these models.

  5. Focus786 commented on Sep 24, 2026

    @Focus786

    Same symptom on the latest Desktop build — adding a v2.0.14 case with byte-level evidence that the message content is not the cause.

    Environment

    • OpenCode Desktop: 2.0.14 (bundled CLI 2.0.14)
    • OS: Windows 11 (Windows_NT 10.0.26200, win32 x64)
    • Install/channel: release

    Symptom

    Assistant replies render Markdown normally (headings, bold, tables, lists, code blocks), but all math falls back to raw LaTeX source. No error is surfaced; the $...$ / $$...$$ delimiters are shown literally.

    Evidence that the message content is fine

    Reading the raw message back from the local session store (GET /api/session/{sessionID}/message):

    • The text is standard Markdown + LaTeX.
    • No \ escaping and no ``` fence wrapping.
    • $ delimiters are balanced (even count).

    So this is not a producer-side escaping or fencing problem.

    Evidence that the formulas are fine

    Every formula from the failing reply was rendered through KaTeX 0.16.11 with throwOnError: true (the same strictness the Desktop renderer uses):

    Formula Result
    A^{-1} ok
    AB=BA=I,\qquad B=A^{-1} ok
    \det(A)\neq0\iff\operatorname{rank}(A)=n\iff A\ \text{可逆}\iff Ax=0\ \text{只有零解}\iff \text{行(列)向量组线性无关} ok
    A^{-1}=\dfrac{1}{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix} ok
    (A\mid I)\to(I\mid A^{-1}) ok
    \text{可逆} ok

    All render without error, including \operatorname and CJK inside \text{}. The failure is therefore in the Desktop chat renderer's math recognition, not in KaTeX parsing.

    Notes

    Workaround

    Pasting the same message into Obsidian renders $...$ correctly, confirming the source bytes are correct.

  6. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    Closing as a duplicate of #38030. Same Desktop LaTeX rendering regression (comments show block math is affected too). Tracking in #38030.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions