-
Notifications
You must be signed in to change notification settings - Fork 63
fix(ui): show avatar initials for single-segment usernames; tooltip truncated chart names #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eliran-ops
wants to merge
3
commits into
main
Choose a base branch
from
feat/fix-cosmetic-batch-avatar-stop-claude-truncation-tooltips
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
84a3039
fix(ui): show avatar initials for single-segment usernames; tooltip t…
eliran-mic 75a43ae
fix(ui): make Tooltip wrapperClassName actually win over default display
eliran-mic 0ab023e
fix(user-initials): drop non-letters; honour single-segment fallback
eliran-mic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { describe, it, expect } from 'vitest' | ||
| import { computeUserInitials } from './user-initials' | ||
|
|
||
| // Pinning the SKY-825 bug 41 contract: the previous implementation | ||
| // only looked at separator-split segments, so any username without a | ||
| // '.', '_', or '-' (e.g. "mkohli", "alice") produced empty initials | ||
| // and the UserMenu fell back to a generic silhouette icon. The new | ||
| // helper guarantees a non-empty, uppercase 1-2-letter label whenever | ||
| // there's a usable username. | ||
|
|
||
| describe('computeUserInitials', () => { | ||
| it('uses segment initials when separators are present', () => { | ||
| expect(computeUserInitials('mary.kohli')).toBe('MK') | ||
| expect(computeUserInitials('mary_kohli')).toBe('MK') | ||
| expect(computeUserInitials('mary-kohli')).toBe('MK') | ||
| }) | ||
|
|
||
| it('caps segment initials at 2 even with many separators', () => { | ||
| expect(computeUserInitials('a.b.c.d')).toBe('AB') | ||
| }) | ||
|
|
||
| it('falls back to leading letters when no separators (the SKY-825 bug 41 fix)', () => { | ||
| expect(computeUserInitials('mkohli')).toBe('MK') | ||
| expect(computeUserInitials('alice')).toBe('AL') | ||
| }) | ||
|
|
||
| it('returns a single letter for single-character usernames', () => { | ||
| expect(computeUserInitials('a')).toBe('A') | ||
| }) | ||
|
|
||
| it('strips the @-domain before computing', () => { | ||
| expect(computeUserInitials('mary.kohli@example.com')).toBe('MK') | ||
| expect(computeUserInitials('mkohli@example.com')).toBe('MK') | ||
| }) | ||
|
|
||
| it('uppercases the result', () => { | ||
| expect(computeUserInitials('alice')).toBe('AL') | ||
| expect(computeUserInitials('ALICE')).toBe('AL') | ||
| expect(computeUserInitials('aLiCe')).toBe('AL') | ||
| }) | ||
|
|
||
| it('returns empty string for null/undefined/empty inputs (caller falls back to silhouette)', () => { | ||
| expect(computeUserInitials(null)).toBe('') | ||
| expect(computeUserInitials(undefined)).toBe('') | ||
| expect(computeUserInitials('')).toBe('') | ||
| }) | ||
|
|
||
| it('handles consecutive separators without producing empty segments', () => { | ||
| expect(computeUserInitials('mary..kohli')).toBe('MK') | ||
| expect(computeUserInitials('mary__kohli')).toBe('MK') | ||
| }) | ||
|
|
||
| it('handles email-only usernames with @ as the first character', () => { | ||
| expect(computeUserInitials('@example.com')).toBe('') | ||
| }) | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * Computes a 1- or 2-character avatar label for a username. | ||
| * | ||
| * Rules: | ||
| * - operate on the local-part (before any '@') only — domains | ||
| * never carry useful identity for an in-app avatar. | ||
| * - if the local-part contains separators (`.`, `_`, `-`), use the | ||
| * first letter of each segment (max 2). e.g. "mary.kohli" → "MK". | ||
| * - otherwise, use the first 1-2 letters of the whole local-part. | ||
| * e.g. "mkohli" → "MK". | ||
| * - always uppercase. | ||
| * - returns '' for inputs with no usable letters so the caller can | ||
| * decide on a graceful fallback (silhouette icon, '?'). | ||
| * | ||
| * Without the fallback to the leading letters, usernames like | ||
| * "mkohli" produced no segment initials, radar's UserMenu showed a | ||
| * generic silhouette, and the user perceived duplicated identity | ||
| * affordance because another circle in the header (radar-hub-web's | ||
| * own avatar) showed correctly-computed initials. (SKY-825 bug 41) | ||
| */ | ||
| export function computeUserInitials(username: string | null | undefined): string { | ||
| if (!username) return '' | ||
| const localPart = username.split('@')[0] | ||
| if (!localPart) return '' | ||
| const segments = localPart.split(/[._-]/).filter(Boolean) | ||
| // 2+ segments → use the first letter of each (e.g. "mary.kohli" → "MK"). | ||
| // Otherwise fall back to the leading letters of the whole local-part | ||
| // so single-segment usernames like "mkohli" still produce "MK" | ||
| // instead of just "M". (SKY-825 bug 41) | ||
| if (segments.length >= 2) { | ||
| return segments | ||
| .slice(0, 2) | ||
| .map(s => s[0]?.toUpperCase() ?? '') | ||
| .filter(Boolean) | ||
| .join('') | ||
| } | ||
| return localPart.slice(0, 2).toUpperCase() | ||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.