Repository navigation
fix(avatar): preserve grapheme clusters when generating initials - #4750
Merged
cixzhang merged 7 commits intoAug 6, 2026
Merged
Conversation
getInitials() uses String.charAt(0), which indexes by UTF-16 code unit rather than codepoint. Names starting with a character outside the Basic Multilingual Plane (e.g. emoji) get split mid-surrogate-pair, rendering as a replacement character instead of the initial. This test documents the failure; the fix follows in a subsequent commit. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
alex-js-ltd
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
August 6, 2026 10:40
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsAvatar (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
approved these changes
Aug 6, 2026
cixzhang
left a comment
Contributor
There was a problem hiding this comment.
Thank you for improving the i18n here!
cixzhang
enabled auto-merge (squash)
August 6, 2026 16:11
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
The approval event is one-shot: if review-clear's run dies, the gate stays pending forever and only a human noticing recovers it. During the 2026-08-06 GitHub Actions incident the workflow failed in 'Set up job' (Failed to resolve action download info: Service Unavailable) before any script ran, and #4750 sat blocked on an approval it already had. Add a 15-minute clear-only sweep to review-clear.yml, sharing the exact same clearOne() as the event path so recovery can never drift from the live path. It considers an open PR unresolved when the needs:code-review label is present OR the review-required status is pending, and clears only when an entitled ENGOWNER has approved -- it can remove a gate an approval already satisfied, never create one, so it is safe unattended. Also add workflow_dispatch for an immediate sweep, and document that a human cannot hand-clear this gate: branch protection requires the review-required context from the GitHub Actions app, so a status posted with a personal token greens the rollup without satisfying the requirement.
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
The approval event is one-shot: if review-clear's run dies, the gate stays pending forever and only a human noticing recovers it. During the 2026-08-06 GitHub Actions incident the workflow failed in 'Set up job' (Failed to resolve action download info: Service Unavailable) before any script ran, and #4750 sat blocked on an approval it already had. Add a 15-minute clear-only sweep to review-clear.yml, sharing the exact same clearOne() as the event path so recovery can never drift from the live path. It considers an open PR unresolved when the needs:code-review label is present OR the review-required status is pending, and clears only when an entitled ENGOWNER has approved -- it can remove a gate an approval already satisfied, never create one, so it is safe unattended. Also add workflow_dispatch for an immediate sweep, and document that a human cannot hand-clear this gate: branch protection requires the review-required context from the GitHub Actions app, so a status posted with a personal token greens the rollup without satisfying the requirement.
cixzhang
added a commit
that referenced
this pull request
Aug 12, 2026
The approval event is one-shot: if review-clear's run dies, the gate stays pending forever and only a human noticing recovers it. During the 2026-08-06 GitHub Actions incident the workflow failed in 'Set up job' (Failed to resolve action download info: Service Unavailable) before any script ran, and #4750 sat blocked on an approval it already had. Add a 15-minute clear-only sweep to review-clear.yml, sharing the exact same clearOne() as the event path so recovery can never drift from the live path. It considers an open PR unresolved when the needs:code-review label is present OR the review-required status is pending, and clears only when an entitled ENGOWNER has approved -- it can remove a gate an approval already satisfied, never create one, so it is safe unattended. Also add workflow_dispatch for an immediate sweep, and document that a human cannot hand-clear this gate: branch protection requires the review-required context from the GitHub Actions app, so a status posted with a personal token greens the rollup without satisfying the requirement.
cixzhang
added a commit
that referenced
this pull request
Aug 16, 2026
* fix(core): count strings by graphemes, not code units Several user-visible string operations indexed by UTF-16 code units, miscounting or corrupting emoji, flags, ZWJ sequences, and combining marks: - TextArea's character counter (display, over-limit state, aria-invalid, warning icon, and live-region announcements) showed an emoji as 2+ characters. All limit math now counts user-perceived characters, and is skipped entirely when no maxLength is set. - PowerSearch's two truncation helpers could split a surrogate pair or drop a combining mark at the cut point. Both now cut on grapheme boundaries with their exact previous thresholds and ellipses. - Table's auto-generated column headers failed to capitalize astral-plane letters (charAt(0) grabbed half a surrogate pair). Adds shared utils/grapheme.ts (graphemeLength, firstGrapheme, truncateGraphemes) built on a reused Intl.Segmenter with a code-point fallback — extracted from Avatar's merged #4750 fix, which now consumes the shared util. For pure-ASCII input every refactored site is byte-identical to the previous behavior at all reachable parameters. Fixes #4759 * perf(core): take the first grapheme without segmenting the whole string Also memoize TextArea's counter length, harden the combining-mark test fixture against NFC normalization, and point maxLength consumers at graphemeLength for validation parity. Streaming reveal follow-up filed as #4779. * refactor(core): name the character utilities in plain English Review feedback on the new public API: `grapheme` is Unicode jargon and reads as too technical for consumers. graphemeLength -> characterCount firstGrapheme -> firstCharacter truncateGraphemes -> truncateCharacters Renames the file, the internal helpers and the doc prose to match, so the word only survives where it is the literal `Intl.Segmenter` granularity value. No behavior change: every function body is unchanged apart from the identifiers. --------- Co-authored-by: Cindy Zhang <[email protected]>
4 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4749
getInitials()used.charAt(0), which indexes UTF-16 code units rather than user-perceived grapheme clusters. As a result, names beginning with multi-code-unit characters—such as emoji, flag or ZWJ sequences, and decomposed letters with combining marks—could produce broken or truncated initials.Changes
getInitials()to extract the first grapheme usingIntl.Segmenterwithgranularity: 'grapheme'.Intl.Segmenteris unavailable. The fallback prevents surrogate pairs from being split, although full multi-code-point grapheme preservation requiresIntl.Segmenter.Test plan
pnpm -F @astryxdesign/core test— Avatar suite passes (45/45), including the two new tests. Both fail against the previous.charAt(0)implementation and pass with this fix.pnpm check:changesets