Repository navigation
fix(ui): render dollar math with marked-katex-extension - #53513
Merged
Merged
Conversation
opencode-agent
Bot
force-pushed
the
desktop-dollar-math
branch
from
October 6, 2026 10:36
c517b36 to
9eb8b67
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #38030
Type of change
What does this PR do?
Desktop has only rendered
\(...\)inline math and$$blocks on their own lines since #34850, so the$...$and single-line$$...$$that most models emit show up as raw LaTeX.marked-katex-extension(default mode) for$...$,$$...$$, and$$blocks, replacing our block regex. Our\(...\)inline extension stays because the package doesn't support that syntax.$must follow a space or line start, and the closing$must be followed by a space or punctuation. So "$5 and $10", "$5-$10", and$HOMEstay plain.parseSmallMarkdownused to keep text on the main-thread fast path unless it contained\(or$$. That fast path has no math support, so short messages with$x$would never reach KaTeX. Any text with two or more$now goes to the worker; a lone$5stays on the fast path.$$block containing a blank line was split into separately rendered blocks while streaming.Known limits of the extension's default mode, captured in tests: tight inline math such as
($x$),$x$-axis, and CJK without spaces (因此$x^2$是) stays raw. A price and math on the same line (Pay $5 now, or $x$ later) can be read as one formula and render as a KaTeX error.\[...\]is still unsupported.This takes a different approach from #52100.
How did you verify your code works?
packages/ui:bun test src/context(111 pass) andbun run typecheckpackages/session-ui:bun test src/components/markdown(88 pass) andbun run typecheck; the new stream test fails without the splitter changepackages/app:bun run typecheck$regex (unclosed$followed by thousands of backslashes) parse in about 13msScreenshots / recordings
Not captured in the app; verified at the parser and stream-splitter level.
Checklist
Requested by: @Brendonovich (Brendan via Slack)