Skip to content

fix: avatar initials - #66517

Open
kristian-zendato wants to merge 2 commits into
masterfrom
fix/name-initials
Open

kristian-zendato wants to merge 2 commits into
masterfrom
fix/name-initials

Conversation

@kristian-zendato

@kristian-zendato kristian-zendato commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Have the avatar initials case-sensitive
  • Choose right font to display different language for the initials

Screenshots

Before After
image image
image image

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@kristian-zendato
kristian-zendato requested a review from a team as a code owner November 11, 2026 10:01
@kristian-zendato
kristian-zendato requested review from Altahrim and icewind1991 and removed request for a team November 11, 2026 10:01
@kristian-zendato kristian-zendato changed the title Fix/name initials fix: avatar name initials Nov 11, 2026
@kristian-zendato kristian-zendato added 3. to review Waiting for reviews bug feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.) labels Nov 13, 2026
@4jNsY6fCVqZv

4jNsY6fCVqZv commented Nov 13, 2026 •

Copy link
Copy Markdown

@kristian-zendato Thank you so much for working on this!

Could you imagine looking into the display name/greeting part of #46878 as well?

For example, by ensuring that the display name is used in the greeting, as long as the user (or admin) has explicitly set it – regardless of whether it is in upper or lower case or is identical to the user ID.

For us, this currently means that our accounts are losing their personalised welcoming touch, as the user ID and the display name set in the profile are the same.

Signed-off-by: kristian-zendato <kristian.zendato@nextcloud.com>
Signed-off-by: kristian-zendato <kristian.zendato@nextcloud.com>
@kristian-zendato
kristian-zendato requested review from marcoambrosini, pringelmann and skjnldsv and removed request for a team November 16, 2026 14:47
@kristian-zendato

kristian-zendato commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@4jNsY6fCVqZv I updated the code for your comment.

Here is what I did for it.

  • Add a new field displayLabel to have the explicitly set display name(not fallback from user id when empty).
  • Add a new user configuration field to check if the display name is explicitly set or not.
  • Update logic of showing and updating display name(e.g. on Admin accounts, profile page)

@4jNsY6fCVqZv

Copy link
Copy Markdown

@kristian-zendato

That sounds wonderful! Thank you so much!

Does it matter, if the display name was set deliberately by the user in their profile, or by an admin when the account was created?

Would you mind updating the title of the PR so that it reflects both aspects?

And could you even imagine a backport to version 34/35?

@kristian-zendato kristian-zendato changed the title fix: avatar name initials fix: profile display name for greeting and avatar initials Nov 17, 2026
@kristian-zendato

Copy link
Copy Markdown
Contributor Author

@kristian-zendato

That sounds wonderful! Thank you so much!

Does it matter, if the display name was set deliberately by the user in their profile, or by an admin when the account was created?

Would you mind updating the title of the PR so that it reflects both aspects?

And could you even imagine a backport to version 34/35?

@4jNsY6fCVqZv Here are the scenarios when displayName is set explicitly.

  1. When user update their Display Name on their profile
  2. When admin set display name on Accounts page; either when account is created and edited.

Backport will be done once the PR is approved.

Comment on lines +119 to +126
if (preg_match('/\p{Hangul}/u', $character) === 1) {
return __DIR__ . '/../../../core/fonts/NotoSansKR-Regular.ttf';
}
if (preg_match('/[\p{Hiragana}\p{Katakana}]/u', $character) === 1) {
return __DIR__ . '/../../../core/fonts/NotoSansJP-Regular.ttf';
}
if (preg_match('/\p{Han}/u', $character) === 1) {
return __DIR__ . '/../../../core/fonts/NotoSansJP-Regular.ttf';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not do the preg_match directly on the whole username? Why loop on each character?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let's imagine a scenario for a username with different language.
Of course, it is rare case, but when a Japanese live in Germany can set their username in both Japanese and German.
In that case, we need to select proper font for each character.

@come-nc come-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This whole display label thing is overengineered.
Why is the display name logic not working? We should not add a second field for the same thing.

@come-nc

come-nc commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Regarding uppercase vs lowercase I would need a review from design as this change would be a design decision @marcoambrosini

@pringelmann pringelmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree with @come-nc on overengineering. The column already knows if we have a name: it's NULL until something is set. It only stops knowing because clearing it writes the uid into it. If clearing stored an empty value instead, the column is the single source of truth and we only need a small way to read it, not a second config key. Maybe this could solve the problem more simply?

Also, please split the avatar changes out into separate PR? The casing change still needs a design decision, and imo it shouldn't block or ride along with a backport of the greeting fix.

@kristian-zendato

Copy link
Copy Markdown
Contributor Author

I totally agree with that adding second config key is not a good solution for this.
But updating displayName column can cause a lot of side effect from many components from server and other apps.

Here are some examples of them.

To reduce this side-effects, I introduced a new variable called displayLabel to use for greeting messages and displayName update.

Could you suggest me any better idea for the side-effects please?
cc @pringelmann , @come-nc , @susnux

@pringelmann

Copy link
Copy Markdown
Contributor

I totally agree with that adding second config key is not a good solution for this. But updating displayName column can cause a lot of side effect from many components from server and other apps.

Here are some examples of them.

* If we return empty string for cleared displayName, all `??` operators should be replace by '||'
  https://github.com/nextcloud/server/blob/185277024c91315478c0422af9b031ae5e3c8d69/core/src/views/AccountMenu.vue#L88

* If we return null for cleared displayName, need to update code on `circles` app too.
  https://github.com/nextcloud/circles/blob/609d5198bbee33601cbdecffc012bb94c62f1bfd/lib/Service/FederatedUserService.php#L452

To reduce this side-effects, I introduced a new variable called displayLabel to use for greeting messages and displayName update.

Could you suggest me any better idea for the side-effects please? cc @pringelmann , @come-nc , @susnux

Sorry maybe my suggestion was too imprecise: getDisplayName() itself wouldn't need to change. It already falls back to the uid when the column is empty, and every account created without a name already has NULL there today. Clearing would simply restore that state. setDisplayName() has to allow '' for that, and the change event should still carry the uid, not an empty string. But apart from that I don't see any major side effects.

The open question is still how the dashboard learns no name was set. I'd keep that small and non-public instead of a new IUser method plus a config key.

@kristian-zendato

Copy link
Copy Markdown
Contributor Author

Split explicit displayName part to #66796

@kristian-zendato kristian-zendato changed the title fix: profile display name for greeting and avatar initials fix: avatar initials Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dashboard] Greetings and avatar initials should respect consciously chosen display names

4 participants