Skip to content

Commit a5c5ee7

Browse files
authored
fix(web): show agent flavor icon in session header (#714)
* fix(web): reuse agent flavor icon in session header * fix(web): use neutral badge for unknown agent flavor
1 parent cf378df commit a5c5ee7

6 files changed

Lines changed: 49 additions & 41 deletions

File tree

125 KB
Loading
132 KB
Loading
414 KB
Loading
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const FLAVOR_BADGES: Record<string, { label: string; colors: string }> = {
2+
claude: {
3+
label: 'Cl',
4+
colors: 'bg-[#d97706] text-white',
5+
},
6+
codex: {
7+
label: 'Cx',
8+
colors: 'bg-[#111827] text-white',
9+
},
10+
cursor: {
11+
label: 'Cu',
12+
colors: 'bg-[#0f766e] text-white',
13+
},
14+
gemini: {
15+
label: 'Gm',
16+
colors: 'bg-[#2563eb] text-white',
17+
},
18+
kimi: {
19+
label: 'Km',
20+
colors: 'bg-[#7c3aed] text-white',
21+
},
22+
opencode: {
23+
label: 'Op',
24+
colors: 'bg-[#15803d] text-white',
25+
},
26+
}
27+
28+
const UNKNOWN_FLAVOR_BADGE = {
29+
label: 'Un',
30+
colors: 'bg-[var(--app-secondary-bg)] text-[var(--app-hint)]',
31+
}
32+
33+
export function AgentFlavorIcon({ flavor, className }: { flavor?: string | null; className?: string }) {
34+
const normalized = (flavor ?? '').trim().toLowerCase()
35+
const badge = FLAVOR_BADGES[normalized] ?? UNKNOWN_FLAVOR_BADGE
36+
37+
return (
38+
<span
39+
aria-hidden="true"
40+
className={`inline-flex items-center justify-center rounded-sm text-[8px] font-semibold leading-none ${badge.colors} ${className ?? 'h-4 w-4'}`}
41+
>
42+
{badge.label}
43+
</span>
44+
)
45+
}

web/src/components/SessionHeader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { RenameSessionDialog } from '@/components/RenameSessionDialog'
88
import { ConfirmDialog } from '@/components/ui/ConfirmDialog'
99
import { getSessionModelLabel } from '@/lib/sessionModelLabel'
1010
import { useTranslation } from '@/lib/use-translation'
11+
import { AgentFlavorIcon } from '@/components/AgentFlavorIcon'
1112

1213
function getSessionTitle(session: Session): string {
1314
if (session.metadata?.name) {
@@ -162,7 +163,7 @@ export function SessionHeader(props: {
162163
</div>
163164
<div className="flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-[var(--app-hint)]">
164165
<span className="inline-flex items-center gap-1">
165-
<span aria-hidden="true"></span>
166+
<AgentFlavorIcon flavor={session.metadata?.flavor} className="h-3.5 w-3.5 shrink-0" />
166167
{session.metadata?.flavor?.trim() || 'unknown'}
167168
</span>
168169
{modelLabel ? (

web/src/components/SessionList.tsx

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { CopyIcon, CheckIcon } from '@/components/icons'
1111
import { cn } from '@/lib/utils'
1212
import { useTranslation } from '@/lib/use-translation'
1313
import { DEFAULT_SESSION_PREVIEW_LIMIT, useSessionPreviewLimit } from '@/hooks/useSessionPreviewLimit'
14+
import { AgentFlavorIcon } from '@/components/AgentFlavorIcon'
1415

1516
type SessionGroup = {
1617
key: string
@@ -481,45 +482,6 @@ function SessionListSearch(props: {
481482
)
482483
}
483484

484-
const FLAVOR_BADGES: Record<string, { label: string; colors: string }> = {
485-
claude: {
486-
label: 'Cl',
487-
colors: 'bg-[#d97706] text-white',
488-
},
489-
codex: {
490-
label: 'Cx',
491-
colors: 'bg-[#111827] text-white',
492-
},
493-
cursor: {
494-
label: 'Cu',
495-
colors: 'bg-[#0f766e] text-white',
496-
},
497-
gemini: {
498-
label: 'Gm',
499-
colors: 'bg-[#2563eb] text-white',
500-
},
501-
kimi: {
502-
label: 'Km',
503-
colors: 'bg-[#7c3aed] text-white',
504-
},
505-
opencode: {
506-
label: 'Op',
507-
colors: 'bg-[#15803d] text-white',
508-
},
509-
}
510-
511-
function FlavorIcon({ flavor, className }: { flavor?: string | null; className?: string }) {
512-
const badge = FLAVOR_BADGES[(flavor ?? 'claude').trim().toLowerCase()] ?? FLAVOR_BADGES.claude
513-
return (
514-
<span
515-
aria-hidden="true"
516-
className={`inline-flex items-center justify-center rounded-sm text-[8px] font-semibold leading-none ${badge.colors} ${className ?? 'h-4 w-4'}`}
517-
>
518-
{badge.label}
519-
</span>
520-
)
521-
}
522-
523485
function MachineIcon(props: { className?: string }) {
524486
return (
525487
<svg
@@ -604,7 +566,7 @@ function SessionItem(props: {
604566
>
605567
<div className={`flex items-center justify-between gap-3 ${!s.active ? 'opacity-50' : ''}`}>
606568
<div className="flex items-center gap-2 min-w-0">
607-
<FlavorIcon flavor={s.metadata?.flavor} className="h-4 w-4 shrink-0" />
569+
<AgentFlavorIcon flavor={s.metadata?.flavor} className="h-4 w-4 shrink-0" />
608570
<div className={`truncate text-sm font-medium ${s.active ? 'text-[var(--app-fg)]' : 'text-[var(--app-hint)]'}`}>
609571
{sessionName}
610572
</div>

0 commit comments

Comments
 (0)