
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.
pre/code elements and table column order stay LTR.⇄ toggle button appears in the chat header, next to "New Chat".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.
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.
Install from the VS Code Marketplace, Open VSX, or a .vsix from Releases:
bashcursor --install-extension rtl-agents-<version>.vsix --force
Then activate it once:
RTL Agents: Activate RTL.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.
Because AI chat panels live inside the editor's workbench, the extension patches workbench files on disk. It's built to do that responsibly:
product.json checksums so you don't get an [Unsupported] warning, and restores them exactly on deactivation.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.
⭐ 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