Skip to content

feat(tui): full RTL/Bidi support for Persian, Arabic, Hebrew, and Urdu text #41454

@aminshurabi

Description

@aminshurabi

feat(tui): Full RTL/Bidi support for Persian, Arabic, Hebrew, and Urdu text

Problem

Persian, Arabic, Hebrew, and Urdu text renders left-aligned with disconnected letters in the Hermes TUI (hermes --tui). This makes the TUI unusable for ~500M+ potential users across Iran, the Middle East, North Africa, Pakistan, and Israel.

Currently:

  • 🇮🇷 Chat messages render LTR (left-aligned) regardless of content
  • 🔤 Persian/Arabic script letters are disconnected (isolated forms instead of cursive)
  • 📌 Gutter glyph (▸ / ⚕) stays fixed on left for all languages
  • ⌨️ Input field has no RTL cursor direction support
  • 📝 Markdown blocks ignore text direction

Proposed Solution

Phase 1: Chat Message RTL (MVP)

  • Detect RTL text via Unicode range (\u0600-\u06FF Arabic/Persian, \u0590-\u05FF Hebrew, \u0750-\u077F Arabic Supplement)
  • Apply flexDirection: "row-reverse" for RTL message rows
  • Apply alignItems: "flex-end" for RTL message content
  • Mirror gutter glyph spacing for RTL

Phase 2: Full Bidi

  • RTL cursor movement in input field when typing RTL text
  • Per-paragraph direction detection in markdown renderer
  • RTL tool output previews
  • RTL system messages

Phase 3: Configuration

  • display.rtl_enabled: true/false in config.yaml
  • Auto-detect vs. force-LTR toggle

Implementation Notes

The fix is straightforward — a working prototype already exists as a local patch:

  1. Add RTL detection regex to messageLine.tsx
  2. Insert flexDirection={rtl ? 'row-reverse' : 'row'} on the message row
  3. Add alignItems={rtl ? 'flex-end' : 'flex-start'} on the content box

Impact

  • Iran: ~90M Persian speakers
  • Arab world: ~400M Arabic speakers
  • Israel: ~9M Hebrew speakers
  • Pakistan: ~230M (Urdu uses Arabic script)
  • Afghanistan: ~40M (Dari/Pashto)

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/tuiTerminal UI (ui-tui/ + tui_gateway/)type/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions