Skip to content

[FEATURE] Native RTL (Right-to-Left) alignment in TUI renderer #39525

Description

@razavioo

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:

Proposed Solution

Add native support to the TUI renderer to detect and align RTL text.

  1. 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).
  2. 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.
  3. 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

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