RTL text (Persian, Arabic, Hebrew, etc.) is scrambled when English/Latin characters appear mid-sentence.
Chat seems to pick direction from the first strong character of the message, then applies it to the whole bubble. That is not enough for mixed RTL+LTR text. An English word, identifier, path, URL, or number in the middle of a Persian sentence breaks visual word order and punctuation.
The logical text is usually correct; only the displayed BiDi layout is wrong. This is a Chat UI rendering bug, not a model bug.
Steps to Reproduce
Open Chat or Agent.
Send a Persian sentence that starts with a Persian character and embeds an English token in the middle, e.g.:
لطفاً فایل create-form-client.ts را باز کن و تابع createFormClient را بررسی کن.
Send another sentence that starts with English, then continues in Persian, e.g.:
createFormClient باید روی snapshot ولیدیت کند، نه روی پرسشنامه زنده.
Compare the on-screen order with the same text copied into Notepad or a browser.
Expected Behavior
Each paragraph should get its own direction. Embedded English tokens (inline code, identifiers, URLs, numbers) should stay intact without reversing the surrounding RTL sentence. Punctuation should stay with the clause it belongs to. Code blocks should remain LTR.
Hey, thanks for the detailed report and for both examples, the analysis is spot on.
You read the behavior correctly. Your own messages take direction from the first strong character in each paragraph, so a sentence that starts with an English identifier like createFormClient flips the whole line to left-to-right. Assistant replies don’t detect direction yet, so a Persian sentence with an English token in the middle gets laid out as LTR, and the word order and punctuation look scrambled. The text itself is still intact, if you copy it into an RTL-aware editor, it reads correctly. This is a chat rendering limitation, not a model issue.
This is a known issue we’re tracking, and I’ve added your report to it. We don’t have a complete fix in the app yet, and I can’t share an exact timeline. I’ll post in the thread when there’s an update.
For now, two things help:
Ask the model to put Persian and English on separate lines, or keep names in inline code, this avoids most of the reordering.
Some folks in the community maintain extensions that apply RTL styling to the chat panel, for example the one shared in this thread: Add RTL for chat
The broken layout is not “the line starts with English.” It happens when the sentence starts with RTL and an English token sits in the middle of the same line.
Example (starts with Persian, English in the middle):
لطفاً فایل create-form-client.ts را باز کن و تابع createFormClient را بررسی کن.
What I see in Chat: the Persian word order and punctuation look reversed around the English identifiers. What I see after copy-paste into Notepad: the sentence is correct.
That is the case I was reporting. A line that starts with English (createFormClient باید روی snapshot…) is a second, related case — not the primary one.
First-strong-character on the whole bubble is not enough. An RTL-first paragraph with Latin in the same line still gets laid out as LTR, so the surrounding Persian reorders.
Thanks for the clarification, your analysis is correct. You’re right that first-strong across the whole bubble isn’t enough here: an RTL-first paragraph with an English token in the middle still gets laid out as LTR, and the surrounding Persian gets reordered, even though the text itself stays intact (after copying, it reads correctly). That’s exactly the rendering limitation we’re tracking, and I’ve added your main case to what’s already been shared with the team.
We don’t have a complete fix in the app yet, and I can’t share an exact timeline. I’ll reply in the thread when there’s an update.
For now, the same workaround still helps: ask the model to put Persian and English on separate lines (or keep names in inline code), plus community extensions for RTL styling of the chat panel from Add RTL for chat