Skip to content

fix: render both initials for multi-word names in RAGFlowAvatar - #17320

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
tryeverything24:fix-avatar-initials
Aug 20, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
tryeverything24:fix-avatar-initials

Conversation

@tryeverything24

Copy link
Copy Markdown
Contributor

Summary

RAGFlowAvatar renders a name-based fallback avatar (initials) when no image is
available. The getInitials helper was meant to produce a single initial for
one-word names and two initials (first + last word) for multi-word names, but a
copy-paste slip made both branches identical:

if (parts.length === 1) {
  return parts[0][0].toUpperCase();
}
return parts[0][0].toUpperCase(); // same as the single-word branch

As a result the parts.length === 1 check is dead code and every name — including
multi-word names like "John Doe" — renders just the first letter ("J" instead of
"JD"). The surrounding SVG already sizes its viewBox on initials.length - 1,
so it was written to accommodate multi-character initials; the layout branch was
simply never reachable.

This PR makes the multi-word branch return the first and last word initials, which
is the intended (and standard) avatar behavior:

return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();

One-word names are unchanged. name is already guarded as a non-empty string and
trim().split(/\s+/) yields non-empty word segments, so the new access is safe.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ce7306a-605c-46a3-9271-3331bdc38238

📥 Commits

Reviewing files that changed from the base of the PR and between ac675c6 and d237a0a.

📒 Files selected for processing (1)
  • web/src/components/ragflow-avatar.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/components/ragflow-avatar.tsx

📝 Walkthrough

Walkthrough

The avatar initials generator now uses the first and last characters of a single-word name, uppercased, instead of only the first character.

Changes

Avatar initials

Layer / File(s) Summary
Single-word initials
web/src/components/ragflow-avatar.tsx
getInitials now returns two-character initials for single-part names.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Poem

I’m a rabbit with initials bright,
Two little letters, neat and light.
First and last now hop in line,
Uppercased and crisp—they shine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the initials-rendering fix in RAGFlowAvatar and matches the PR's main intent.
Description check ✅ Passed The description includes the required Summary section and adds helpful context plus change type details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN
JinHai-CN requested a review from cike8899 August 20, 2026 10:09
@cike8899 cike8899 added the ci Continue Integration label Aug 20, 2026
@JinHai-CN
JinHai-CN merged commit 181db39 into infiniflow:main Aug 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants