From 0226a95fb610214880dbbe2c526811ab2e852597 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 21:31:22 -0800 Subject: [PATCH] feat(teammates): profile pictures on Team rows and teammate profiles Uses the roster's pictureUrl (stablyai/orca-cloud#740; https only, re-checked in main). Initials stay underneath and show if the image is absent or fails to load; no referrer is sent. --- .../profile-cloud-org-members-client.test.ts | 32 +++++++++++++++++ .../profile-cloud-org-members-client.ts | 18 +++++++++- .../components/billing/team/TeamAvatar.tsx | 35 +++++++++++++++++-- .../billing/team/TeamMemberList.tsx | 6 +++- .../billing/team/TeamPageView.fixture.tsx | 12 ++++++- .../teammates/TeammateProfileDialog.tsx | 1 + .../teammates/TeammateProfileView.fixture.tsx | 13 +++++++ .../teammates/TeammateProfileView.tsx | 18 ++++++++-- src/shared/orca-profiles.ts | 2 ++ 9 files changed, 129 insertions(+), 8 deletions(-) create mode 100644 src/main/orca-profiles/profile-cloud-org-members-client.test.ts diff --git a/src/main/orca-profiles/profile-cloud-org-members-client.test.ts b/src/main/orca-profiles/profile-cloud-org-members-client.test.ts new file mode 100644 index 00000000000..64f64d9bb28 --- /dev/null +++ b/src/main/orca-profiles/profile-cloud-org-members-client.test.ts @@ -0,0 +1,32 @@ +import { describe, expect, it } from 'vitest' +import { normalizeRoster } from './profile-cloud-org-members-client' + +describe('normalizeRoster', () => { + it('keeps https profile pictures and drops anything else', () => { + const roster = normalizeRoster({ + viewerRole: 'member', + canManageMembers: false, + pendingInvites: [], + members: [ + { + userId: 'a', + email: 'a@x.dev', + role: 'member', + pictureUrl: 'https://img.propelauth.com/a.png' + }, + { userId: 'b', email: 'b@x.dev', role: 'member', pictureUrl: 'http://x.dev/b.png' }, + { userId: 'c', email: 'c@x.dev', role: 'member', pictureUrl: 'javascript:alert(1)' }, + { userId: 'd', email: 'd@x.dev', role: 'member', pictureUrl: 'file:///etc/passwd' }, + { userId: 'e', email: 'e@x.dev', role: 'member' } + ] + }) + expect(roster.members.map((m) => m.pictureUrl)).toEqual([ + 'https://img.propelauth.com/a.png', + undefined, + undefined, + undefined, + undefined + ]) + expect('pictureUrl' in roster.members[4]!).toBe(false) + }) +}) diff --git a/src/main/orca-profiles/profile-cloud-org-members-client.ts b/src/main/orca-profiles/profile-cloud-org-members-client.ts index 4723b6f2174..9be78a26bdc 100644 --- a/src/main/orca-profiles/profile-cloud-org-members-client.ts +++ b/src/main/orca-profiles/profile-cloud-org-members-client.ts @@ -40,6 +40,19 @@ function normalizeTimestamp(value: unknown): number { return Date.now() } +// The renderer loads this image, so only a plain https URL from auth is kept. +function optionalPictureUrl(value: unknown): string | undefined { + if (typeof value !== 'string' || value.length > 2048) { + return undefined + } + try { + const url = new URL(value) + return url.protocol === 'https:' && !url.username && !url.password ? url.toString() : undefined + } catch { + return undefined + } +} + function normalizeMember(value: unknown): OrcaOrgMember | null { if (!value || typeof value !== 'object') { return null @@ -54,6 +67,9 @@ function normalizeMember(value: unknown): OrcaOrgMember | null { userId: userId ?? null, email, displayName: optionalString(record.displayName), + ...(optionalPictureUrl(record.pictureUrl) + ? { pictureUrl: optionalPictureUrl(record.pictureUrl) } + : {}), role: normalizeRole(record.role, 'member') } } @@ -74,7 +90,7 @@ function normalizePendingInvite(value: unknown): OrcaOrgPendingInvite | null { } } -function normalizeRoster(value: unknown): OrcaOrgMembersRoster { +export function normalizeRoster(value: unknown): OrcaOrgMembersRoster { if (!value || typeof value !== 'object') { throw new Error('invalid_orca_org_members_roster') } diff --git a/src/renderer/src/components/billing/team/TeamAvatar.tsx b/src/renderer/src/components/billing/team/TeamAvatar.tsx index 62f6be5ef3a..2c45075d9c2 100644 --- a/src/renderer/src/components/billing/team/TeamAvatar.tsx +++ b/src/renderer/src/components/billing/team/TeamAvatar.tsx @@ -1,5 +1,33 @@ +import { useState } from 'react' import { cn } from '@/lib/utils' +/** + * A teammate's provider profile picture filling its avatar circle, or null when there is none or it + * failed to load (the caller's initials show instead). No referrer goes to the image host. + */ +export function ProfilePicture({ + url, + className +}: { + url: string | undefined + className?: string +}): React.JSX.Element | null { + const [failed, setFailed] = useState(null) + if (!url || failed === url) { + return null + } + return ( + setFailed(url)} + className={cn('absolute inset-0 size-full rounded-full object-cover', className)} + /> + ) +} + /** "Ada Lovelace" → "AL", "ada@x.io" → "A", "Acme Dev" → "AD". */ export function initialsFor(nameOrEmail: string): string { const base = nameOrEmail.includes('@') ? (nameOrEmail.split('@')[0] ?? '') : nameOrEmail @@ -15,21 +43,23 @@ export function initialsFor(nameOrEmail: string): string { return (first + second).toUpperCase() } -/** Round person avatar (initials). Pending people get a dashed, hollow look. */ +/** Round person avatar (picture, else initials). Pending people get a dashed, hollow look. */ export function PersonAvatar({ name, pending = false, + pictureUrl, className }: { name: string pending?: boolean + pictureUrl?: string className?: string }): React.JSX.Element { return ( {initialsFor(name)} + {pending ? null : } ) } diff --git a/src/renderer/src/components/billing/team/TeamMemberList.tsx b/src/renderer/src/components/billing/team/TeamMemberList.tsx index eb9ddbb9740..083d064cc2d 100644 --- a/src/renderer/src/components/billing/team/TeamMemberList.tsx +++ b/src/renderer/src/components/billing/team/TeamMemberList.tsx @@ -259,7 +259,11 @@ export function TeamMemberList(props: TeamMemberListProps): React.JSX.Element { className="group/row flex min-h-12 flex-col justify-center bg-card px-3 py-2 transition-colors animate-in fade-in-0 duration-200 motion-reduce:animate-none" >
- +

