Skip to content

fix(chat): right-align Arabic assistant replies with logical text-align - #2639

Merged
vastsa merged 3 commits into
vastsa:mainfrom
koeria:fix/2635-arabic-reply-alignment
Nov 28, 2026
Merged

vastsa merged 3 commits into
vastsa:mainfrom
koeria:fix/2635-arabic-reply-alignment

Conversation

@koeria

@koeria koeria commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#2389 already set each Markdown block's dir from the majority strong script, and used text-align: start on user message paragraphs. Assistant replies go through Markdown, which set dir only. When a physical text-align: left is inherited (or used as a platform default), an Arabic-only reply stays left-aligned even with dir="rtl".

This applies the same logical alignment to Markdown paragraphs, lists, headings, and blockquotes, and gives headings and quotes the same majority-script dir. List padding uses padding-inline-start so RTL lists indent from the right. List containers also receive that dir so the gutter follows the list rather than the surrounding paragraph. The hast node prop is no longer spread onto the DOM.

This is the verified inherited-alignment fix: the Chromium probe confirms glyph placement and RTL/LTR list gutters under an explicit text-align: left ancestor. The probe applies that ancestor itself, so it does not show that the reported Windows chat path in #2635 inherits that alignment in production. Refs #2635 — leave the issue open until that path is confirmed.

The MessageBubble assistant contract and E2E-060d now describe this alignment and list-gutter behavior.

Test plan

  • node --test test/markdown-bidi-alignment.test.mjs test/markdown-*.test.mjs test/text-direction.test.mjs (40 passed)
  • Desktop tsc --noEmit and style-token check passed
  • scripts/e2e-bidi.mjs Chromium probe: inherited text-align: left glyph placement and RTL/LTR list gutters
  • docs/spec/04-ux/08-component-spec.md §8.3 and docs/spec/06-delivery/e2e/ui-shell.md E2E-060d

Refs #2635

Markdown blocks already set dir from majority script (vastsa#2388), but only
user bubbles used text-align: start. A physical text-align: left inherited
from an ancestor or a platform default kept Arabic-only replies
left-aligned even when dir=rtl was set.

Apply the same logical alignment to Markdown paragraphs, lists, headings,
and blockquotes, and give headings and quotes the same majority-script
dir. List padding uses padding-inline-start so RTL lists indent from the
right.

Fixes vastsa#2635

@aiuo-codepilot aiuo-codepilot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIUO CodePilot · Preliminary review

Diff-only preliminary review of PR #2639. The change extends majority-script `dir` and logical `text-align: start` to Markdown paragraphs, list items, headings, and blockquotes, switches list padding to logical properties, and stops spreading hast `node` onto the DOM. No concrete added-line defect is evidenced from the patch alone. Verify on a renderer build that nested Markdown blocks retain intended alignment and that `getComputedStyle().textAlign` exposes the expected value across supported engines.

No evidenced findings in the supplied diff.

Head: cd93b21
Base: 6214e55
CI: success; mergeable: true.

Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran all 40 focused Markdown/direction tests on the integration candidate 4f6638a2e (base 6214e5583, head cd93b21a1). In a separate Chromium probe using the production Markdown renderer and prose stylesheet, an Arabic-only paragraph aligned right on both revisions by default. With an ancestor explicitly set to text-align: left, the old paragraph aligned left and the candidate aligned right. That confirms the inheritance fix, but does not independently reproduce the reported Windows path.

The proposed RTL list indentation is still incomplete. In a pure Arabic two-item list under the usual LTR prose container, the candidate <li> computes direction: rtl, but <ul> still computes direction: ltr with padding-left: 22.4px and padding-right: 0px (same as main). The logical padding is on the container, so changing only the item direction leaves the list gutter on the opposite side from RTL list content. The current direction/alignment assertions do not exercise that geometry.

Please either keep the patch focused on paragraph alignment and leave list indentation out, or set the direction on the list container where appropriate and add a browser geometry assertion for pure RTL and ordinary LTR lists. Please also make the paragraph regression exercise the actual inherited alignment (or document what reproduces the Windows case), and verify glyph placement rather than accepting computed start alone.

Place dir on ul/ol from the list's majority script so
padding-inline-start sits on the same side as RTL items.
The bidi probe now asserts list padding geometry and that an
Arabic paragraph stays visually right-aligned when an ancestor
uses physical text-align:left.

Fixes vastsa#2635

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the follow-up on GitHub’s integration candidate abf4e6345 (base 6214e5583, head 210cb0523): 40 Markdown/direction tests, the PR base check, a renderer build, and the Chromium bidi probe passed on macOS. Glyph placement under an explicitly left-aligned ancestor and both RTL/LTR list gutters are now covered; the earlier gutter finding is resolved. The architecture check passed with an oversized-file growth warning. The full local desktop build did not complete because the provisioned agent-runtime dependency could not resolve @earendil-works/pi-ai/utils/hosted-search.

What remains is the scope of Fixes #2635: the probe applies text-align: left itself, so it does not show that the reported Windows chat path gets that inherited alignment in production. Please provide a before/after run of that Windows path, or describe this as the verified inherited-alignment fix and leave #2635 open until that path is confirmed. Please also update the relevant renderer spec / E2E scenario for the assistant alignment and list-gutter behavior.

Describe the MessageBubble assistant contract as physical row placement
plus text-align:start under a majority-script dir. Add E2E-060d for
that alignment and list-gutter behavior. This PR is the verified
inherited-alignment fix; leave vastsa#2635 open until the reported Windows
chat path is confirmed.

Refs vastsa#2635

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified aa3797cd8 on GitHub integration candidate eaee496a1 (base 6214e5583). All 40 focused tests passed, as did the PR-base check and the Chromium probe (RTL glyph placement under an explicitly left-aligned ancestor and RTL/LTR list gutters). The renderer build and probe used the candidate shared source because the provisioned shared dist is stale; the full local build remains blocked by hosted-search dependency resolution. All six GitHub checks on this revision passed. The spec and scenario now describe the narrower behavior, and #2635 stays open for the unverified Windows path.

@vastsa
vastsa merged commit 223e005 into vastsa:main Nov 28, 2026
6 checks passed
zergfff added a commit to zergfff/PI-Desktop-fork that referenced this pull request Nov 30, 2026
Ported from vastsa/PI-Desktop v0.24.0-beta.7 (bug fixes only; the release's
features were left for a later rebase):

vastsa#2625 quarantine rejected outbox appends instead of retrying them forever
vastsa#2574 settle live turns and tool rows when the sidecar dies mid-stream
vastsa#2578 native Pi turns stay stoppable after a reload
vastsa#2634 the task badge mirrors work that is still running
vastsa#2639 let Arabic and Hebrew paragraphs choose their own side
vastsa#2640 stop a renderer crash loop with one GPU-less relaunch, then a dialog
vastsa#2642 reject differing spellings of one tool argument
vastsa#2655 compaction summaries open on demand in the transcript
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.

2 participants