gemini-cli - ✅(Solved) Fix Feature Request: Universal RTL and BiDi Support for Terminal Rendering [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25478Fetched 2026-04-16 07:05:58
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Timeline (top)
labeled ×2cross-referenced ×1issue_type_added ×1subscribed ×1

Fix Action

Fixed

PR fix notes

PR #25243: feat: implement universal RTL/BiDi support with ANSI-safe rendering

Description (problem / solution / changelog)

This PR introduces comprehensive RTL and BiDi support for the Gemini CLI. Key improvements:

  • Universal RTL Logic: Refactored utilities to support all RTL languages (Arabic, Hebrew, Persian, etc.).
  • ANSI-Safe Rendering: Preserves escape codes for styling during reordering.
  • Precise Line Wrapping: Implemented a "Wrap-First, Reorder-Second" strategy to prevent vertical line displacement.
  • Performance: Implemented a Singleton pattern for the BiDi engine to optimize memory usage.
  • Resiliency: Added a GEMINI_NATIVE_RTL environment variable as a kill switch for native terminal support.
  • Testing: Added comprehensive unit tests using Vitest to ensure stability across languages and environments.
  • Screenshots : <img width="952" height="745" alt="Screenshot 2026-04-13 034148" src="https://github.com/user-attachments/assets/1626c699-1b87-4daa-b542-4962fcdf4ea5" />
<img width="953" height="741" alt="Screenshot 2026-04-13 035437" src="https://github.com/user-attachments/assets/b07516cd-0234-4d6b-9377-6ae68bcf0af1" />

Fixes #25478

Changed files

  • RTL_CHANGELOG.md (added, +39/-0)
  • package-lock.json (modified, +14/-3)
  • packages/cli/package.json (modified, +2/-0)
  • packages/cli/src/ui/components/InputPrompt.tsx (modified, +119/-47)
  • packages/cli/src/ui/components/messages/UserMessage.tsx (modified, +11/-2)
  • packages/cli/src/ui/rtl/bidi-js.d.ts (added, +24/-0)
  • packages/cli/src/ui/rtl/bidi.ts (added, +87/-0)
  • packages/cli/src/ui/rtl/rtlUtils.test.ts (added, +40/-0)
  • packages/cli/src/ui/rtl/rtlUtils.ts (added, +91/-0)
  • packages/cli/src/ui/rtl/utils.ts (added, +27/-0)
  • packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx (modified, +11/-2)
  • packages/cli/src/ui/utils/TableRenderer.tsx (modified, +3/-1)
RAW_BUFFERClick to expand / collapse

What would you like to be added?

I am proposing the implementation of a comprehensive RTL and BiDi (Bidirectional) text rendering engine tailored for the CLI. I have already developed a complete solution with the following key improvements:

  • Universal RTL Logic: Refactored utilities to support all RTL languages (Arabic, Hebrew, Persian, Urdu, etc.).
  • ANSI-Safe Rendering: Preserves escape codes for styling during text reordering.
  • Precise Line Wrapping: Implemented a "Wrap-First, Reorder-Second" strategy to prevent vertical line displacement.
  • Performance: Implemented a Singleton pattern for the BiDi engine to optimize memory usage.
  • Resiliency: Added a GEMINI_NATIVE_RTL environment variable as a kill switch for native terminal support.
  • Testing: Added comprehensive unit tests using Vitest to ensure stability across languages and environments.

Why is this needed?

Currently, the Gemini CLI does not correctly render Right-to-Left (RTL) languages in the terminal. The text often appears disconnected, in reverse order, or suffers from severe formatting corruption when mixed with ANSI escape codes (colors, bold text, etc.).

While there have been previous requests for specific language support like Arabic (e.g., #1791, #2954), they were closed due to inactivity. The CLI currently lacks a universal bidirectional text shaping solution that safely handles terminal styling across all OS environments for all RTL languages.

Additional context

I have already submitted a Pull Request that fully implements this architecture and solves the issue.

Related PR: #25243 Before:

<img width="1463" height="390" alt="Image" src="https://github.com/user-attachments/assets/c69dd2fc-f582-48ed-a501-6d254022d90e" /> <img width="952" height="745" alt="Image" src="https://github.com/user-attachments/assets/28925ede-fa20-4ca5-a7ed-5689a23b0717" />

extent analysis

TL;DR

Review and merge the proposed Pull Request #25243 to implement a comprehensive RTL and BiDi text rendering engine for the CLI.

Guidance

  • Verify the proposed solution by testing it with various RTL languages and ANSI escape codes to ensure correct rendering.
  • Check the unit tests added using Vitest to ensure stability across languages and environments.
  • Review the implementation of the Singleton pattern for the BiDi engine to optimize memory usage.
  • Test the GEMINI_NATIVE_RTL environment variable as a kill switch for native terminal support.

Example

No code snippet is provided as the issue does not contain specific code details.

Notes

The proposed solution seems to address the issue of incorrect RTL language rendering in the Gemini CLI, but it's essential to review and test the implementation thoroughly to ensure its correctness and stability.

Recommendation

Apply the workaround by merging the proposed Pull Request #25243, as it provides a comprehensive solution to the RTL rendering issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING