blog-logo
  • Codefa
  • Codeim
  • Interfacefa
  • Blog
  • About
  • Contact

All rights reserved by Foshati

DitfaTeamtemT.TeljooNeex
RTL Agents: Proper Right-to-Left AI Chat in Cursor, VS Code, Windsurf and Antigravity

RTL Agents: Proper Right-to-Left AI Chat in Cursor, VS Code, Windsurf and Antigravity

By Simon Sanders•October 29, 2026

If you write to AI assistants in Persian, Arabic or Hebrew, you know the pain: the chat panel in your editor renders everything left-to-right. Sentences start on the wrong side, punctuation jumps around, and a reply that begins with npm install becomes unreadable.

RTL Agents is an open-source (MIT) extension that fixes this in Cursor, VS Code, Windsurf, VSCodium and Antigravity — without flipping your code, your editor, or your tables.

What it does

  • Message text is pinned to a right-to-left base.
  • Latin runs inside a sentence — library names, commands, inline code — keep their natural left-to-right order.
  • Code blocks, Monaco editors, pre/code elements and table column order stay LTR.
  • A ⇄ toggle button appears in the chat header, next to "New Chat".

Why "detect the language" doesn't work

The obvious approach is to detect direction per paragraph from its first strong character. In practice, that breaks constantly. A normal Persian sentence that happens to start with API, OTP or npm install flips entirely to LTR — left-aligned, with its punctuation on the wrong side. On a representative set of real chat replies, first-character detection misfired on roughly 40% of lines.

So RTL Agents pins the base direction to RTL and lets the browser's Unicode Bidirectional algorithm place every embedded Latin word, number and punctuation mark. The trade-off is small: an all-English paragraph is right-aligned, but its word order stays perfectly intact.

There's a second subtlety: editors indent lists and draw quote bars with physical CSS properties like padding-left and border-left, which don't follow direction. RTL Agents resets those and re-applies them on the logical start side, so lists and quotes look correct too.

Zero flicker while streaming

Earlier approaches ran JavaScript on every streamed word or watched the whole document with a MutationObserver. That causes visible flicker (text appears left-aligned, then jumps) and burns CPU while a reply generates.

Since v2, RTL Agents is pure CSS applied at layout time. Alignment is correct before the first paint, with no per-word script and no measurable CPU cost.

Installation

Install from the VS Code Marketplace, Open VSX, or a .vsix from Releases:

bash
cursor --install-extension rtl-agents-<version>.vsix --force

Then activate it once:

  1. Open the Command Palette and run RTL Agents: Activate RTL.
  2. Fully quit and reopen the editor (a window reload isn't enough).
  3. Open the AI chat and press Ctrl+Alt+R / Cmd+Ctrl+R, or click ⇄.

On macOS/Linux, if activation reports permission denied, the extension prints the exact sudo chown … command to run.

Safe to install, clean to remove

Because AI chat panels live inside the editor's workbench, the extension patches workbench files on disk. It's built to do that responsibly:

  • It updates the relevant product.json checksums so you don't get an [Unsupported] warning, and restores them exactly on deactivation.
  • Deactivate restores every patched file byte for byte.
  • It detects editor updates and re-applies itself automatically.
  • A backup from an older editor build is never written over a newer one.

Configuration

json
{
  "rtl-agents.baseDirection": "rtl",
  "rtl-agents.customSelectors": [".my-custom-chat-panel"]
}

Set baseDirection to "auto" only if your chats are mostly English with occasional RTL passages.

Get it

⭐ github.com/Foshati/rtl-agents — if you work in an RTL language, I'd love your feedback on edge cases in your favorite editor.

Comments

Sign in to leave a comment or like this post