Skip to content

fix(chat): handle mixed RTL/LTR prompt text#462

Open
Sushanth012 wants to merge 1 commit into
fathah:mainfrom
Sushanth012:fix/rtl-prompt-direction
Open

fix(chat): handle mixed RTL/LTR prompt text#462
Sushanth012 wants to merge 1 commit into
fathah:mainfrom
Sushanth012:fix/rtl-prompt-direction

Conversation

@Sushanth012

Copy link
Copy Markdown

Summary

  • set the chat prompt textarea and message bubbles to auto-detect text direction
  • apply unicode-bidi: plaintext so mixed RTL/LTR paragraphs render in reading order
  • keep code blocks isolated as LTR inside assistant markdown
  • add renderer tests for the direction attributes

Fixes #452.

Verification

  • npm run typecheck
  • npm run lint (0 errors; existing CRLF prettier warnings in the repo)
  • npx vitest run src/renderer/src/screens/Chat/ChatInput.test.tsx (blocked locally by Node 18/Vitest ESM config error: ERR_REQUIRE_ESM)

@pmos69

pmos69 commented May 31, 2026

Copy link
Copy Markdown
Collaborator

This looks like the right approach to me. dir="auto" is preferable to forcing rtl, since English-only prompts/messages should remain LTR while Arabic-first mixed text gets RTL layout.

Two small verification notes before merge:

  1. The added test checks the dir="auto" attributes, but the core behavior is CSS/browser bidi rendering. Could you add a quick manual verification note or screenshot with:

    • Arabic + English + numbers/parentheses in the textarea
    • the same text rendered in a user chat bubble
    • an assistant response containing a code block, confirming code remains LTR
  2. The PR body says the focused Vitest run was blocked locally by Node 18 / ESM config. Could you rerun with the repo-supported Node version or confirm CI covers the new test?

No objection to the actual fix shape.

@pmos69

pmos69 commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

This still looks like the right fix direction, and it is not superseded by current main.

Current main still lacks the dir="auto"/bidi handling for mixed RTL/LTR chat text. The PR is stale now, though, and conflicts in:

  • src/renderer/src/screens/Chat/ChatInput.test.tsx
  • src/renderer/src/screens/Chat/MessageRow.tsx

The rebase should be straightforward:

  • keep the current IME tests in ChatInput.test.tsx and add the bidi assertions alongside them
  • in MessageRow.tsx, keep the current grouped/error class logic and add dir="auto" to the real .chat-bubble div

The CSS and textarea change apply cleanly. After rebasing, the earlier manual verification request still applies: please check an Arabic/English/numbers mixed prompt in the textarea, the same text in a user bubble, and an assistant response with a code block to confirm code remains LTR.

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.

[Bug] RTL/LTR mixed text direction rendered incorrectly in prompt/text input

2 participants