Skip to content

[FEATURE]:راست چین شدن کادر چت #33201

Closed as duplicate
Closed as duplicate

Description

@SaberMarandi

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

در نسخه فعلی ، هنگام استفاده از زبان فارسی، کادر چت و محتوای پیام‌ها به‌صورت چپ‌چین نمایش داده می‌شود. و امکان راست چین کردن وجود ندارد.
این موضوع باعث کاهش خوانایی، تجربه کاربری ضعیف‌تر و ناسازگاری با استانداردهای زبان‌های راست‌به‌چپ می‌شود.
درخواست دارم امکان راست‌چین شدن کامل رابط چت (شامل ورودی، خروجی و جهت متن) برای زبان‌های RTL مانند فارسی اضافه شود.
این قابلیت تجربه کاربران فارسی‌زبان را به‌طور چشمگیری بهبود می‌دهد.

Activity

  1. mynameistito commented on Jun 21, 2026

    @mynameistito
    Contributor

    Translation to English:

    In the current version, when using the Persian language, the chat box and message content are displayed left-aligned, and there is no option to align them to the right.

    This reduces readability, weakens the user experience, and creates inconsistency with the standards of right-to-left languages.

    I would like to request the addition of full right-to-left alignment support for the chat interface, including the input field, output messages, and text direction, for RTL languages such as Persian.

    This feature would significantly improve the experience for Persian-speaking users.

  2. SaberMarandi commented on Jun 26, 2026

    @SaberMarandi
    Author

    هنوز این مشکل برطرف نشده

  3. NXR8 commented on Jul 16, 2026

    @NXR8

    RTL OpenCode — Arabic RTL Support System

    A system that adds Right-to-Left (RTL) text support to the OpenCode Desktop app while keeping code blocks LTR.


    How It Works

    1. Arabic Detection

    var AR = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF]/;

    Checks for any Arabic character within the first 30 characters of the text:

    • Arabic found → RTL
    • No Arabic → LTR

    Solves mixed-language cases:

    "This is a long English sentence... مع عربي في النهاية"  → LTR (Arabic after 48 chars)
    "Hello مرحبا"                                              → RTL (Arabic within first 30)
    

    2. Prompt Input

    Uses only 3 characters instead of 30 — switches to RTL instantly when the user types the first Arabic character.

    3. List Containers (<ol>, <ul>)

    These are skipped — they inherit direction from their parent (the Arabic paragraph). Individual <li> elements get direction based on their own content.

    4. Locking Code & Links LTR

    When an element is RTL, all code and anchor elements inside are forced LTR:

    code, span.line, .inline-code, a  ←  display:inline-block + dir:ltr

    5. MutationObserver for Streaming

    Monitors DOM changes with:

    • childList: new elements during streaming
    • subtree: all nesting levels
    • characterData: inline text changes

    Re-attaches the input event listener on the prompt input when React re-renders it.


    Console Snippet

    /* Paste this in Console after typing "allow pasting" */
    
    var s=document.createElement('style');
    s.textContent='p,li,ol,ul,blockquote,h1,h2,h3,h4,h5,h6,table,th,td,[data-slot="text-part-body"],[data-slot="user-message-text"],[data-component="prompt-input"]{text-align:start}'+
    '[data-component="markdown-code"],[data-component="markdown-code"] pre,[data-component="markdown-code"] code,[data-component="markdown-code"] span.line{direction:ltr!important;text-align:left!important}'+
    '[dir="rtl"] ol,[dir="rtl"] ul{padding-inline-start:32px}'+
    '[dir="rtl"] li>ol,[dir="rtl"] li>ul{padding-inline-start:1rem}';
    document.head.appendChild(s);
    
    var AR=/[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF]/;
    var SEL='p,li,ol,ul,blockquote,h1,h2,h3,h4,h5,h6,table,th,td,[data-slot="text-part-body"],[data-slot="user-message-text"]';
    
    function isText(n){return n.matches&&n.matches(SEL)}
    function setDir(el){
      if(!el||el.getAttribute('dr'))return;
      if(el.closest('pre')||el.tagName==='CODE')return;
      var t=(el.textContent||'').trim();
      if(!t){el.setAttribute('dir','ltr');el.setAttribute('dr','1');return}
      el.setAttribute('dir',AR.test(t.substring(0,30))?'rtl':'ltr');el.setAttribute('dr','1');
      if(el.getAttribute('dir')==='rtl')el.querySelectorAll('code,span.line,.inline-code,a,[dir="ltr"]').forEach(function(e){
        if(!e.closest('pre')){e.style.display='inline-block';e.setAttribute('dir','ltr');e.style.textAlign='left'}
      })
    }
    function attInp(el){
      if(!el||el.getAttribute('di'))return;
      el.addEventListener('input',function(){
        var t=(this.textContent||'').trim();
        if(!t)return;
        this.setAttribute('dir',AR.test(t.substring(0,3))?'rtl':'ltr')
      });
      el.setAttribute('di','1')
    }
    function scan(n){
      if(n.nodeType!==1)return;
      if(isText(n))setDir(n);
      if(n.matches&&n.matches('[data-component="prompt-input"],div[contenteditable="true"][role="textbox"]'))attInp(n);
      var f=n.querySelectorAll(SEL+',[data-component="prompt-input"],div[contenteditable="true"][role="textbox"]');
      for(var i=0;i<f.length;i++){
        if(isText(f[i]))setDir(f[i]);
        if(f[i].matches&&f[i].matches('[data-component="prompt-input"],div[contenteditable="true"][role="textbox"]'))attInp(f[i])
      }
    }
    document.querySelectorAll(SEL).forEach(setDir);
    attInp(document.querySelector('[data-component="prompt-input"],div[contenteditable="true"][role="textbox"]'));
    
    new MutationObserver(function(m){
      for(var i=0;i<m.length;i++)
        for(var j=0;j<m[i].addedNodes.length;j++)scan(m[i].addedNodes[j]);
    }).observe(document.getElementById('root')||document.body,{childList:true,subtree:true,characterData:true});

    Testing

    1. Open DevTools (F12 or Ctrl+Shift+I)
    2. Type allow pasting in the Console
    3. Paste the snippet above
    4. Verify:
      • Arabic text → right-aligned
      • English text → left-aligned
      • Lists → numbers/bullets on the right for Arabic
      • Code blocks → always LTR, left-aligned
      • Streaming responses → applied automatically
  4. razavioo commented on Jul 29, 2026

    @razavioo

    Community plugin available: opencode-rtl

    For those looking for RTL support, we've built an OpenCode plugin that automatically applies Unicode bidi isolation (RLI/LRI/PDI) to the AI's responses and system prompts.

    npm install opencode-rtl
    // opencode.json
    {
      "plugin": [
        ["opencode-rtl", { "language": "auto" }]
      ]
    }

    What it fixes today:

    • Injects RTL system prompts so the AI responds in your language
    • Protects inline code (console.log()) and markdown blocks from getting scrambled by wrapping them in LTR isolates
    • Works out-of-the-box for Arabic, Persian, Hebrew, Urdu, etc.
    • Fixes character ordering and mixed-direction (BiDi) text issues

    Current limitations:

    • Right-alignment: The plugin fixes the ordering of words and code (which fixes a lot of the unreadable output), but the text is still left-aligned. Full right-alignment requires native support in the renderer (like CSS dir="rtl" as discussed in this issue, or native alignment in the CLI TUI).
    • Streaming: It formats the text after the response completes. (We are proposing a streaming hook to fix this).

    Repo: https://github.com/razavioo/opencode-rtl

  5. razavioo commented on Sep 27, 2026

    @razavioo

    برای راستچین شدن کادر چت میتونید از پلاگین opencode-rtl استفاده کنید.

    // opencode.jsonc (OpenCode 2)
    {
      "plugins": [{ "package": "opencode-rtl", "options": { "language": "fa" } }]
    }
    // opencode.json (OpenCode 1)
    {
      "plugin": [["opencode-rtl", { "language": "fa" }]]
    }

    این پلاگین متنهای فارسی/عربی رو با کاراکترهای یونیکد bidi ایزوله میکنه تا ترمینال درست نمایش بده.

  6. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    Closing as a duplicate of #26915, which tracks RTL (right-to-left) support in the desktop chat. Please add your details and 👍 there.

    به‌عنوان تکراریِ #26915 بسته شد؛ لطفاً جزئیات و 👍 را آنجا اضافه کنید.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions