Agent RTL — Claude Code, Codex & Kimi
Persian and Arabic right-to-left text for the chat panels of three VS Code AI
agents: Claude Code (anthropic.claude-code), Codex (openai.chatgpt)
and Kimi Code (moonshot-ai.kimi-code). One engine handles messages,
plans, lists, tables, quotes, question cards and message inputs for all three.
Code and the agents' own UI stay left-to-right, and every change can be undone.
Published as jackprtda.agent-rtl. Earlier local releases used
mohsen.agent-rtl and Kimi RTL Support (mohsen.kimi-rtl-support).
If either old extension is still installed, this version offers to uninstall
it and waits for a window reload so only one extension patches the agents.
Existing on/off state files and reversible patches remain compatible. A saved
Remove Injection choice belongs to the old VS Code identity; apply it again
after migration if you want that agent's patch to remain removed.
What you get
- Smart direction by content, per block. Messages and inputs share a
Unicode-aware prose classifier. Each paragraph, heading, list item, cell and
quote is measured separately. English product names and acronyms have less
weight than surrounding Persian grammar; paths, URLs, code and Markdown link
destinations do not dominate the prose.
Claude Code را بررسی کن and
API و سپس … read from the right. An English sentence containing a short
Persian quotation stays left-to-right. Digits and punctuation cast no vote.
- Lists. Bullets and numbers sit beside their own text on the right. Numbers
read
98. rather than .98, and multi-digit counters are never clipped. An
English item inside a Persian list keeps the list's side, with its sentence
still reading left-to-right.
- Tables and quotes. Table columns flow right-to-left and the table moves to
the right edge. English or numeric cells align with their table. The quote
bar and its padding move to the right.
- Technical text keeps its order. Code blocks and inline code stay
left-to-right. Times (
10:30), addresses (127.0.0.1:3020), dates and
versions keep the order you would get from plain RTL text. Arrow relations such
as service.example.com → 127.0.0.1:3020 stay in reading order.
- Message inputs. The same classifier handles drafts, including Persian
sentences starting with English names. Codex rich-text paragraphs choose
their directions independently without changing editor-owned DOM. Claude's
visible mention layer follows its input. Typing, caret, undo,
Enter/Shift+Enter and IME input are never intercepted.
- UI chrome is untouched. Buttons, menus, the
/ and @ popups, tool rows,
headers and flex layouts keep their native layout.
- Text is never rewritten. The extension only sets reversible CSS
properties. It inserts no characters and replaces no nodes, so copy, drag,
selection and streaming behave exactly as they do without it.
Per agent
- Claude Code:
- Covered: sent and received messages, thinking, tool descriptions, TODO
lists, the question card (
AskUserQuestion), the main input with its
mention layer, answer and rejection inputs, and the separate Plan
Preview tab with its comments.
- A short Persian message fills its sent-message bubble instead of hugging
the left edge.
- Codex:
- Covered: messages, reasoning, plans, request cards (the question, its
choices and the free-text answer), and the ProseMirror input.
- In the request card, the question uses the full header width. Each choice's
label and description move together, while the number badges and controls
stay where they are.
- Kimi Code:
- Covered: messages, thinking, SetTodoList items, the question card (prompt,
choices and custom answer) and the input.
- Kimi's own auto permission mode is covered in its own section below.
Questions and popups
Question prose is classified independently from the controls around it. A
Persian label can remain RTL beside an English description; switching language
or navigating to the next question refreshes its direction. Native option
order, radio/checkbox state, keyboard shortcuts and answer text remain intact.
- Claude Code: single-select and multi-select
AskUserQuestion, question
tabs, option previews, Other-only free answers and answered review; natural
language in permission prompts and the known fallback/remote-control-offer
dialogs. Commands and paths retain their technical layout.
- Codex:
requestUserInput single choices, multiple questions, no-options
answers and secret-marked questions; the separate requestOptionPicker
radio/checklist picker, including custom answers and empty option lists;
execution-approval explanations and MCP schema-form questions with text,
enum, boolean and multiple-enum fields. Secret-marked requestUserInput
questions retain Codex's native editor behavior.
- Kimi: single and multiple selection, sequential questions with Back/Next,
custom choices and free responses, and natural-language approval descriptions.
Kimi's native question labels are plain text; they do not render Markdown.
Tests boot the installed apps and verify actual glyph positions, narrow
wrapping, Space/Enter/Escape, retained selections and the exact answers received
by the fake host. They also check that disabling RTL restores native styles.
Controls
Each installed agent gets a status-bar button (Claude Code RTL: On,
Codex RTL: Off, …) that toggles only that agent. Each chat panel's title bar
also has a button: a check mark means on, a crossed circle means off. New
installations are on for every agent. On/Off and Remove choices are remembered
across restarts and agent updates.
| Command |
Purpose |
Agent RTL: Manage |
Pick an agent and toggle, inspect or remove it |
Agent RTL: Toggle Claude Code / Codex / Kimi RTL |
Toggle one agent |
… RTL: Turn on / Turn off |
Set one agent's state (the title shows the current one) |
Agent RTL: Claude Code / Codex / Kimi Status |
Agent version, on/off, and whether the loaded patch is current |
Agent RTL: Remove Claude Code / Codex / Kimi Injection |
Remove the patch and stop reapplying it |
Reload the window after installing/updating Agent RTL, an agent update,
Remove, or changing an agent's on/off state. The command offers a reload;
it never reloads an active conversation automatically. The next webview loads
its saved state without background polling or recurring cache entries.
Remote-SSH and other remote workspaces
Agent RTL runs on the workspace host, where the agents themselves are
installed. In a remote window, install the VSIX on that remote host
(Extensions: Install from VSIX while connected), then Developer: Reload
Window. A local installation does not change agents running on a server.
Tooltips and the Status commands show whether the local host or a remote
workspace is patched. Each host keeps its own on/off state.
How it works
- The extension finds each agent's webview entry script:
- Claude Code:
webview/index.js
- Codex: the
assets/index-*.js named in webview/index.html
- Kimi:
dist/webview.js
- It appends a marked block (
/* MOHSEN-AGENT-RTL:BEGIN */ … END) to that
script. Claude Code's Plan Preview template in its extension.js gets a
second marked block inside the template's own nonce-authorised script.
- It writes
mohsen-agent-rtl-state.json (its own record) and embeds that
state in the payload. Legacy state SVGs are removed. The runtime makes no
polling requests; a reload loads the new setting.
- In the webview, the runtime observes only the changed messages. It sets
direction, text-align and unicode-bidi through the CSSOM (inline
!important properties), plus a few layout properties such as mirrored quote
borders or a table's margin.
- List markers and rich-text inputs use constructed stylesheets instead.
These work under nonce-only style policies and never touch nodes that an
editor manages.
- Turning off restores each property's previous value, including values the
host changed in the meantime.
- All writes are atomic. Before the first change, a pristine backup is saved
next to each patched file (
*.mohsen-rtl-backup). A lock file prevents
concurrent patching.
- An unknown Plan Preview template stops the whole operation before either
file is written.
- Another extension's RTL patch is reported as a conflict and left alone.
- The Kimi text-rewriting block from releases before 0.4 is replaced
automatically, and its on/off choice is kept.
- After an agent update, or after this extension is updated, the current
runtime is written again on the next activation.
Kimi auto permission mode
Kimi Code starts new sessions in manual approval mode. There is no setting for
fully autonomous auto mode, so Agent RTL changes the default in Kimi's
extension host (const defaultApproval = { …, afk: false } becomes
afk: true). It keeps a one-time pristine backup
(extension.js.kimi-rtl-backup) and reapplies the change after Kimi updates.
Agent RTL: Remove Kimi Injection restores the backup. This behaviour applies
to Kimi only; Codex and Claude Code permissions are never touched. If a Kimi
release no longer contains that code, the change is skipped and RTL still works.
Compatibility
Verified by booting each agent's real webview application in Chromium:
- Claude Code 2.1.325
- Codex 26.1111.21308
- Kimi Code 0.9.0
Earlier Claude Code 2.1.26x and Codex 26.90x markup is covered by the
fixture-based tests.
Editors: VS Code, VS Code Insiders, VS Code Server (Remote-SSH), Cursor,
Windsurf and Antigravity installations under the user's home directory.
Known limits:
- Ambiguous bilingual text. Detection is a deterministic local heuristic,
not a semantic language model. Very short, equally balanced fragments can
have more than one reasonable base direction. A leading LRM/RLM/ALM can
explicitly select the intended direction without the extension adding marks.
- Mixed lines inside one plain-text node/control. A native textarea or
Claude's plaintext-only editor cannot assign an independently inferred base
to each newline without rewriting the host's text or DOM. If all lines agree,
the heuristic wins even with English-leading Persian. If their directions
differ, native
plaintext provides first-strong direction per line. The same
limitation applies to one displayed pre-wrapped block or <br> sequence;
separate rich-text/Markdown paragraphs have independent inferred bases.
- Kimi file links in arrows. When one end of an arrow relation is a file
link, Kimi renders that end as a button. The relation then keeps the native
RTL order, so the arrow's direction can look reversed.
- Kimi numbered lists. Kimi's renderer ignores a list's starting number
(
98. shows as 1.). That comes from Kimi, not from this extension.
- Codex thread title. The title in Codex's header is part of a button and
keeps Codex's own rendering.
- Scope. Standalone desktop apps and terminal (CLI) output are not covered.
Permissions
Enabling RTL writes to the agents' extension folders, e.g.
~/.vscode-server/extensions/anthropic.claude-code-*/webview/. Those folders
belong to your user, so no administrator rights are needed. If a folder is
read-only, the error message names the file that could not be written.
Development
Plain JavaScript, no build step:
npm install
npm test # patching, discovery, migration, auto mode; real bundles when installed
CHROMIUM_PATH=/path/to/chromium npm test # adds all browser suites
npm run test:visual # browser suites only, with screenshots
npm run package # builds agent-rtl-<version>.vsix
- Real-app suites.
test/claude-app.test.js, test/codex-app.test.js and
test/kimi-app.test.js start each installed agent's real webview application
against an in-page fake extension host. They stream a scripted Persian/English
conversation into it and measure where glyphs and list markers actually land.
Nothing is sent to an agent backend.
- Pointing at a specific agent build. Set
CLAUDE_RTL_TEST_DIR,
CODEX_RTL_TEST_DIR or KIMI_RTL_TEST_DIR to an unpacked official
extension. The suites only read that folder.
Direction design follows Unicode UAX #9, higher-level protocols
for inferred paragraph bases and W3C inline bidi guidance
for opposite-direction isolation. dir=auto alone uses first-strong and cannot
solve English-leading Persian. Because these are third-party React/editor
documents, reversible CSSOM rules supply the inferred base without editing
their semantic attributes or text. The browser retains Unicode bidi ordering.
Publishing
Publishing to the Marketplace requires access to the jackprtda publisher
account. Building a VSIX, pushing Git commits or creating a GitLab release does
not publish anything.
npm run package
npx vsce login jackprtda
npm run publish # or upload the .vsix in the Marketplace management portal
License
MIT
| |