Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(rtl): land the terminal half of PR #213, hold the UI half

chaitanyagiri59d721ed3e19
diff --git a/src/renderer/src/components/SettingsModal.tsx b/src/renderer/src/components/SettingsModal.tsx
index cfee3770..31f443b4 100644
--- a/src/renderer/src/components/SettingsModal.tsx
+++ b/src/renderer/src/components/SettingsModal.tsx
@@ -24,6 +24,7 @@ import { AiEnginesSettings } from './AiEnginesSettings';
import { REALTIME_MODEL } from '@shared/realtimePricing';
import { RealtimeDevicePicker } from '@/realtime/DevicePicker';
import { CostHud } from '@/realtime/CostHud';
+import { isArabicTerminalEnabled, setArabicTerminalEnabled } from '@/terminal/arabicSetting';
import { isComposingKey } from '@shared/imeGuard';
import { LANGUAGES, setLanguage } from '@/i18n';
@@ -213,6 +214,9 @@ export function SettingsModal({ config, onClose, initialSection }: SettingsModal
catch { setKeepAwake(!next); }
};
const [simpleMode, setSimpleMode] = useState<boolean>(cfgX.audience === 'non-technical');
+ // Renderer-local, not part of HarnessConfig — it only changes how this window
+ // paints pty output. Read once; the setter keeps localStorage in step.
+ const [arabicTerminal, setArabicTerminal] = useState(isArabicTerminalEnabled);
const toggleSimpleMode = async () => {
const next = !simpleMode;
setSimpleMode(next);
@@ -959,6 +963,23 @@ export function SettingsModal({ config, onClose, initialSection }: SettingsModal
{simpleMode ? t('common.on') : t('common.off')}
</PixelButton>
</div>
+ <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
+ <span style={{ fontSize: 13, lineHeight: '20px', color: 'var(--cth-ink-900)' }}>
+ {t('settings.general.arabicTerminal')}
+ </span>
+ <span style={{ fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)' }}>
+ {t('settings.general.arabicTerminalDesc')}
+ </span>
+ </div>
+ <PixelButton
+ variant={arabicTerminal ? 'primary' : 'secondary'}
+ size="sm"
+ onClick={() => { const next = !arabicTerminal; setArabicTerminalEnabled(next); setArabicTerminal(next); }}
+ >
+ {arabicTerminal ? t('common.on') : t('common.off')}
+ </PixelButton>
+ </div>
</div>
</div>
diff --git a/src/renderer/src/components/terminalPool.ts b/src/renderer/src/components/terminalPool.ts
index e25b673e..28ec7727 100644
--- a/src/renderer/src/components/terminalPool.ts
+++ b/src/renderer/src/components/terminalPool.ts
@@ -18,6 +18,9 @@ import { Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
import { WebglAddon } from '@xterm/addon-webgl';
import { Unicode11Addon } from '@xterm/addon-unicode11';
+import { arabicJoinRanges } from '@/terminal/arabicJoiner';
+import { attachArabicSpacingFix } from '@/terminal/arabicSpacingFix';
+import { isArabicTerminalEnabled } from '@/terminal/arabicSetting';
import {
classifyPathToken, isPathToken, pathTokenMatcher, stripPathToken, type PathAction
} from '@shared/terminalPaths';
@@ -557,6 +560,12 @@ export function dismissTerminalPicker(ptyId: string): void {
* rather than leave a black terminal. */
function leaseWebglRenderer(entry: TerminalEntry): void {
if (entry.webgl) return;
+ // Arabic mode wants the DOM renderer ON PURPOSE: rows become real text nodes,
+ // so the browser's own engine does shaping and (with the CSS in
+ // design/global.css) bidi — what the WebGL cell painter structurally cannot
+ // (xterm.js has no bidi: xtermjs/xterm.js#701). Skipping the lease IS the
+ // feature, not a fallback.
+ if (isArabicTerminalEnabled()) return;
try {
const webgl = new WebglAddon();
webgl.onContextLoss(() => {
@@ -636,6 +645,30 @@ export function attachTerminal(entry: TerminalEntry, container: HTMLElement): vo
// terminal, and xterm needs its host in the document to measure the cell.
entry.term.open(entry.host);
entry.opened = true;
+ // Arabic/RTL terminal support (the full recipe is documented in
+ // terminal/arabicJoiner.ts): join every Arabic phrase into one render range,
+ // and strip xterm's per-span letter-spacing from Arabic spans. MUST come
+ // after open(): registering a joiner on an unopened terminal throws.
+ //
+ // The `cth-bidi` class is what scopes the bidi CSS in design/global.css to
+ // this terminal. The PR applied those rules to every .xterm on the page;
+ // they are `!important` and change span layout, so an English user who
+ // fell back to the DOM renderer (a lost WebGL lease) would have had their
+ // TUI box-drawing shifted by a feature they never enabled.
+ if (isArabicTerminalEnabled()) {
+ entry.host.classList.add('cth-bidi');
+ entry.term.registerCharacterJoiner(arabicJoinRanges);
+ entry.unsub.push(attachArabicSpacingFix(entry.host));
+ // Terminals open at boot, often BEFORE webfonts finish loading, so xterm
+ // measures Arabic glyphs against fallback metrics and keeps them. When
+ // the real fonts land, poke fontFamily (a self-assign) to force a
+ // re-measure and full repaint.
+ void document.fonts?.ready.then(() => {
+ if (entry.exited) return;
+ const fam = entry.term.options.fontFamily;
+ entry.term.options.fontFamily = fam;
+ });
+ }
}
leaseWebglRenderer(entry);
// PTY startup output can arrive before this pooled terminal subscribes.
diff --git a/src/renderer/src/design/global.css b/src/renderer/src/design/global.css
index 8ee112c1..536514b3 100644
--- a/src/renderer/src/design/global.css
+++ b/src/renderer/src/design/global.css
@@ -199,6 +199,26 @@ canvas, img, svg { image-rendering: pixelated; image-rendering: crisp-edges; }
font-feature-settings: "liga" 0, "clig" 0, "calt" 0 !important;
}
+/* Arabic/RTL in terminals (see terminal/arabicJoiner.ts for the whole recipe).
+ `plaintext` gives each ROW its own base direction from its first strong
+ character — an Arabic row lays out right-to-left and right-aligned, a Latin
+ row is untouched. The span override matters just as much: xterm's DOM
+ renderer emits inline-block spans, which are ATOMIC to the bidi algorithm, so
+ the browser can never reorder them; plain inline text it can. !important is
+ load-bearing: the DOM renderer INJECTS a runtime stylesheet whose rules land
+ after this file and would otherwise win the cascade.
+
+ SCOPED to `.cth-bidi`, which terminalPool puts on a host only when the user
+ has switched Arabic terminals on. Unscoped, these rules would also reshape
+ the terminal of an English user who happened to fall back to the DOM renderer
+ after losing a WebGL lease — a layout change from a feature they never
+ enabled. The WebGL canvas ignores CSS entirely, so this is inert either way
+ for anyone on the GPU renderer. */
+.cth-bidi .xterm .xterm-rows > div,
+.cth-bidi.xterm .xterm-rows > div { unicode-bidi: plaintext !important; }
+.cth-bidi .xterm .xterm-rows > div > span,
+.cth-bidi.xterm .xterm-rows > div > span { display: inline !important; unicode-bidi: normal !important; }
+
/* ─── Markdown preview (v0.3.4) ──────────────────────────────────────────────
Shared by the IDE split/preview view and the fullscreen file overlay. All
colors ride the tokens, so light + dark themes come for free. */
@@ -231,19 +251,26 @@ canvas, img, svg { image-rendering: pixelated; image-rendering: crisp-edges; }
padding: 10px 12px; overflow-x: auto; border-radius: 2px;
}
.cth-md-preview pre code { background: transparent; padding: 0; }
+/* Code is LTR no matter what language the prose around it is in: an inline
+ `code` inherits dir from the paragraph holding it, which would flip a shell
+ command or a path. `isolate` keeps it from disturbing the surrounding run.
+ For LTR prose this is what already happened, so nothing moves. */
+.cth-md-preview code, .cth-md-preview pre {
+ direction: ltr; unicode-bidi: isolate; text-align: left;
+}
.cth-md-preview blockquote {
- margin: 0.8em 0; padding: 2px 0 2px 14px;
- border-left: 3px solid var(--cth-ink-300); color: var(--cth-ink-700);
+ margin: 0.8em 0; padding-block: 2px; padding-inline-start: 14px;
+ border-inline-start: 3px solid var(--cth-ink-300); color: var(--cth-ink-700);
}
-.cth-md-preview ul, .cth-md-preview ol { padding-left: 22px; margin: 0.5em 0; }
+.cth-md-preview ul, .cth-md-preview ol { padding-inline-start: 22px; margin: 0.5em 0; }
.cth-md-preview li { margin: 3px 0; }
.cth-md-preview li::marker { color: var(--cth-ink-500); }
-.cth-md-preview input[type="checkbox"] { accent-color: var(--cth-mint); margin-right: 6px; }
+.cth-md-preview input[type="checkbox"] { accent-color: var(--cth-mint); margin-inline-end: 6px; }
.cth-md-preview table {
border-collapse: collapse; margin: 0.8em 0; display: block; overflow-x: auto;
}
.cth-md-preview th, .cth-md-preview td {
- border: 1px solid var(--cth-ink-100); padding: 5px 10px; text-align: left;
+ border: 1px solid var(--cth-ink-100); padding: 5px 10px; text-align: start;
font-size: 13px;
}
.cth-md-preview th { background: var(--cth-cream-200); font-weight: 600; }
diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json
index 70d64099..811c5757 100644
--- a/src/renderer/src/i18n/locales/en.json
+++ b/src/renderer/src/i18n/locales/en.json
@@ -244,7 +244,9 @@
"languageDesc": "Choose the language for the app interface. English is the default.",
"dangerZone": "DANGER ZONE",
"dangerDesc": "Reset wipes {{godName}}'s memories, the entire hive (every agent, message, task, and the board), the semantic-memory palace, and all settings - then takes you back to onboarding.",
- "resetStartOver": "reset & start over"
+ "resetStartOver": "reset & start over",
+ "arabicTerminal": "Arabic / RTL text in terminals",
+ "arabicTerminalDesc": "Renders terminals with the browser's text engine so Arabic joins and reads right-to-left (xterm has no bidi of its own). Off is the GPU renderer: faster, but RTL-blind. Off by default for everyone; applies to newly opened terminals."
},
"agentsModels": {
"defaultModel": "Default agent model",
diff --git a/src/renderer/src/i18n/locales/zh-CN.json b/src/renderer/src/i18n/locales/zh-CN.json
index ddc9408a..3e161829 100644
--- a/src/renderer/src/i18n/locales/zh-CN.json
+++ b/src/renderer/src/i18n/locales/zh-CN.json
@@ -244,7 +244,9 @@
"languageDesc": "选择应用界面的语言。默认英文。",
"dangerZone": "危险区",
"dangerDesc": "重置会抹掉 {{godName}} 的记忆、整个 hive(每个智能体、消息、任务和看板)、语义记忆宫殿以及所有设置——然后带你回到新手引导。",
- "resetStartOver": "重置并重新开始"
+ "resetStartOver": "重置并重新开始",
+ "arabicTerminal": "终端中的阿拉伯语 / RTL 文本",
+ "arabicTerminalDesc": "使用浏览器的文本引擎渲染终端,让阿拉伯语正确连写并从右向左显示(xterm 自身不支持 bidi)。关闭时使用 GPU 渲染器:更快,但无法处理 RTL。默认对所有人关闭;仅对新打开的终端生效。"
},
"agentsModels": {
"defaultModel": "默认智能体模型",
diff --git a/src/renderer/src/terminal/arabicJoiner.ts b/src/renderer/src/terminal/arabicJoiner.ts
new file mode 100644
index 00000000..95f12f61
--- /dev/null
+++ b/src/renderer/src/terminal/arabicJoiner.ts
@@ -0,0 +1,60 @@
+/**
+ * Arabic rendering for the terminal — the working recipe, three parts:
+ *
+ * 1. DOM renderer (terminalPool skips the WebGL lease in Arabic mode). Rows
+ * become real DOM text, so the browser's text engine is in play at all.
+ *
+ * 2. A character joiner (this file). On its own the DOM renderer emits a span
+ * PER CELL with letter-spacing — atomic boxes the browser can neither shape
+ * across nor reorder. Joining every Arabic phrase into one range makes it a
+ * single span: real contextual shaping, lam-alef ligatures, marks on their
+ * letters — by the font itself, no presentation-form tricks.
+ *
+ * 3. CSS in design/global.css: rows get `unicode-bidi: plaintext` (each row
+ * takes its base direction from its first strong character, like dir=auto)
+ * and spans drop to `display: inline` (inline-block boxes are atomic to the
+ * bidi algorithm — inline text isn't, so phrase order follows the UBA).
+ *
+ * Result measured in a real browser: Arabic rows right-aligned and correctly
+ * ordered, mixed Arabic/Latin rows interleave properly, Latin rows unchanged.
+ *
+ * KNOWN TRADE: the block cursor is drawn at the logical cell offset, counted
+ * from the left — on an RTL row it does not sit where the next glyph will
+ * appear. Reading correctness is worth a misplaced cursor.
+ */
+
+/** Arabic script, its supplements, and the presentation-form blocks. */
+export function isArabicCp(cp: number): boolean {
+ return (cp >= 0x0600 && cp <= 0x06ff) || (cp >= 0x0750 && cp <= 0x077f) ||
+ (cp >= 0xfb50 && cp <= 0xfdff) || (cp >= 0xfe70 && cp <= 0xfeff);
+}
+
+/** Characters a phrase may flow across without ending the join: the space and
+ * punctuation that sit BETWEEN Arabic words. The range still only extends as
+ * far as the last Arabic character, so trailing punctuation stays outside. */
+const PHRASE_GLUE = ' ,.:;()«»،؛؟!ـ-—';
+
+/**
+ * Ranges of `text` (one terminal row) to render as single units: every maximal
+ * stretch that containsArabic, glued across the punctuation between words.
+ * Shape matches xterm's registerCharacterJoiner contract: [start, end).
+ */
+export function arabicJoinRanges(text: string): [number, number][] {
+ const ranges: [number, number][] = [];
+ let i = 0;
+ while (i < text.length) {
+ if (!isArabicCp(text.charCodeAt(i))) { i++; continue; }
+ const start = i;
+ let end = i + 1;
+ let lastArabic = i + 1;
+ while (end < text.length) {
+ const cp = text.charCodeAt(end);
+ if (isArabicCp(cp)) { end++; lastArabic = end; continue; }
+ if (PHRASE_GLUE.includes(text[end])) { end++; continue; }
+ break;
+ }
+ if (lastArabic - start > 1) ranges.push([start, lastArabic]);
+ i = Math.max(end, lastArabic);
+ }
+ return ranges;
+}
diff --git a/src/renderer/src/terminal/arabicSetting.ts b/src/renderer/src/terminal/arabicSetting.ts
new file mode 100644
index 00000000..124905b6
--- /dev/null
+++ b/src/renderer/src/terminal/arabicSetting.ts
@@ -0,0 +1,42 @@
+/**
+ * The renderer switch for RTL-script terminal support: ON keeps xterm on its
+ * DOM renderer, registers the Arabic character joiner, and lets the bidi CSS
+ * in design/global.css do its work — together these render Arabic (and other
+ * RTL scripts' neutral runs) shaped and correctly ordered, which the WebGL
+ * cell painter structurally cannot (xterm.js has no bidi: xtermjs/xterm.js#701).
+ * OFF leases the WebGL renderer: faster, and exactly the previous behavior.
+ *
+ * DEFAULT: OFF, for everyone, until someone turns it on in Settings.
+ *
+ * The PR proposed defaulting it on for RTL system locales. That is the same
+ * OS-sniffing the language picker deliberately does not do: it would move an
+ * existing user off the GPU renderer on upgrade, because of their OS locale,
+ * without them asking. The founder's rule for this release is that nothing
+ * changes for anyone until they pick it, so the locale sniff is gone and the
+ * toggle is the only way in. Re-defaulting it belongs with the rest of the RTL
+ * UI work, once an RTL app language actually ships.
+ */
+const KEY = 'cth.arabicTerminal';
+
+let enabled = read();
+
+function read(): boolean {
+ try {
+ const stored = window.localStorage.getItem(KEY);
+ if (stored === '1') return true;
+ if (stored === '0') return false;
+ } catch { /* private mode — off, like everyone else */ }
+ return false;
+}
+
+/** Hot path — called on terminal attach; reads the cached value. */
+export function isArabicTerminalEnabled(): boolean {
+ return enabled;
+}
+
+/** Flip the switch. Renderer choice is made when a terminal leases WebGL (on
+ * attach), so this applies to newly created terminal views. */
+export function setArabicTerminalEnabled(next: boolean): void {
+ enabled = next;
+ try { window.localStorage.setItem(KEY, next ? '1' : '0'); } catch { /* private mode */ }
+}
diff --git a/src/renderer/src/terminal/arabicSpacingFix.ts b/src/renderer/src/terminal/arabicSpacingFix.ts
new file mode 100644
index 00000000..8b2267bc
--- /dev/null
+++ b/src/renderer/src/terminal/arabicSpacingFix.ts
@@ -0,0 +1,55 @@
+/**
+ * Part 4 of the Arabic terminal recipe (see arabicJoiner.ts for parts 1–3):
+ * neutralize xterm's letter-spacing on Arabic spans.
+ *
+ * The DOM renderer pads every text run with `letter-spacing` so its width comes
+ * out at an exact number of cells. For Latin monospace that is a sub-pixel
+ * correction; for a joined Arabic phrase — whose natural width is far narrower
+ * than one-cell-per-character — it stretches the phrase across its whole cell
+ * span. Two failures at once: huge gaps between letters, and the browser
+ * DISABLES cursive joining on any text with letter-spacing, so the letters
+ * disconnect exactly like the bug this whole effort exists to fix.
+ *
+ * CSS cannot express "spans whose text is Arabic", so this is a
+ * MutationObserver: whenever rows change, any span containing Arabic gets its
+ * letter-spacing forced to normal. Latin spans keep their correction, so TUI
+ * box-drawing stays cell-aligned. The pass is cheap — it touches only added
+ * nodes and changed text, a handful of spans per repaint.
+ */
+import { isArabicCp } from './arabicJoiner';
+
+function hasArabic(s: string): boolean {
+ for (let i = 0; i < s.length; i++) if (isArabicCp(s.charCodeAt(i))) return true;
+ return false;
+}
+
+function fixSpan(el: Element): void {
+ if (el.tagName === 'SPAN' && hasArabic(el.textContent ?? '')) {
+ (el as HTMLElement).style.letterSpacing = 'normal';
+ }
+}
+
+function sweep(root: ParentNode): void {
+ for (const el of root.querySelectorAll('span')) fixSpan(el);
+}
+
+/** Observe a terminal's host element; returns a disposer. */
+export function attachArabicSpacingFix(host: HTMLElement): () => void {
+ sweep(host);
+ const mo = new MutationObserver((records) => {
+ for (const r of records) {
+ if (r.type === 'characterData') {
+ const el = r.target.parentElement;
+ if (el) fixSpan(el);
+ continue;
+ }
+ for (const n of r.addedNodes) {
+ if (n.nodeType !== Node.ELEMENT_NODE) continue;
+ fixSpan(n as Element);
+ sweep(n as Element);
+ }
+ }
+ });
+ mo.observe(host, { subtree: true, childList: true, characterData: true });
+ return () => mo.disconnect();
+}
diff --git a/test/arabic-terminal.test.cjs b/test/arabic-terminal.test.cjs
new file mode 100644
index 00000000..0634fb68
--- /dev/null
+++ b/test/arabic-terminal.test.cjs
@@ -0,0 +1,115 @@
+'use strict';
+
+// The terminal half of PR #213. It landed on ONE condition: that it is inert
+// for everybody who has not switched it on. These tests are that condition.
+// Arabic rendering CORRECTNESS is not tested here and is not claimed — it needs
+// a reviewer who reads Arabic, which this one is not.
+
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const loadTs = require('./load-ts.cjs');
+
+const { arabicJoinRanges, isArabicCp } = loadTs('src/renderer/src/terminal/arabicJoiner.ts');
+const root = path.join(__dirname, '..');
+const read = (p) => fs.readFileSync(path.join(root, p), 'utf8');
+
+const HELLO_AR = 'مرحبا'; // 5 Arabic letters, U+0645 U+0631 U+062D U+0628 U+0627
+
+// --- inertness: the whole basis for landing this half ----------------------
+
+test('a row with no Arabic produces no join ranges at all', () => {
+ for (const row of [
+ '', 'hello world', '$ npm run build', 'const x = 42;',
+ '┌───┐│ box │└───┘', // TUI box drawing
+ '\x1b[31mred\x1b[0m', // an escape sequence that reached the row
+ '你好世界', // CJK is not RTL and must not join
+ 'café — naïve « quotes »' // latin-1 plus the punctuation used as glue
+ ]) {
+ assert.deepEqual(arabicJoinRanges(row), [], `joined something in: ${JSON.stringify(row)}`);
+ }
+});
+
+test('glue characters alone never create a range', () => {
+ // PHRASE_GLUE only extends a run that already started on an Arabic letter.
+ // Its ASCII/Latin half is tested here; the rest of the list (، ؛ ؟ and the
+ // tatweel ـ) sits INSIDE the Arabic block, so those are Arabic first and glue
+ // second, and they are covered by the phrase tests below.
+ assert.deepEqual(arabicJoinRanges(' ,.:;()«»!-—'), []);
+});
+
+test('a lone Arabic character is left alone', () => {
+ // Nothing to shape across, so there is no reason to make it a span.
+ assert.deepEqual(arabicJoinRanges(`a ${HELLO_AR[0]} b`), []);
+});
+
+// --- it does do its job ----------------------------------------------------
+
+test('an Arabic word becomes one range', () => {
+ assert.deepEqual(arabicJoinRanges(HELLO_AR), [[0, 5]]);
+});
+
+test('a range stops at the last Arabic character, not the trailing space', () => {
+ const row = `hi ${HELLO_AR} bye`;
+ assert.deepEqual(arabicJoinRanges(row), [[3, 8]]);
+ assert.equal(row.slice(3, 8), HELLO_AR);
+});
+
+test('a phrase flows across the punctuation between its words', () => {
+ const two = `${HELLO_AR} ${HELLO_AR}`;
+ assert.deepEqual(arabicJoinRanges(two), [[0, two.length]]);
+});
+
+test('isArabicCp covers the script blocks and nothing else', () => {
+ for (const cp of [0x0600, 0x06ff, 0x0750, 0x077f, 0xfb50, 0xfdff, 0xfe70, 0xfeff]) {
+ assert.equal(isArabicCp(cp), true, `0x${cp.toString(16)} should be Arabic`);
+ }
+ for (const cp of [0x0041, 0x05ff, 0x0700, 0x4e00, 0xfb4f, 0xfe6f]) {
+ assert.equal(isArabicCp(cp), false, `0x${cp.toString(16)} should not be Arabic`);
+ }
+});
+
+// --- the gates -------------------------------------------------------------
+
+test('the feature is off by default and does not sniff the OS locale', () => {
+ const src = read('src/renderer/src/terminal/arabicSetting.ts');
+ assert.doesNotMatch(src, /navigator/,
+ 'arabicSetting reads the OS locale again — the founder ruled that out');
+ assert.match(src, /return false;\s*\n\}/, 'read() must fall back to false');
+});
+
+test('nothing Arabic is wired into a terminal unless the toggle is on', () => {
+ const src = read('src/renderer/src/components/terminalPool.ts');
+ // Match the CALL, not the import line at the top of the file.
+ for (const call of ['registerCharacterJoiner(', 'attachArabicSpacingFix(entry.host)', "classList.add('cth-bidi')"]) {
+ const i = src.indexOf(call);
+ assert.ok(i > 0, `${call} is missing`);
+ const guard = src.lastIndexOf('if (isArabicTerminalEnabled())', i);
+ assert.ok(guard > 0 && i - guard < 1200, `${call} is not behind the enabled check`);
+ }
+});
+
+test('the bidi CSS is scoped, so it cannot reach a terminal that never opted in', () => {
+ const css = read('src/renderer/src/design/global.css');
+ // Only the terminal-row bidi rules. global.css also has a pre-existing
+ // .xterm-rows rule for ligature suppression, and a deliberately global
+ // `unicode-bidi: isolate` on markdown code spans; neither is this feature.
+ const rules = css.split('\n').filter((l) => l.includes('.xterm-rows > div'));
+ assert.ok(rules.length > 0, 'the bidi rules vanished');
+ for (const r of rules) {
+ assert.ok(r.includes('.cth-bidi'),
+ `an unscoped .xterm-rows rule reshapes every DOM-renderer terminal: ${r.trim()}`);
+ }
+});
+
+test('the markdown direction rules use logical properties, a no-op in LTR', () => {
+ // Only the .cth-md-preview rules. The separate .cth-md-card surface still
+ // uses physical properties; it belongs to the RTL UI half, which is held.
+ const md = read('src/renderer/src/design/global.css')
+ .split('\n').filter((l) => l.trim().startsWith('.cth-md-preview') || l.includes('inline-start'))
+ .join('\n');
+ assert.doesNotMatch(md, /padding-left:|border-left:|margin-right:/,
+ 'a physical property here renders differently once dir=rtl');
+ assert.match(md, /padding-inline-start|border-inline-start|margin-inline-end/);
+});