Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
Chat / Markdown rendering (fenced code blocks)
Steps to reproduce
-
Have the assistant reply with a prose fence (
md,markdown,textor a fence with no language) whose lines are Arabic or Hebrew, for example:```md تدخل **كندة** القاعة. الرؤوس تلتفت. > **كندة** > صباح الخير. اليوم سأغيّر رأيكم. ::: **تقاطع مع** ::: English line stays left. ``` -
Look at the rendered block.
Expected behavior
A prose fence is written text, not source code. Each line should get its own direction, so Arabic lines read right to left and right-aligned, and English lines in the same block stay left to right. Real code fences (ts, py, …) should stay LTR as they are now.
Actual behavior
MarkdownCodeBlock puts dir="ltr" on every fence, prose fences included (apps/web/src/components/chat/MarkdownCodeBlock.tsx, the wrapper with className="chat-markdown-codeblock …"). As a result, Arabic lines in a md / text block:
- end with the full stop on the wrong side (
تدخل **كندة** القاعة.shows the.at the left), - have
**,>and:::reordered against the words around them, - are left-aligned.
A second issue shows up once such a line is RTL: coding fonts with contextual alternates (Fira Code, Cascadia Code…) draw **, --, .. and ::: as ligatures whose glyphs are shifted into the neighbouring cell. That only works left to right. Between Arabic words those glyphs land on the wrong side and overprint the Arabic letters.
Upstream has already fixed this for paragraphs, lists, quotes and inline code (markdownTextDirection.ts, #22777, #26095, #36876). Prose fences are the remaining gap.
Suggested fix
I've been running this as a local CSS patch on the desktop app and it works. Code fences are untouched.
/* Prose fences: each newline-separated line is its own bidi paragraph. */
.chat-markdown-codeblock:is(
[data-language="md" i], [data-language="markdown" i], [data-language="mdx" i],
[data-language="text" i], [data-language="txt" i],
[data-language="plaintext" i], [data-language="plain" i]
) pre {
unicode-bidi: plaintext;
text-align: start;
}
/* Coding-font ligatures are drawn assuming LTR and overprint RTL letters. */
.chat-markdown-codeblock:is(/* same list */) pre :is(code, span) {
font-variant-ligatures: none;
font-feature-settings: "liga" 0, "calt" 0;
}unicode-bidi: plaintext on the <pre> treats each line as a separate bidi paragraph. Shiki's .line spans are inline, so they don't get in the way, and text-align: start then follows each line. The fence header (language label, copy button) is outside the <pre> and keeps its LTR layout. Another option is to drop dir="ltr" for these languages and set the direction per line the way markdownTextDirection.ts does for blocks.
Impact
Minor bug or occasional failure
Version or commit
0.1.12-nightly.20261122.5085 (desktop); still present on main at 60682f7
Environment
Windows 11 Pro, desktop app (Electron)
Logs or stack traces
No response
Screenshots, recordings, or supporting files
No response
Workaround
A local CSS injection into the renderer's index.html.
Activity