claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[FEATURE] Plugin UI API: add text direction (dir / textAlign) to Box, Text and Markdown so mods can render RTL (Hebrew/Arabic)

Open yoram85 opened this issue 1 month ago • 1 comments

Problem

I write to Claude Code in Hebrew in the VS Code extension, and I tried to build a mod (plugin ui.render hook on UserMessage / AssistantMessage) that draws the conversation right-to-left. The plugin UI API doesn't let me do that:

  • The allowlisted Box / Text props cover layout, spacing and color only. There is no dir and no text alignment (textAlign), and a tree with any other prop fails validation.
  • Markdown (MarkdownProps) has no direction or alignment option either.
  • Client, which could run arbitrary web code, is available on desktop only and is missing on vscode.
  • Unicode direction marks (RLM/RLE) inside text only reorder runs within a line. They don't change paragraph alignment, so Hebrew stays left-aligned.

So right now a plugin can't fix RTL rendering on any surface, even though it can redraw every transcript row.

Proposed solution

Add a direction prop to the plugin element props, e.g.:

dir?: 'ltr' | 'rtl' | 'auto';      // Box, Text, Markdown
textAlign?: 'start' | 'end' | 'left' | 'right' | 'center';  // Text, Markdown

On vscode / desktop / mobile this could map straight to the HTML dir attribute and CSS text-align. On terminal it could be ignored, or used for right-alignment.

With that, an RTL mod is a few lines:

on('ui.render', { component: 'AssistantMessage' }, ($, e) => {
  const { Markdown } = $.ui.resolve(e);
  return <Markdown text={e.props.text} dir="auto" />;
});

Related

  • #78625: dir="auto" on the VS Code webview's assistant-message div. That would fix the default rendering, and this request would let users and plugins control it.
  • #37183: general RTL support.

Environment

  • Claude Code 2.1.289, VS Code extension, Windows 11
  • Language: Hebrew

yoram85 avatar Oct 06 '26 14:10 yoram85

+1, with data from building an RTL mod for the terminal surface (https://github.com/MohammedSaud404/rtl-terminal):

  • On terminal, a mod can get RTL right today, but only by working around the renderer. It wraps each paragraph itself, right-aligns the rows with Box alignItems="flex-end", and pins every run with RLM or LRM, because Claude Code reorders each row from strong characters only (LRO and isolates are ignored or printed as-is). Brackets have to be mirrored beforehand, since nothing mirrors them.
  • On macOS and Linux terminals other than VS Code's, Claude Code drops RLM and LRM and turns RLI and PDI into U+FFFD before the terminal sees them, so a mod can't hand a direction to the terminal's own bidi engine at all.
  • On vscode and desktop, as described above, there is no way to set direction or alignment.

A dir prop, mapping to the HTML dir attribute on the webview surfaces and to right-aligned rows with paragraph-level bidi on the terminal, would replace all of that with a few lines. Passing RLM, LRM and the isolates through to the terminal on macOS and Linux would also help the terminals that implement bidi themselves.

MohammedSaud404 avatar Oct 09 '26 12:10 MohammedSaud404