{profileUserId && props.onOpenProfile ? ( diff --git a/src/renderer/src/components/billing/team/TeamPageView.fixture.tsx b/src/renderer/src/components/billing/team/TeamPageView.fixture.tsx index e9c4c2b37d5..73725469a20 100644 --- a/src/renderer/src/components/billing/team/TeamPageView.fixture.tsx +++ b/src/renderer/src/components/billing/team/TeamPageView.fixture.tsx @@ -6,6 +6,10 @@ import { sampleTeam } from '../plan-billing-fixtures' import { TeamDialogContent } from './TeamDialogHost' import { TeamPageView, type TeamPageViewProps } from './TeamPageView' +// Fixtures render offline: a self-contained stand-in for a provider profile picture. +const ADA_PICTURE = + "data:image/svg+xml;utf8," + const NOW = Date.UTC(2026, 10, 18, 15) const DAY = 86_400_000 const width = 1100 @@ -15,7 +19,13 @@ const roster: OrcaOrgMembersRoster = { canManageMembers: true, members: [ { userId: 'u-neil', email: 'neil@acme.dev', displayName: 'Neil Parker', role: 'owner' }, - { userId: 'u-ada', email: 'ada@acme.dev', displayName: 'Ada Lovelace', role: 'admin' }, + { + userId: 'u-ada', + email: 'ada@acme.dev', + displayName: 'Ada Lovelace', + role: 'admin', + pictureUrl: ADA_PICTURE + }, { userId: 'u-grace', email: 'grace@acme.dev', displayName: 'Grace Hopper', role: 'member' }, { userId: null, email: 'linus@acme.dev', role: 'member' } ], diff --git a/src/renderer/src/components/teammates/TeammateProfileDialog.tsx b/src/renderer/src/components/teammates/TeammateProfileDialog.tsx index 20f402c269d..5b0b7f3622c 100644 --- a/src/renderer/src/components/teammates/TeammateProfileDialog.tsx +++ b/src/renderer/src/components/teammates/TeammateProfileDialog.tsx @@ -89,6 +89,7 @@ function ProfileBody({ userId }: { userId: string }): React.JSX.Element { userId={userId} name={name} email={member?.email ?? null} + {...(member?.pictureUrl ? { pictureUrl: member.pictureUrl } : {})} role={member?.role ?? null} profile={profile} error={error} diff --git a/src/renderer/src/components/teammates/TeammateProfileView.fixture.tsx b/src/renderer/src/components/teammates/TeammateProfileView.fixture.tsx index 1b2a76b3d2d..889e8852cae 100644 --- a/src/renderer/src/components/teammates/TeammateProfileView.fixture.tsx +++ b/src/renderer/src/components/teammates/TeammateProfileView.fixture.tsx @@ -4,6 +4,9 @@ import { FIXTURE_NOW, workspace } from '../cloud-workspaces/cloud-workspaces.tes import { TeammateProfileView, type TeammateProfileViewProps } from './TeammateProfileView' const DAYS = 182 +// Fixtures render offline: a self-contained stand-in for a provider profile picture. +const PICTURE = + "data:image/svg+xml;utf8," /** A believable work pattern: weekdays busy, weekends quiet, a vacation gap. Deterministic. */ function levels(): number[] { @@ -87,6 +90,16 @@ export const teammate = defineFixture({ ) }) +/** A teammate with a provider profile picture (falls back to initials if it fails to load). */ +export const withPicture = defineFixture({ + width: 600, + render: () => ( + + + + ) +}) + /** Your own profile: amounts in the hover caption, private workspaces included, no Poke. */ export const self = defineFixture({ width: 600, diff --git a/src/renderer/src/components/teammates/TeammateProfileView.tsx b/src/renderer/src/components/teammates/TeammateProfileView.tsx index a6ad5b56b97..e7cfb662834 100644 --- a/src/renderer/src/components/teammates/TeammateProfileView.tsx +++ b/src/renderer/src/components/teammates/TeammateProfileView.tsx @@ -10,6 +10,7 @@ import { cn } from '@/lib/utils' import type { CloudWorkspace } from '../../../../shared/cloud-workspaces/cloud-workspaces-wire' import type { OrcaOrgRole } from '../../../../shared/orca-profiles' import type { TeammateProfile } from '../../../../shared/cloud-workspaces/team-presence-wire' +import { ProfilePicture } from '../billing/team/TeamAvatar' import { roleLabel } from '../billing/team/team-roles' import { dotState, statusLabel } from '../cloud-workspaces/CloudWorkspaceRow' import { @@ -33,6 +34,8 @@ export type TeammateProfileViewProps = { /** Roster name, else the control plane's, else a short id. */ name: string email: string | null + /** Profile picture from the roster (https only); initials when absent or it fails to load. */ + pictureUrl?: string role: OrcaOrgRole | null profile: TeammateProfile | null /** Set when the profile couldn't load; the header still shows from the roster. */ @@ -46,7 +49,15 @@ export type TeammateProfileViewProps = { onTurnOnPokes: () => void } -function LargeAvatar({ userId, name }: { userId: string; name: string }): React.JSX.Element { +function LargeAvatar({ + userId, + name, + pictureUrl +}: { + userId: string + name: string + pictureUrl: string | undefined +}): React.JSX.Element { // Same per-member hue as the small avatars on workspace rows, so a teammate keeps one color. const hueStyle: React.CSSProperties & { '--avatar-hue': string } = { '--avatar-hue': String(memberHue(userId)) @@ -56,12 +67,13 @@ function LargeAvatar({ userId, name }: { userId: string; name: string }): React. aria-hidden style={hueStyle} className={cn( - 'inline-flex size-12 shrink-0 select-none items-center justify-center rounded-full text-base font-medium', + 'relative inline-flex size-12 shrink-0 select-none items-center justify-center overflow-hidden rounded-full text-base font-medium', 'bg-[hsl(var(--avatar-hue)_45%_88%)] text-[hsl(var(--avatar-hue)_45%_28%)]', 'dark:bg-[hsl(var(--avatar-hue)_30%_26%)] dark:text-[hsl(var(--avatar-hue)_55%_82%)]' )} > {initials(name)} + ) } @@ -142,7 +154,7 @@ export function TeammateProfileView(props: TeammateProfileViewProps): React.JSX. return (

- +