Skip to content

The agent that grows with you

refactor(desktop): one profile glyph

Brooklyn Nicholson9c73cbe66a05
diff --git a/apps/desktop/src/app/chat/profile-tag.test.tsx b/apps/desktop/src/app/chat/profile-tag.test.tsx
index fab0a261dca..a69b3283060 100644
--- a/apps/desktop/src/app/chat/profile-tag.test.tsx
+++ b/apps/desktop/src/app/chat/profile-tag.test.tsx
@@ -28,12 +28,14 @@ describe('ProfileTag', () => {
expect(tag.textContent).toBe('x')
})
- it('normalizes an empty profile to default and stays neutral', () => {
+ it('normalizes an empty profile to default, which shows the home glyph', () => {
render(<ProfileTag profile="" />)
const tag = screen.getByRole('img', { name: 'Profile: default' })
- expect(tag.textContent).toBe('d')
- // Default/root profile carries no identity color.
+ // The default profile has no initial and no identity color — it is the
+ // home icon, same as the profiles panel and the rail.
+ expect(tag.textContent).toBe('')
+ expect(tag.querySelector('.codicon-home')).not.toBeNull()
expect(tag.style.color).toBe('')
})
diff --git a/apps/desktop/src/app/chat/profile-tag.tsx b/apps/desktop/src/app/chat/profile-tag.tsx
index 8cb3e38ac3a..25773088f3b 100644
--- a/apps/desktop/src/app/chat/profile-tag.tsx
+++ b/apps/desktop/src/app/chat/profile-tag.tsx
@@ -1,36 +1,30 @@
import { useStore } from '@nanostores/react'
+import { ProfileGlyph } from '@/components/ui/profile-glyph'
import { Tip } from '@/components/ui/tooltip'
import { useI18n } from '@/i18n'
-import { profileColorSoft, resolveProfileColor } from '@/lib/profile-color'
-import { cn } from '@/lib/utils'
+import { resolveProfileColor } from '@/lib/profile-color'
import { $profileColors, normalizeProfileKey } from '@/store/profile'
-/** Owning-profile chip: soft profile-tint square with the initial, tooltip +
- * accessible label carrying the full name. Same visual language as the
- * profile rail; the default profile stays neutral. Identity, not status —
+/** Owning-profile chip: the shared {@link ProfileGlyph}, resolved against the
+ * live profile colors and labelled with the full name. Identity, not status —
* session state dots keep their own semantics (#66003). */
export function ProfileTag({ className, profile }: { className?: string; profile: null | string | undefined }) {
const { t } = useI18n()
const colors = useStore($profileColors)
const key = normalizeProfileKey(profile)
- const color = resolveProfileColor(key, colors)
- const hue = color ?? 'var(--ui-text-quaternary)'
const label = t.sidebar.row.ownedByProfile(key)
return (
<Tip label={label}>
- <span
+ <ProfileGlyph
aria-label={label}
- className={cn(
- 'grid size-4 shrink-0 place-items-center rounded-[3px] text-[0.5rem] font-semibold uppercase leading-none',
- className
- )}
+ className={className}
+ color={resolveProfileColor(key, colors)}
+ isDefault={key === 'default'}
+ name={key}
role="img"
- style={{ backgroundColor: profileColorSoft(hue, 22), color: color ?? undefined }}
- >
- {key.replace(/[^a-z0-9]/gi, '').charAt(0) || '?'}
- </span>
+ />
</Tip>
)
}
diff --git a/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx b/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx
index 4a178f15c5f..530ef5c6c0c 100644
--- a/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx
+++ b/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx
@@ -29,6 +29,7 @@ import { ColorSwatches } from '@/components/ui/color-swatches'
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from '@/components/ui/context-menu'
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Popover, PopoverAnchor, PopoverContent } from '@/components/ui/popover'
+import { ProfileGlyph } from '@/components/ui/profile-glyph'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
import { Tip, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
import { getProfileSoul, updateProfileSoul } from '@/hermes'
@@ -496,19 +497,12 @@ function ProfileDropdown({
// One dropdown row per profile — its own component so each row can own a
// hover-intent prewarm timer (see useProfilePrewarm).
function ProfileDropdownItem({ color, name }: { color: null | string; name: string }) {
- const hue = color ?? 'var(--ui-text-quaternary)'
const { cancelPrewarm, startPrewarm } = useProfilePrewarm(name)
return (
<SelectItem onPointerEnter={startPrewarm} onPointerLeave={cancelPrewarm} value={name}>
<span className="flex min-w-0 items-center gap-1.5">
- <span
- aria-hidden="true"
- className="grid size-4 shrink-0 place-items-center rounded-[3px] text-[0.5rem] font-semibold uppercase leading-none"
- style={{ backgroundColor: profileColorSoft(hue, 22), color: color ?? undefined }}
- >
- {name.replace(/[^a-z0-9]/gi, '').charAt(0) || '?'}
- </span>
+ <ProfileGlyph aria-hidden="true" color={color} isDefault={false} name={name} />
<span className="truncate">{name}</span>
</span>
</SelectItem>
diff --git a/apps/desktop/src/app/profiles/index.tsx b/apps/desktop/src/app/profiles/index.tsx
index 0ec99934410..a27cb261a9c 100644
--- a/apps/desktop/src/app/profiles/index.tsx
+++ b/apps/desktop/src/app/profiles/index.tsx
@@ -5,12 +5,12 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { CodeEditor } from '@/components/chat/code-editor'
import { PageLoader } from '@/components/page-loader'
import { Button } from '@/components/ui/button'
-import { Codicon } from '@/components/ui/codicon'
+import { ProfileGlyph } from '@/components/ui/profile-glyph'
import { getProfileSoul, type ProfileInfo, updateProfileSoul } from '@/hermes'
import { useI18n } from '@/i18n'
import { displayPath } from '@/lib/display-path'
import { AlertTriangle, Save } from '@/lib/icons'
-import { profileColorSoft, resolveProfileColor } from '@/lib/profile-color'
+import { resolveProfileColor } from '@/lib/profile-color'
import { normalize } from '@/lib/text'
import { notify, notifyError } from '@/store/notifications'
import { $profileColors, refreshProfiles } from '@/store/profile'
@@ -205,6 +205,7 @@ function ProfileRow({
active={active}
lead={
<ProfileGlyph
+ aria-hidden="true"
color={resolveProfileColor(profile.name, colors)}
isDefault={profile.is_default}
name={profile.name}
@@ -219,33 +220,6 @@ function ProfileRow({
)
}
-// Leading glyph for a profile row, mirroring the sidebar rail: the default
-// profile gets the `home` icon; named profiles get a soft color-tinted square
-// with their initial in the profile's color.
-function ProfileGlyph({ color, isDefault, name }: { color: null | string; isDefault: boolean; name: string }) {
- if (isDefault) {
- return <Codicon className="shrink-0 text-muted-foreground/70" name="home" size="0.9rem" />
- }
-
- const hue = color ?? 'var(--ui-text-quaternary)'
-
- const initial =
- name
- .replace(/[^a-z0-9]/gi, '')
- .charAt(0)
- .toUpperCase() || '?'
-
- return (
- <span
- aria-hidden="true"
- className="grid size-4 shrink-0 place-items-center rounded-[3px] text-[0.5rem] font-semibold uppercase leading-none"
- style={{ backgroundColor: profileColorSoft(hue, 22), color: color ?? undefined }}
- >
- {initial}
- </span>
- )
-}
-
function ProfileDetail({ profile }: { profile: ProfileInfo }) {
const { t } = useI18n()
const p = t.profiles
diff --git a/apps/desktop/src/components/ui/profile-glyph.tsx b/apps/desktop/src/components/ui/profile-glyph.tsx
new file mode 100644
index 00000000000..7a67c5749d2
--- /dev/null
+++ b/apps/desktop/src/components/ui/profile-glyph.tsx
@@ -0,0 +1,43 @@
+import { profileColorSoft } from '@/lib/profile-color'
+import { cn } from '@/lib/utils'
+
+import { Codicon } from './codicon'
+
+/** A profile's mark, in one place: the default profile is the `home` icon (it
+ * has no color of its own and an initial would read as just another named
+ * profile); every other profile is a soft tint of its color carrying its
+ * initial. Presentational — callers resolve the color from `$profileColors`. */
+export function ProfileGlyph({
+ className,
+ color,
+ isDefault,
+ name,
+ ...props
+}: Omit<React.ComponentProps<'span'>, 'color'> & {
+ color: null | string
+ isDefault: boolean
+ name: string
+}) {
+ if (isDefault) {
+ return (
+ <span className={cn('grid size-4 shrink-0 place-items-center', className)} {...props}>
+ <Codicon className="text-(--ui-text-quaternary)" name="home" size="0.75rem" />
+ </span>
+ )
+ }
+
+ const initial = name.replace(/[^a-z0-9]/gi, '').charAt(0) || '?'
+
+ return (
+ <span
+ className={cn(
+ 'grid size-4 shrink-0 place-items-center rounded-[3px] text-[0.5rem] font-semibold uppercase leading-none',
+ className
+ )}
+ style={{ backgroundColor: profileColorSoft(color ?? 'var(--ui-text-quaternary)', 22), color: color ?? undefined }}
+ {...props}
+ >
+ {initial}
+ </span>
+ )
+}