From bae57cf55ac4e48ffb5c2b5ca431a3ae5ae8d63d Mon Sep 17 00:00:00 2001 From: Preston Booth Date: Tue, 17 Nov 2026 11:17:29 -0700 Subject: [PATCH 1/2] feat(mosaic): show the user's role beside their email in the combined switcher Co-Authored-By: Claude Sonnet 5.5 --- .changeset/quiet-roles-show.md | 5 +++++ packages/mosaic/src/features/switcher/switcher.model.tsx | 8 ++++++-- packages/mosaic/src/features/switcher/switcher.types.ts | 2 ++ packages/mosaic/src/features/switcher/switcher.view.tsx | 4 +++- .../user-button/__tests__/user-button.feature.test.tsx | 7 +++++++ packages/swingset/src/stories/fixtures/switcher.tsx | 1 + 6 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .changeset/quiet-roles-show.md diff --git a/.changeset/quiet-roles-show.md b/.changeset/quiet-roles-show.md new file mode 100644 index 00000000000..5e96ba5bced --- /dev/null +++ b/.changeset/quiet-roles-show.md @@ -0,0 +1,5 @@ +--- +'@clerk/mosaic': minor +--- + +The combined organization and user switcher now shows the user's role in the active organization next to their identifier in the popup header, for example `cameron@clerk.com · Admin`. diff --git a/packages/mosaic/src/features/switcher/switcher.model.tsx b/packages/mosaic/src/features/switcher/switcher.model.tsx index a3a114e41a5..0855c2a788b 100644 --- a/packages/mosaic/src/features/switcher/switcher.model.tsx +++ b/packages/mosaic/src/features/switcher/switcher.model.tsx @@ -164,7 +164,11 @@ export function useSwitcherModel( const { isLoaded: isUserLoaded, user } = useUser(); const { isLoaded: isSessionLoaded, session } = useSession(); // The active org names the trigger. That is not a request to turn Organizations on. - const { isLoaded: isOrgLoaded, organization } = useOrganization({ + const { + isLoaded: isOrgLoaded, + organization, + membership, + } = useOrganization({ __internal_skipAttemptToEnableOrganizations: true, }); const clerk = useClerk(); @@ -323,7 +327,7 @@ export function useSwitcherModel( organizationsEnabled, renderBranding: displayConfig.branded, activeSession: toSession(session.id, user), - activeOrganization: organization ? toMembership(organization) : null, + activeOrganization: organization ? { ...toMembership(organization), roleName: membership?.roleName } : null, // The user resource settles this before the paginated list answers; the count covers a stale resource. hasOrganizations: user.organizationMemberships.length > 0 || (userMemberships.count ?? 0) > 0, hidePersonal: forceOrganizationSelection || (options.hidePersonal ?? false), diff --git a/packages/mosaic/src/features/switcher/switcher.types.ts b/packages/mosaic/src/features/switcher/switcher.types.ts index 3affed65882..1ac90e8d3cc 100644 --- a/packages/mosaic/src/features/switcher/switcher.types.ts +++ b/packages/mosaic/src/features/switcher/switcher.types.ts @@ -22,6 +22,8 @@ export interface SwitcherMembership { imageUrl?: string; membersCount?: number; planLabel?: string; + /** The signed-in user's role in this organization, as Clerk names it. */ + roleName?: string; } export interface SwitcherSuggestion { diff --git a/packages/mosaic/src/features/switcher/switcher.view.tsx b/packages/mosaic/src/features/switcher/switcher.view.tsx index 0c6ab1e0d49..dd71f8685db 100644 --- a/packages/mosaic/src/features/switcher/switcher.view.tsx +++ b/packages/mosaic/src/features/switcher/switcher.view.tsx @@ -159,7 +159,9 @@ function membershipSubtitle(membership: SwitcherMembership, m: Messages, locale: function headerSubtitle(lead: LeadSelection, identifier: string, m: Messages, locale: string): string { if (lead.kind === 'organization') { - return lead.user ? identifier : membershipSubtitle(lead.organization, m, locale); + return lead.user + ? joinDetails(identifier, lead.organization.roleName) + : membershipSubtitle(lead.organization, m, locale); } if (lead.kind === 'none') { // No selection is not the account, so it carries no identifier line. diff --git a/packages/mosaic/src/features/user-button/__tests__/user-button.feature.test.tsx b/packages/mosaic/src/features/user-button/__tests__/user-button.feature.test.tsx index b20f5cc8723..7acb0df3f1e 100644 --- a/packages/mosaic/src/features/user-button/__tests__/user-button.feature.test.tsx +++ b/packages/mosaic/src/features/user-button/__tests__/user-button.feature.test.tsx @@ -220,6 +220,13 @@ describe('UserButton', () => { expect(requiredPopup().querySelector('.cl-user-button-header-description')).toHaveTextContent('alice'); }); + it('names the role in the active organization beside the identifier in combined mode', async () => { + await renderUserButton({ mode: 'combined' }); + await open(); + + expect(requiredPopup().querySelector('.cl-user-button-header-description')).toHaveTextContent('alice · Member'); + }); + describe('switching organization', () => { it('makes the selected organization active and closes', async () => { const { navigate } = await renderUserButton(); diff --git a/packages/swingset/src/stories/fixtures/switcher.tsx b/packages/swingset/src/stories/fixtures/switcher.tsx index e2f746458a8..7f87a9a4131 100644 --- a/packages/swingset/src/stories/fixtures/switcher.tsx +++ b/packages/swingset/src/stories/fixtures/switcher.tsx @@ -35,6 +35,7 @@ const nestLabs: SwitcherMembership = { name: 'NestLabs Creative', membersCount: 24, planLabel: 'Pro plan', + roleName: 'Admin', imageUrl: defaultOrgLogo, }; From b78766d116ba7dc0706ae5682e83b1b9780942bb Mon Sep 17 00:00:00 2001 From: Preston Booth Date: Tue, 17 Nov 2026 11:48:18 -0700 Subject: [PATCH 2/2] test(mosaic): pass the supported combined prop in the switcher role test Co-Authored-By: Claude Sonnet 5.5 --- .../features/user-button/__tests__/user-button.feature.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mosaic/src/features/user-button/__tests__/user-button.feature.test.tsx b/packages/mosaic/src/features/user-button/__tests__/user-button.feature.test.tsx index 7acb0df3f1e..8dbd86523bb 100644 --- a/packages/mosaic/src/features/user-button/__tests__/user-button.feature.test.tsx +++ b/packages/mosaic/src/features/user-button/__tests__/user-button.feature.test.tsx @@ -221,7 +221,7 @@ describe('UserButton', () => { }); it('names the role in the active organization beside the identifier in combined mode', async () => { - await renderUserButton({ mode: 'combined' }); + await renderUserButton({ combined: true }); await open(); expect(requiredPopup().querySelector('.cl-user-button-header-description')).toHaveTextContent('alice · Member');