Skip to content

feat(tui): native bidi/RTL rendering for prompts and messages - #48589

Closed
muhamedbeshir wants to merge 3286 commits into
anomalyco:devfrom
muhamedbeshir:oc2-rtl-ar-fix
Closed

feat(tui): native bidi/RTL rendering for prompts and messages#48589
muhamedbeshir wants to merge 3286 commits into
anomalyco:devfrom
muhamedbeshir:oc2-rtl-ar-fix

Conversation

@muhamedbeshir

Copy link
Copy Markdown

Render Arabic, Persian, Urdu and Hebrew text correctly in the native TUI using UAX #9, without terminal-side bidi support or destructive text rewriting.

  • Add bidi-js based layout engine (direction detection via first strong char, LRI/PDI isolation for URLs/paths/numbers/code spans, grapheme- and width-aware wrapping, logical<->visual caret maps).
  • Add BidiTextareaRenderable for the prompt: visual caret placement and visual arrow-key motion while the edit buffer stays logical Unicode.
  • Add a markdown renderNode hook for assistant paragraphs/headings; fenced code, tables and diffs keep the stock LTR renderer.
  • Add BidiTextRenderable for user message echoes.
  • English-only content takes the stock render path unchanged; selection/copy return logical text.
  • Tests: engine unit tests, real test-renderer component tests, and an app-level e2e that types Arabic via real key presses and streams an assistant reply.

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Please provide a description of the issue, the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

thdxr and others added 30 commits September 6, 2026 11:08
Co-authored-by: Hona <10430890+Hona@users.noreply.github.com>
Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com>
Co-authored-by: Hona <10430890+Hona@users.noreply.github.com>
Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com>
…7738)

Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
opencode-agent Bot and others added 19 commits September 11, 2026 18:12
Co-authored-by: nexxeln <95541290+nexxeln@users.noreply.github.com>
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • No "Type of change" checkbox is checked. Please select at least one.
  • "How did you verify your code works?" section is empty. Please explain how you tested.
  • Not all checklist items are checked. Please confirm you have tested locally and have not included unrelated changes.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

Port of the UAX anomalyco#9 fix to the opencode2 (v2) codebase, which uses @opentui/core 0.5.10.

- bidi engine (bidi-js wrapper): first-strong paragraph direction, LRI/PDI isolation for URLs/paths/numbers/code spans, grapheme/width-aware wrapping, logical<->visual caret maps.
- BidiTextareaRenderable for the prompt; edit buffer stays logical.
- withBidiMarkdown composes with the existing plugins.markdown() renderNode for assistant paragraphs/headings; code/tables/diffs keep the stock LTR renderer.
- BidiTextRenderable for user message echoes.
- English-only content takes the stock render path; selection/copy stays logical.
- Tests: engine unit tests + real test-renderer component tests (31 passing).
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 12, 2026
@github-actions github-actions Bot closed this Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.