Repository navigation
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
moritzWa
added a commit
to moritzWa/opencode
that referenced
this pull request
Oct 5, 2026
1 task done
Member
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
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 #53648
#40508 tracks LaTeX rendering for the v2 TUI.
Type of change
What does this PR do?
Models often write math as
\( … \),\[ … \]or$$ … $$in prose. The TUI passes message text straight to the opentui<markdown>component, which has no math support, so formulas show as raw LaTeX (e.g.\text{saved} = (\text{units …}) \times \text{rate}or\(0.5^5 \approx 3\%\)).This adds
renderMath(packages/tui/src/util/math.ts), a small LaTeX-to-Unicode pass applied to assistant text and reasoning before markdown rendering. The two examples above becomesaved = (units …) × rateand0.5⁵ ≈ 3%. It handles\text{}, fractions, square roots, superscripts and subscripts (falling back to_(…)when Unicode has no subscript for a letter), Greek letters, common operators and arrows,\left/\right,\mathbb, and multi-line environments.What it leaves alone:
$is not treated as math, so amounts like "$900M" stay as written.#45339 added fenced
```latexrendering to v2. This covers prose math on the current TUI.How did you verify your code works?
packages/tui/test/util/math.test.ts(7 tests), andbun run typecheckinpackages/tui.renderMathover every assistant message containing math delimiters in my local session database (16 parts). 3 changed, all correctly, and nothing inside code was modified.Screenshots / recordings
Rendered with the TUI's
<markdown>component and defaultopencodetheme.Before: the delimiters and commands show raw.
After: the same text after
renderMath. Inline code is unchanged.Checklist