Skip to content

Support RTL/BiDi text rendering in CLI output #38524

Closed as duplicate
Closed as duplicate

Description

@yanivhrs

Problem

When typing or displaying Hebrew (and other RTL scripts) in opencode's CLI interface, the text renders with broken BiDi — characters appear in the wrong visual order because most terminal emulators lack proper bidirectional text support.

This affects a significant user base (Hebrew, Arabic, Persian, Urdu, etc.) and is not a trivial cosmetic issue — it makes the tool unusable for prompts and responses in RTL languages.

Example

Typing Hebrew text in the chat produces output where words appear disjointed or in reverse order, depending on the surrounding LTR characters.

Suggested approach

Some possible mitigations at the application level:

  1. Unicode BiDi control characters — wrap detected RTL text segments with RLM (U+200F) or LRM (U+200E) markers to give terminals a hint about direction.
  2. Bidi algorithm implementation — apply the Unicode Bidirectional Algorithm (UAX#9) to reorder text before writing to stdout, so the terminal receives already-correctly-ordered glyphs.
  3. Configuration flag — add an \
    tl\\ or \\�idi\\ option that users in RTL locales can enable.

Environment

  • opencode CLI (terminal interface)
  • Windows Terminal / iTerm2 / etc.
  • Hebrew locale / RTL input

References

Activity

  1. github-actions commented on Jul 23, 2026

    @github-actions
    Contributor

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

    Please review those issues to see if your report is already covered, and consider adding any new details there instead.

  2. yanivhrs commented on Jul 23, 2026

    @yanivhrs
    Author

    Related issues check — conclusion:

    Issue Same root? Different surface?
    #32726 RTL text renders LTR Desktop app (Electron/HTML - CSS fix: unicode-bidi: plaintext)
    #26915 RTL support request Desktop app chat panel (CSS/HTML directional attributes)
    #35319 RTL broken + tested fix recipe Desktop app renderer (injected CSS/JS via Electron)
    #1685 Unrelated (mouse selection bug) Text highlighting, not RTL at all

    None are exact duplicates because this issue targets the CLI terminal (stdout TTY rendering — Unicode control characters / UAX#9 reordering), whereas the others all target the Desktop app's HTML/CSS renderer. Same family of problems (BiDi support), different layers of the stack — fixing one won't fix the other.

    If someone wants to take on the Desktop side, #35319 has a thorough, tested fix recipe ready to go.

  3. razavioo commented on Jul 29, 2026

    @razavioo

    Community plugin available: opencode-rtl

    While waiting for native RTL/BiDi support in the CLI renderer, we built an opencode plugin that tackles this at the plugin layer:

    # Install
    npm install opencode-rtl
    // opencode.json
    {
      "plugin": [
        ["opencode-rtl", { "language": "auto", "isolateAssistantText": "auto", "isolateUserMessages": "auto" }]
      ]
    }

    What it does today:

    • Unicode bidi isolation (RLI/LRI/PDI) for RTL paragraphs, headings, lists, blockquotes, and table cells
    • Inline code spans are LTR-isolated inside RTL text (e.g. fetchData() stays correct inside Persian prose)
    • System prompt injection so the model responds in the user's RTL language
    • Auto-detection of Arabic, Persian, Hebrew, Urdu, Pashto, and more
    • Digit conversion (preserve / latin / arabic-indic / eastern-arabic)

    What it can't do (needs core changes):

    • Right-alignment — Unicode bidi controls character ordering but not paragraph alignment. The TUI renderer would need native dir="rtl" paragraph alignment support.
    • Streaming formatting — experimental.text.complete only fires after the full response. A text.delta or text.partial mutation hook would let plugins format text as it streams.

    Repo: https://github.com/razavioo/opencode-rtl

    Would love to see native BiDi-aware rendering in the CLI output — this plugin is a bridge until then.

  4. razavioo commented on Sep 27, 2026

    @razavioo

    Until native BiDi support lands in OpenCode's TUI renderer, the opencode-rtl plugin provides a working solution.

    It wraps RTL text segments with Unicode bidi isolates (U+2067 RLI / U+2069 PDI), handles mixed LTR/RTL content (code blocks, tables, inline code), and rewrites the assistant's SSE stream so model output renders correctly in bidi-capable terminals.

    Works with OpenCode 1.x (0.1.9) and OpenCode 2.x (1.0.0).

    // opencode.jsonc (OpenCode 2)
    {
      "plugins": [{ "package": "opencode-rtl", "options": { "language": "auto" } }]
    }
  5. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    Closing as a duplicate of #16875. Same request: RTL/BiDi rendering in the terminal UI. Tracking in #16875.

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