Repository navigation
Description
Description
- I have verified this feature I'm about to request hasn't been suggested before.
The CLI/TUI renderer currently assumes all text is Left-to-Right (LTR). When a user configures OpenCode to speak an RTL language (Arabic, Persian, Hebrew) or uses an RTL plugin like opencode-rtl, the text's unicode character ordering can be fixed via BiDi control characters, but the text remains strictly left-aligned.
In right-to-left languages, reading left-aligned text is incredibly jarring. We need a way for the TUI to right-align blocks of text that are predominantly RTL.
Why this is not a duplicate:
- Support RTL/BiDi text rendering in CLI output #38524 reports BiDi character ordering bugs — this issue is specifically about paragraph alignment (right-aligning text in the terminal), which is a different rendering concern.
- [FEATURE]: Add RTL (Right-to-Left) language support in the chat panel #26915 targets the Desktop/Electron app (CSS
dirattribute) — this issue targets the CLI/TUI renderer (terminal padding/alignment). - Persian/Arabic (RTL) text is not displayed correctly in opencode TUI #32984 reports that Persian/Arabic text is "not displayed correctly" — this issue proposes a concrete implementation for right-alignment specifically, which none of the above issues address with a proposed solution for the TUI.
Proposed Solution
Add native support to the TUI renderer to detect and align RTL text.
- Detection: When rendering a block of text (paragraph, list item, etc.), check if the first strong directional character is RTL (or if the block contains a high percentage of RTL characters).
- Alignment: If the block is RTL, pad the text with spaces on the left side instead of the right side, effectively right-aligning it in the terminal window.
- Configuration: This could be an explicit setting in
opencode.json(e.g.,"ui": { "rtl": true }) or auto-detected.
Alternative Solution
If native detection is too complex for the TUI renderer (Ink/React), expose a styling primitive or terminal width variable to plugins so they can pad strings manually to achieve right-alignment.
Context
See the opencode-rtl community plugin (https://github.com/razavioo/opencode-rtl) which solves the unicode bidi ordering problems, but is currently blocked from fully solving the UX because it cannot control terminal alignment.
Activity
github-actions commentedon Jul 29, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
- [ ] I have verified this feature I'm about to request hasn't been suggested before.Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know.
github-actions commentedon Jul 29, 2026
Thank you for updating the issue! It now looks great — the verification checkbox is checked, the problem is clearly explained, and the proposed solution is well thought out. The needs:compliance label has been removed.
razavioo commentedon Sep 27, 2026
Until native RTL alignment lands in the TUI renderer, the opencode-rtl plugin is the community workaround. It uses Unicode bidi isolates at the text level so terminals with bidi support render RTL correctly.
The related request in #39526 (streaming text transformation hook) was partly what motivated the v1.0.0 rewrite — since OpenCode 2 removed the
text.completehook, the plugin now intercepts the provider SSE stream viahttp.responseto apply bidi isolation to assistant text as it streams.opencodejr commentedon Oct 28, 2026
Thanks for the detailed request, @razavioo! You're asking for the TUI to right-align blocks of text (paragraphs, list items and so on) that are mainly RTL. That would happen either automatically, based on the first strong directional character in each block, or through an option such as
"ui": { "rtl": true }. It would fill the alignment gap thatopencode-rtlcan't cover with bidi control characters alone.I checked whether a plugin could do this today. It can't do it reliably. The TUI plugin API can add content at a few fixed places in the UI and register markdown code-block renderers. Nothing reaches how message text or paragraphs are laid out, and spaces added to the text itself get re-wrapped by the TUI. So this would need either built-in alignment in the TUI or a new hook for each text block, such as a per-paragraph
align/directioncallback, in the plugin API. I've noted both options for the maintainers, who will consider this.Related issues: