Skip to content

Rendering Bug: RTL Line Wrapping overlaps with Context numbers #55913

Open

Description

@7azmi

Description

Longer RTL text, Arabic in my case, seem to overlap and flip the important numbers of Context

It's a tiny annoying problem, not affecting me much as a dev but I'm confident there are some users prompting fully in Arabic. I'll give it a try and submit.

Not sure if it is just on my machine. You can clearly see the rendering problem in the gif below.

Plugins

None

OpenCode version

2.0.26

Steps to reproduce

  1. Prompt something like Generate a long story sample in Arabic in paragraph form, 7-8 paragraphs, each paragraph as one block with very long sentences and no manual line breaks. Plain Arabic text only, for testing RTL wrapping while scrolling.
  2. Scroll down/up

Screenshot and/or share link

Image

Operating System

Linux Mint 22.3 x86_64

Terminal

gnome-terminal

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for the report and the GIF. I reproduced this on 2.0.26 in gnome-terminal (running under a virtual X display), using the free model and a long single-paragraph Arabic prompt, then scrolling up and down. On rows where the wrapped Arabic shares a line with the sidebar, sidebar text (the Context token count 6,369, the 1 from 1% used, the end of the session title) jumps to the left edge of the transcript. The Arabic also runs past the transcript into the sidebar. The recording and screenshots below show it, and the script below reproduces it.

    It still happens on the latest dev (e25b7ab), where the long Arabic message alone was enough to trigger it.

    Our guess, not yet confirmed: gnome-terminal (VTE) reorders each whole terminal row for right-to-left text, while OpenCode places every cell itself. So a row with Arabic plus sidebar text gets reordered as a unit. Terminals that don't reorder right-to-left text themselves shouldn't show this. Related, broader RTL issues: #39525 (aligning RTL text to the right in the TUI) and #16875 / #47982 (Arabic letters shown reversed or disconnected).

    recording.mp4

    Screenshot

    Screenshot

    Screenshot

    Reproduction script (run-vte.sh)
    #!/bin/bash
    # Reproduce anomalyco/opencode#55913 in a real gnome-terminal (VTE, which applies its own BiDi).
    # Needs: gnome-terminal xvfb dbus-x11 xdotool imagemagick ffmpeg fonts-noto-core, and `opencode` on PATH
    # (or set OPENCODE_CMD). Uses the built-in free model. Records the screen to $OUT.mp4 and
    # saves screenshots $OUT-*.png.
    set -e
    OUT=${OUT:-/workspace/repro/vte}
    OPENCODE_CMD=${OPENCODE_CMD:-$(command -v opencode)}
    export DISPLAY=:99
    rm -f /tmp/.X99-lock
    Xvfb :99 -screen 0 1900x600x24 >/dev/null 2>&1 &
    sleep 2
    eval "$(dbus-launch --sh-syntax)"
    ffmpeg -loglevel error -y -f x11grab -framerate 10 -video_size 1900x600 -i :99 -pix_fmt yuv420p "$OUT.mp4" &
    FF=$!
    P="كان يا ما كان في قديم الزمان مدينة صغيرة تقع على ضفاف نهر عظيم تتدفق مياهه الصافية بين الحقول الخضراء الواسعة والبساتين المثمرة التي تمتد على مد البصر حيث كان الناس يعيشون في سلام ووئام ويتبادلون التحيات كل صباح ويجتمعون في المساء حول النار ليرووا الحكايات القديمة عن أجدادهم الذين بنوا هذه المدينة بأيديهم وصبرهم وعزيمتهم التي لا تلين أبدا مهما اشتدت الصعاب وتكاثرت التحديات من حولهم في كل مكان وزمان"
    PROMPT="$P $P $P $P $P $P"
    mkdir -p /tmp/rtl-proj && cd /tmp/rtl-proj && (git init -q 2>/dev/null || true)
    gnome-terminal --geometry=200x30 -- bash -c "$OPENCODE_CMD --standalone --prompt \"$PROMPT\"; sleep 600" &
    sleep ${WAIT:-40}
    import -window root "$OUT-1-after-response.png"
    xdotool mousemove 700 300
    for i in $(seq 1 15); do xdotool click 4; sleep 0.3; done
    sleep 1; import -window root "$OUT-2-scrolled-up.png"
    for i in $(seq 1 8); do xdotool click 5; sleep 0.3; done
    sleep 1; import -window root "$OUT-3-scrolled-down.png"
    for i in $(seq 1 4); do xdotool click 4; sleep 0.3; done
    sleep 1; import -window root "$OUT-4-scrolled-up-again.png"
    sleep 2
    kill -INT $FF; wait $FF || true

    Run it: bash run-vte.sh

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions