Bidirectional (RTL/LTR) text handling broken for mixed Arabic+English/German content — cursor position and direction both affected
Environment: Open WebUI v0.11.4, self-hosted via container, Chat Direction setting tested in all three modes (Auto / LTR / RTL), both with "Rich Text Input for Chat" enabled and disabled.
Description: When writing messages that mix Arabic with Latin-script text (English/German), text direction and cursor behavior are inconsistent and frequently wrong, regardless of the "Chat Direction" setting:
- Auto mode: messages starting with Arabic sometimes still render left-aligned/LTR instead of RTL. Direction detection appears unreliable for mixed-language content specifically — Arabic and foreign-language runs within the same message end up on the wrong side of each other.
- RTL mode (forced): overall direction is correct, but caret/cursor positioning while typing is broken — the cursor does not land after the just-typed character; deleting requires manually selecting text before a word to backspace from after it.
- With "Rich Text Input for Chat" disabled (plain textarea): cursor behavior becomes reversed/backwards instead of improving.
- With "Rich Text Input for Chat" enabled + Chat Direction = Auto: cursor positioning itself is correct, but the left/right side assignment for Arabic vs. the foreign-language text is swapped/wrong.
Root cause appears to be that dir is applied once per entire message container (ResponseMessage.svelte / UserMessage.svelte, via dir={$settings.chatDirection}) rather than per-paragraph, and the underlying contenteditable-based rich text editor's bidi caret handling doesn't match native browser textarea behavior. I tested adding unicode-bidi: plaintext via custom.css to message/input containers as a workaround — it had no effect, suggesting the issue is deeper than CSS (likely in the editor's internal selection/caret model).
Expected: Mixed Arabic + Latin-script messages should render similarly to ChatGPT's behavior — each paragraph/line resolving its own direction independently, with a stable, correctly-positioned caret while typing regardless of language mixing.
Additional context: Similar bidi-caret bugs have been reported in several other chat/editor projects (including Anthropic's own Claude Code), suggesting this is a broader class of bug in contenteditable-based rich text editors handling bidi content, not necessarily unique to this codebase — but worth tracking here specifically for the chat input/message rendering components.
Source: open-webui/open-webui