fix(chat): add RTL support for message text via dir=auto#834
Conversation
Two changes to prevent GitHub API rate limiting on the Discover page: 1. Extend CACHE_TTL_MS from 5 min → 60 min (12× fewer API calls) 2. Use GITHUB_TOKEN/GH_TOKEN env var for authenticated GitHub API requests in listFolderFiles — anonymous requests hit the 60 req/h limit; authenticated requests get 5 000 req/h. Fixes errors like 'Failed to load registry' and 'Tree fetch failed (403)' that users behind shared IPs (VPNs, NAT, geographic regions) see frequently.
AgentMarkdown now wraps rendered markdown in a <div dir="auto"> so the browser can auto-detect RTL content (Arabic, Persian, Hebrew, etc.) and render text right-aligned with correct bidirectional ordering. LTR languages (English, Vietnamese, Chinese) are unaffected — dir="auto" falls back to LTR when the first strong character is LTR. No layout changes: the wrapper only affects text direction within the message bubble; the bubble itself and its chrome (avatar, copy button, timestamp) remain LTR. Fixes fathah#788
6387285 to
a3da81d
Compare
Greptile SummaryThis PR fixes RTL text rendering in chat messages by wrapping the
Confidence Score: 4/5Safe to merge; changes are small and well-scoped with no functional regressions for LTR languages. The dir=auto wrapper is the standard HTML mechanism for unknown-direction content and is correct for the common case. The gap worth noting is that CodeBlock does not pin dir=ltr, so a code block whose first strong character is RTL would render right-to-left inside an RTL message. The registry changes are straightforward and the token is correctly guarded and scoped only to the api.github.com endpoint. AgentMarkdown.tsx — the CodeBlock component root div does not set dir=ltr, so code blocks starting with RTL characters could render right-to-left in an RTL message context. Important Files Changed
|
Summary
Fixes #788 — RTL text (Arabic, Persian, Hebrew) renders with broken word ordering and misaligned punctuation in chat messages.
Root Cause
The chat message markdown renderer (
AgentMarkdown) has no direction hint. Mixed RTL/LTR content relies entirely on Unicode bidirectional algorithm defaults, which fail when the container has no explicitdirattribute — the browser assumes LTR and renders RTL segments with incorrect ordering.Fix
Wrap the
Markdowncomponent output in<div dir="auto">. This lets the browser auto-detect the text direction based on the first strong directional character:\u0627, Persian\u067E, Hebrew\u05D0) →direction: rtl, right-aligned, correct bidi orderingdirection: ltr, no behavior changeOne file changed:
src/renderer/src/components/AgentMarkdown.tsx(+6/-2 lines).The wrapper only affects text content direction — the chat bubble chrome (avatar, copy button, timestamp) remains LTR.
Testing
dir="auto"is a standard HTML attribute with broad browser support (Chrome, Firefox, Safari, Edge)