Repository navigation
Studio: show right-to-left chat messages right to left - #16348
Conversation
Each paragraph, heading and table cell of a reply takes dir=auto, and lists and quotes whose text starts in an RTL script get dir=rtl, so Persian, Arabic, Urdu and Hebrew read right to left with markers on the right. Code blocks and English text stay left to right. The user bubble gets dir=auto like the composer already has, and list padding is logical so it follows the list's side. Fixes #16201.
|
@codex review |
1 similar comment
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7a5d3fb16
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (letter && RTL_LETTER.test(letter)) { | ||
| node.properties.dir = "rtl"; | ||
| } |
There was a problem hiding this comment.
Explicitly reset LTR direction on nested English containers
When an English list is nested inside a Persian/Arabic list or blockquote, its first letter fails this condition, so it receives no dir and inherits the outer container's new rtl direction. For example, - سلام\n - English item. now puts the English sublist's marker on the right and lays out its punctuation as RTL, whereas it previously rendered LTR. Set an explicit ltr direction when a container's first letter is LTR rather than relying on inheritance.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c603fdb: lists and quotes now get an explicit ltr when their text starts left to right, so a nested English list no longer inherits rtl.
| if (TEXT_BLOCKS.has(node.tagName)) { | ||
| node.properties.dir = "auto"; |
There was a problem hiding this comment.
Isolate code from the newly applied RTL direction
For RTL paragraphs containing inline code, or RTL lists/blockquotes containing fenced code, setting direction on the ancestor also changes the code's inherited direction. Skipping pre and code in firstLetter does not prevent this: neither the plugin nor the existing code styles and FenceBody renderers establish an LTR boundary. Consequently, code punctuation and alignment can change in these replies instead of preserving the previous LTR rendering. Explicitly isolate code with LTR direction, including the custom fence renderers; the new test's assertion that code has no dir attribute does not verify its effective direction.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c603fdb: code blocks (including the custom fence renderers, which share data-streamdown=code-block), inline code and reasoning code are pinned to direction: ltr with unicode-bidi: isolate.
…eplies Lists and quotes now get an explicit ltr when their text starts in a left-to-right script, so an English list nested in a Persian one no longer inherits rtl. Code blocks and inline code are pinned ltr and isolated, and a code block in an RTL list pulls into the list's right-hand indent instead of the left.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c603fdb553
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const letter = firstLetter(node); | ||
| if (letter) { | ||
| node.properties.dir = RTL_LETTER.test(letter) ? "rtl" : "ltr"; |
There was a problem hiding this comment.
Give tight list items their own text direction
For a mixed-language tight list such as - سلام\n- English item., this assigns rtl to the entire list, but neither li receives its own direction because li is absent from TEXT_BLOCKS. Tight Markdown lists have no paragraph wrapper, so the English item's text inherits RTL, moving its trailing punctuation to the wrong side and right-aligning content that previously rendered LTR. Give individual list-item text an independent direction boundary while retaining the container direction needed for list padding and markers.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4f00856: a tight item's leading text is wrapped in an inline dir=auto span, so an English item in an RTL list keeps its punctuation at the end. The item itself keeps the list's direction so all markers stay on one side.
A tight item's text has no paragraph to carry dir=auto, so it is wrapped in an inline dir=auto span. An English item in a Persian list now keeps its punctuation at the end, while the item itself keeps the list's direction so every marker stays on the same side.
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
The new The earlier |
What changed
Fixes #16201: chat messages written in a right-to-left script (Persian, Arabic, Urdu, Hebrew) now read right to left, whatever the interface language.
dir="auto", so each one takes its direction from its own first letter. Mixed replies work line by line: a Persian paragraph is right to left and the English one under it stays left to right.dir="rtl", so the numbers and bullets move to the right. They need an explicit value:dir="auto"on a list skips the items that carry their owndir, so it would always resolve to left to right.dir="auto", matching the composer, which already had it.index.cssusespadding-inline-startinstead ofpadding-left, so it follows the list to the right side. Left-to-right lists render exactly as before.The direction is added by a small rehype plugin after Streamdown's sanitizer, next to the existing sandbox image plugin.
Verification
npm run typecheck,npm test(14526 pass, 0 fail, including the newrehype-auto-direction.test.tsthat runs the chat's real sanitize and harden pipeline),npm run build,npm run bundle:check.Not covered
Desktop builds are not run from this host. Other markdown surfaces (model READMEs, previews) are unchanged.