Skip to content

Avatars show two initials for a one-word user name, as the other UVCS clients do - #166

Merged
danipen merged 6 commits into
mainfrom
fix/avatar-initials
Oct 29, 2026
Merged

danipen merged 6 commits into
mainfrom
fix/avatar-initials

Conversation

@danipen

@danipen danipen commented Oct 29, 2026

Copy link
Copy Markdown
Member

What does this pull request do?

An avatar shown as initials now shows two letters for a one-word user name (jdoe → JD), as the other UVCS clients show it. This applies to the Branch Explorer and every list or panel with an avatar.

Current behavior

The initials were the first letters of the first two words of the name (split on ., _ and - before the @). A one-word name such as jdoe@example.com gave a single letter ("J"). People used to the other clients, which show the first two letters, read that as a change. The rule has been the same since the app's first version, so this isn't a regression.

Behavior with this pull request

  • Names with two or more words don't change: jane.doe → JD.
  • A one-word name shows its first two letters: jdoe → JD, builder → BU.
  • A one-letter name shows that letter, and an empty one shows "?".

How it was implemented

initials (src/renderer/src/lib/userName.ts) is the one place both the Branch Explorer canvas (drawAvatar) and ui/Avatar take initials from, so the fix lives there:

  • It splits the display name into words. With two or more words it takes the first letter of each of the first two; with one word, its first two letters.
  • Letters are counted by code point (Array.from), so a letter outside the BMP isn't split in half.
  • The name is normalized to NFC first, so a letter written with a separate accent mark counts as one letter.
  • Runs of spaces count as one separator.

No cm commands change.

Behavior changes

None beyond the goal.

Checklist

  • npm run typecheck and npm test pass. The new tests cover two-word names (., -, _), one-word names, a one-letter name, an empty name, letters beyond ASCII and outside the BMP, an accent written as a separate mark, and names with extra spaces.

  • Seen working in the app: the Changesets list, the details panel and the Branch Explorer, in production and development builds, with no renderer errors. The change affects only which letters are drawn, not their color or size, and two-letter initials already showed for every two-word name. No screenshot: the change is two letters in a circle.

  • npm run e2e: not needed, since this doesn't touch startup or navigation.

  • Other areas the change reaches: initials has two callers, ui/Avatar and drawAvatar, and both only render the string.

  • Reviewed in a clean context. It found:

    • no test pinned the code-point handling (tests added);
    • names with extra spaces still gave one letter (fixed and tested);
    • a decomposed accent counted as a letter (NFC added and tested);
    • not to call this a regression (it isn't one).

    Declined for now:

    • merging serverInitials with initials: the inputs differ (a host and a user), so that belongs in its own change;
    • reading DOMAIN\user owners: they gave one letter before as well, and it isn't clear cm reports them.
  • docs/ARCHITECTURE.md "Profile pictures (Gravatar)" names the rule.

Fixed issues

None.

🤖 Generated with Claude Code

danipen and others added 6 commits October 29, 2026 15:20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… clients do

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…extra spaces

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ames with extra spaces

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@danipen
danipen enabled auto-merge October 29, 2026 14:38
@danipen
danipen added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 0c4da68 Oct 29, 2026
9 checks passed
@danipen
danipen deleted the fix/avatar-initials branch October 29, 2026 14:48
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.

1 participant