Skip to content

Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.

Let an agent have a color of its own or a picture (#59)

Rayanne B. Lima81649a0f5a69
diff --git a/src/core/agent-look.ts b/src/core/agent-look.ts
new file mode 100644
index 0000000..2cdc2f8
--- /dev/null
+++ b/src/core/agent-look.ts
@@ -0,0 +1,10 @@
+import type { Agent } from '../shared/types'
+
+const MAX_PICTURE = 200_000
+
+// Shown in every window as they are: only a color and only a small picture stay.
+export function cleanLook<T extends Pick<Agent, 'customColor' | 'picture'>>(agent: T): T {
+ const customColor = agent.customColor && /^#[0-9a-f]{6}$/i.test(agent.customColor) ? agent.customColor : undefined
+ const picture = agent.picture && agent.picture.length <= MAX_PICTURE && /^data:image\/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/.test(agent.picture) ? agent.picture : undefined
+ return { ...agent, customColor, picture }
+}
diff --git a/src/core/db.ts b/src/core/db.ts
index f60d1d1..fe5dc10 100644
--- a/src/core/db.ts
+++ b/src/core/db.ts
@@ -233,6 +233,10 @@ const MIGRATIONS = [
`,
`
ALTER TABLE agents ADD COLUMN max_routines INTEGER NOT NULL DEFAULT 10;
+ `,
+ `
+ ALTER TABLE agents ADD COLUMN custom_color TEXT;
+ ALTER TABLE agents ADD COLUMN picture TEXT;
`
]
@@ -330,6 +334,8 @@ export class Db {
web: r['web'] !== 0,
browser: r['browser'] === 1,
apps: JSON.parse(str(r['apps']) || '[]') as AgentApp[],
+ ...(r['custom_color'] ? { customColor: str(r['custom_color']) } : {}),
+ ...(r['picture'] ? { picture: str(r['picture']) } : {}),
autoApprove: JSON.parse(str(r['auto_approve']) || '[]') as string[],
folders: JSON.parse(str(r['folders']) || '[]') as LentFolder[],
archived: r['archived'] === 1,
@@ -349,14 +355,14 @@ export class Db {
saveAgent(a: Agent): void {
this.db
.prepare(
- `INSERT INTO agents (id, name, handle, role, color, instructions, model, fallback_model, fallback_account, account, effort, limit_tokens, max_routines, grants, memory_mode, computer, computer_kind, web, browser, apps, auto_approve, archived, kind, created_at)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ `INSERT INTO agents (id, name, handle, role, color, instructions, model, fallback_model, fallback_account, account, effort, limit_tokens, max_routines, grants, memory_mode, computer, computer_kind, web, browser, apps, auto_approve, archived, kind, custom_color, picture, created_at)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT (id) DO UPDATE SET name = excluded.name, handle = excluded.handle, role = excluded.role,
color = excluded.color, instructions = excluded.instructions, model = excluded.model, fallback_model = excluded.fallback_model, fallback_account = excluded.fallback_account, account = excluded.account, effort = excluded.effort,
limit_tokens = excluded.limit_tokens, max_routines = excluded.max_routines, grants = excluded.grants, memory_mode = excluded.memory_mode,
- computer = excluded.computer, computer_kind = excluded.computer_kind, web = excluded.web, browser = excluded.browser, apps = excluded.apps, auto_approve = excluded.auto_approve, archived = excluded.archived, kind = COALESCE(excluded.kind, agents.kind)`
+ computer = excluded.computer, computer_kind = excluded.computer_kind, web = excluded.web, browser = excluded.browser, apps = excluded.apps, auto_approve = excluded.auto_approve, archived = excluded.archived, kind = COALESCE(excluded.kind, agents.kind), custom_color = excluded.custom_color, picture = excluded.picture`
)
- .run(a.id, a.name, a.handle, a.role, a.color, a.instructions, a.modelId, a.fallbackModelId || null, a.fallbackAccountId || null, a.accountId || null, a.effort, a.limit, routineCap(a.maxRoutines), JSON.stringify(a.grants), a.memory ?? 'auto', a.computer ? 1 : 0, a.computerKind === 'mac' ? 'mac' : 'linux', a.web === false ? 0 : 1, a.browser ? 1 : 0, JSON.stringify(a.apps ?? []), JSON.stringify(a.autoApprove ?? []), a.archived ? 1 : 0, a.kind ?? null, Date.now())
+ .run(a.id, a.name, a.handle, a.role, a.color, a.instructions, a.modelId, a.fallbackModelId || null, a.fallbackAccountId || null, a.accountId || null, a.effort, a.limit, routineCap(a.maxRoutines), JSON.stringify(a.grants), a.memory ?? 'auto', a.computer ? 1 : 0, a.computerKind === 'mac' ? 'mac' : 'linux', a.web === false ? 0 : 1, a.browser ? 1 : 0, JSON.stringify(a.apps ?? []), JSON.stringify(a.autoApprove ?? []), a.archived ? 1 : 0, a.kind ?? null, a.customColor ?? null, a.picture ?? null, Date.now())
}
// Kept apart from saveAgent: folders change only after the core checks them.
diff --git a/src/core/index.ts b/src/core/index.ts
index 29a5dfe..3979da2 100644
--- a/src/core/index.ts
+++ b/src/core/index.ts
@@ -11,6 +11,7 @@ import { L, langOf, locale, setLang, type Lang } from '../shared/lang'
import type { Api, CoreEvent, Method, Request, Wire } from '../shared/rpc'
import { channelName, ENGINES, inQuietHours, modelInfo, rememberModels, WEBHOOK_PORT, type Account, type AccountEngine, type Agent, type BrowserReply, type Message, type EngineId, type EngineStatus, type Settings } from '../shared/types'
import { listModels, quietClaude, quietCodex, withChoice } from './harness'
+import { cleanLook } from './agent-look'
import { Db } from './db'
import { claudeEngine, userProvider } from './engines/claude'
import { codexEngine, userCodexProvider } from './engines/codex'
@@ -635,7 +636,7 @@ const api: Api = {
saveAgent: ({ agent, channelIds }) => {
const before = db.agent(agent.id)
// Archived changes only through archiveAgent, which also stops what the agent was doing.
- const clean: Agent = { ...agent, name: agent.name.trim(), handle: agent.handle.trim().toLowerCase(), archived: before?.archived ?? false }
+ const clean: Agent = { ...cleanLook(agent), name: agent.name.trim(), handle: agent.handle.trim().toLowerCase(), archived: before?.archived ?? false }
const linux = (a?: Agent): boolean => !!a?.computer && a.computerKind !== 'mac'
const mac = (a?: Agent): boolean => !!a?.computer && a.computerKind === 'mac'
db.saveAgent(clean)
diff --git a/src/renderer/src/components/Onboarding.tsx b/src/renderer/src/components/Onboarding.tsx
index fe62afa..3664681 100644
--- a/src/renderer/src/components/Onboarding.tsx
+++ b/src/renderer/src/components/Onboarding.tsx
@@ -41,7 +41,7 @@ import {
isTeam
} from '../store'
import { HarnessList, ModelPicker, usableEngines } from './Harness'
-import { JevKey, LanguagePicker, ModelSelect, Toggle } from './Pages'
+import { ColorPicker, JevKey, LanguagePicker, ModelSelect, PicturePicker, Toggle } from './Pages'
import { Splash } from './Splash'
import { Composer, MessageList } from './Conversation'
import { draftAgent, UseDraft } from './Tuca'
@@ -146,8 +146,6 @@ const TEMPLATES = (): Template[] => [
// The introduction draws again when the language changes: the opening plays only once.
let opened = false
-const COLORS: AgentColor[] = ['sky', 'indigo', 'violet', 'rose', 'amber', 'green', 'teal', 'graphite']
-
const STEPS = ['welcome', 'engine', 'models', 'you', 'tools', 'skills', 'agent', 'powers', 'first'] as const
type Step = (typeof STEPS)[number]
// The builder screen (the Tuca, from the sidebar) is the introduction's last three steps.
@@ -165,7 +163,7 @@ const readyModels = (engines: State['settings']['engines']): typeof MODELS => MO
// A template fills in who the agent is; the model stays if it still works.
function fromTemplate(a: Agent, t: Template, models: typeof MODELS): Agent {
const model = MODELS.some((m) => m.id === a.modelId) ? (models.find((m) => m.id === a.modelId) ?? models[0]) : modelInfo(a.modelId) ? { id: a.modelId } : models[0]
- return { ...a, name: t.name, role: t.role, color: t.color, instructions: t.instructions, modelId: model?.id ?? a.modelId, web: true }
+ return { ...a, name: t.name, role: t.role, color: t.color, customColor: undefined, instructions: t.instructions, modelId: model?.id ?? a.modelId, web: true }
}
export function Onboarding({ build = false, from }: { build?: boolean; from?: View } = {}): ReactNode {
@@ -839,11 +837,11 @@ function MakeAgent(p: {
</div>
<div className="onb__field">
<span>{L('Cor', 'Color')}</span>
- <div className="swatches">
- {COLORS.map((c) => (
- <button key={c} className={`swatch c-${c} ${agent.color === c ? 'is-active' : ''}`} onClick={() => patch({ color: c })} aria-label={c} />
- ))}
- </div>
+ <ColorPicker agent={agent} patch={patch} />
+ </div>
+ <div className="onb__field">
+ <span>{L('Foto ou ícone', 'Photo or icon')}</span>
+ <PicturePicker agent={agent} patch={patch} />
</div>
<div className="onb__field">
<span>{L('Modelo', 'Model')}</span>
@@ -868,7 +866,7 @@ function AgentCard({ agent, handle, computer }: { agent: Agent; handle: string;
const first = agent.instructions.trim().split(/(?<=\.)\s/)[0]
return (
<div className="onb-card">
- <AgentAvatar agent={{ name, color: agent.color }} size={64} />
+ <AgentAvatar agent={{ ...agent, name }} size={64} />
<h2>{name}</h2>
<span className="muted">
@{handle}
@@ -885,7 +883,7 @@ function AgentCard({ agent, handle, computer }: { agent: Agent; handle: string;
<Power on={!!agent.browser} icon="pointer" label={L('Navegador', 'Browser')} />
</div>
<div className="onb-card__bubble">
- <AgentAvatar agent={{ name, color: agent.color }} size={22} />
+ <AgentAvatar agent={{ ...agent, name }} size={22} />
<p>
{L(`Oi! Eu sou ${agent.name.trim() ? `${agent.name.trim()}` : 'o seu agente'}.`, `Hi! I’m ${agent.name.trim() ? `${agent.name.trim()}` : 'your agent'}.`)}{first ? ` ${first}` : L(' Me diz o que eu faço e eu começo.', ' Tell me what I do and I’ll get started.')}
</p>
diff --git a/src/renderer/src/components/Pages.tsx b/src/renderer/src/components/Pages.tsx
index 8cada23..9a1fff5 100644
--- a/src/renderer/src/components/Pages.tsx
+++ b/src/renderer/src/components/Pages.tsx
@@ -1,5 +1,5 @@
import { L, locale, type Lang } from '../../../shared/lang'
-import { useEffect, useState, type ReactNode } from 'react'
+import { useEffect, useState, type CSSProperties, type ReactNode } from 'react'
import {
agentById,
navigate,
@@ -138,7 +138,63 @@ export function Sheet({
// ---------- Agent profile / creation ----------
+// A square of 128 px: enough for any place it shows.
+async function pictureFrom(file: File): Promise<string> {
+ const image = await createImageBitmap(file)
+ const side = Math.min(image.width, image.height)
+ const canvas = document.createElement('canvas')
+ canvas.width = canvas.height = 128
+ canvas.getContext('2d')!.drawImage(image, (image.width - side) / 2, (image.height - side) / 2, side, side, 0, 0, 128, 128)
+ image.close()
+ return canvas.toDataURL('image/webp', 0.85)
+}
+
const COLORS: AgentColor[] = ['sky', 'indigo', 'violet', 'rose', 'amber', 'green', 'teal', 'graphite']
+
+// The eight colors and one of the person's own, here and in the onboarding.
+export function ColorPicker({ agent, patch }: { agent: Pick<Agent, 'color' | 'customColor'>; patch: (p: Partial<Agent>) => void }): ReactNode {
+ return (
+ <div className="swatches">
+ {COLORS.map((c) => (
+ <button key={c} className={`swatch c-${c} ${!agent.customColor && agent.color === c ? 'is-active' : ''}`} onClick={() => patch({ color: c, customColor: undefined })} aria-label={c} />
+ ))}
+ <label className={`swatch swatch--custom ${agent.customColor ? 'is-active' : ''}`} style={agent.customColor ? ({ '--agent': agent.customColor } as CSSProperties) : undefined} title={L('Outra cor', 'Another color')}>
+ <input type="color" aria-label={L('Outra cor', 'Another color')} value={agent.customColor ?? '#888888'} onChange={(e) => patch({ customColor: e.target.value })} />
+ </label>
+ </div>
+ )
+}
+
+// A picture over the face, scaled down here; taken off the same way.
+export function PicturePicker({ agent, patch }: { agent: Pick<Agent, 'name' | 'color' | 'customColor' | 'picture'>; patch: (p: Partial<Agent>) => void }): ReactNode {
+ const [error, setError] = useState('')
+ return (
+ <>
+ <div className="row row--center">
+ <AgentAvatar agent={{ ...agent, name: agent.name || '?' }} size={40} />
+ <label className="btn btn--sm">
+ {L('Enviar imagem', 'Upload image')}
+ <input
+ type="file"
+ accept="image/png,image/jpeg,image/webp"
+ hidden
+ onChange={(e) => {
+ const file = e.target.files?.[0]
+ e.target.value = ''
+ if (file) pictureFrom(file).then((picture) => (setError(''), patch({ picture })), () => setError(L('Não consegui abrir essa imagem.', "I couldn't open that image.")))
+ }}
+ />
+ </label>
+ {agent.picture && (
+ <button type="button" className="btn btn--sm btn--ghost" onClick={() => patch({ picture: undefined })}>
+ {L('Tirar', 'Remove')}
+ </button>
+ )}
+ </div>
+ {error && <span className="field__error">{error}</span>}
+ </>
+ )
+}
const MEMORY_MODES = (): { value: MemoryMode; label: string; hint: string }[] => [
{ value: 'auto', label: L('Grava sozinho', 'Saves on its own'), hint: L('Guarda e avisa na mensagem, com Desfazer.', 'Keeps it and says so in the message, with Undo.') },
{ value: 'approve', label: L('Pede aprovação', 'Asks for approval'), hint: L('Cada memória nova espera você guardar.', 'Each new memory waits for you to keep it.') },
@@ -207,7 +263,7 @@ export function AgentPage({ id, draft: proposed, fromMessage }: { id?: string; d
<Page
title={
<span className="row row--center">
- <AgentAvatar agent={{ name: draft.name || '?', color: draft.color }} size={26} />
+ <AgentAvatar agent={{ ...draft, name: draft.name || '?' }} size={26} />
{isNew ? L('Novo agente', 'New agent') : draft.name}
</span>
}
@@ -269,16 +325,10 @@ export function AgentPage({ id, draft: proposed, fromMessage }: { id?: string; d
<input value={draft.role} placeholder={L('Ex.: Engenharia', 'E.g. Engineering')} onChange={(e) => patch({ role: e.target.value })} />
</Field>
<Field label={L('Cor', 'Color')}>
- <div className="swatches">
- {COLORS.map((c) => (
- <button
- key={c}
- className={`swatch c-${c} ${draft.color === c ? 'is-active' : ''}`}
- onClick={() => patch({ color: c })}
- aria-label={c}
- />
- ))}
- </div>
+ <ColorPicker agent={draft} patch={patch} />
+ </Field>
+ <Field label={L('Foto ou ícone', 'Photo or icon')}>
+ <PicturePicker agent={draft} patch={patch} />
</Field>
</Card>
)}
@@ -575,7 +625,7 @@ export function AgentPage({ id, draft: proposed, fromMessage }: { id?: string; d
<aside className="agent-side">
<div className="profile-card">
- <AgentAvatar agent={{ name: draft.name || '?', color: draft.color }} size={72} />
+ <AgentAvatar agent={{ ...draft, name: draft.name || '?' }} size={72} />
<strong className="profile-card__name">{draft.name || L('Sem nome', 'No name')}</strong>
<span className="muted">@{draft.handle || 'handle'}</span>
{draft.role && <span className="tag">{draft.role}</span>}
diff --git a/src/renderer/src/components/Panel.tsx b/src/renderer/src/components/Panel.tsx
index 00805e6..85ecd75 100644
--- a/src/renderer/src/components/Panel.tsx
+++ b/src/renderer/src/components/Panel.tsx
@@ -6,7 +6,7 @@ import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import { agentById, getState, openLightbox, artifactUrl, browserAction, browserInput, browserOf, reachable, windowless, computerOf, openExternal, openPanel, stopService, useStore, type Artifact } from '../store'
import { call } from '../rpc'
-import { Icon, type IconName } from './ui'
+import { Icon, ownColor, type IconName } from './ui'
const KIND_LABEL = (): Record<Artifact['kind'], string> => ({
image: L('Imagem', 'Image'),
@@ -169,7 +169,7 @@ function BrowserScreen({ agentId, onOpen }: { agentId: string; onOpen?: () => vo
<div className={`screen ${onOpen ? 'screen--button' : ''}`} onClick={onOpen} role={onOpen ? 'button' : undefined}>
<img className="screen__frame" src={view.frame} alt={view.title} draggable={false} />
{c && !view.shown && agent && (
- <span className={`screen__cursor c-${agent.color} ${live ? '' : 'is-idle'}`} style={{ left: `${c.x * 100}%`, top: `${c.y * 100}%` }}>
+ <span className={`screen__cursor c-${agent.color} ${live ? '' : 'is-idle'}`} style={{ ...ownColor(agent), left: `${c.x * 100}%`, top: `${c.y * 100}%` }}>
<i key={c.at} className="screen__ripple" />
<svg width="18" height="18" viewBox="0 0 24 24" aria-hidden>
<path d="m4 2 16 8-7 2-3 7L4 2Z" />
diff --git a/src/renderer/src/components/Routines.tsx b/src/renderer/src/components/Routines.tsx
index f8692cf..529140f 100644
--- a/src/renderer/src/components/Routines.tsx
+++ b/src/renderer/src/components/Routines.tsx
@@ -22,7 +22,7 @@ import {
isTeam
} from '../store'
import { Card, Field, Sheet, Toggle } from './Pages'
-import { AgentAvatar, Icon, shiftWeek, startOfWeek, weekRange } from './ui'
+import { AgentAvatar, Icon, ownColor, shiftWeek, startOfWeek, weekRange } from './ui'
const DAYS = (): string[] => (lang() === 'en' ? ['S', 'M', 'T', 'W', 'T', 'F', 'S'] : ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'])
const DAY_NAMES = (): string[] => (lang() === 'en' ? ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] : ['domingo', 'segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado'])
@@ -426,7 +426,7 @@ function Calendar({
<button
key={o.key}
className={`cal__ev ${o.upcoming ? '' : 'is-past'} ${live ? 'is-live' : ''} ${selected === o.key ? 'is-selected' : ''} ${only && only !== o.agentId ? 'is-dim' : ''} c-${a?.color ?? 'graphite'}`}
- style={{ top }}
+ style={{ ...(a ? ownColor(a) : {}), top }}
title={`${hm(o.at)} · ${o.name}`}
onMouseEnter={() => setGhost(null)}
onClick={(e) => onPick(o, e.currentTarget.getBoundingClientRect())}
diff --git a/src/renderer/src/components/Sidebar.tsx b/src/renderer/src/components/Sidebar.tsx
index f6b06e9..3941b0b 100644
--- a/src/renderer/src/components/Sidebar.tsx
+++ b/src/renderer/src/components/Sidebar.tsx
@@ -15,6 +15,7 @@ import {
shortcut,
updateSettings,
useStore,
+ type Agent,
type View
} from '../store'
import { ContextMenu, type MenuItem, type MenuState } from './Dialogs'
@@ -183,7 +184,7 @@ export function Sidebar(): ReactNode {
if (!agent) return null
return (
<div key={c.id} onContextMenu={(e) => open(e, dmMenu(c.id, agent.id, agent.name))}>
- <DmItem id={c.id} name={agent.name} color={agent.color} unread={c.unread} />
+ <DmItem id={c.id} agent={agent} unread={c.unread} />
</div>
)
})}
@@ -241,12 +242,13 @@ function ChannelItem({ id, name, unread }: { id: string; name: string; unread?:
)
}
-function DmItem({ id, name, color, unread }: { id: string; name: string; color: Parameters<typeof AgentAvatar>[0]['agent']['color']; unread?: number }): ReactNode {
+function DmItem({ id, agent, unread }: { id: string; agent: Agent; unread?: number }): ReactNode {
+ const name = agent.name
const active = useStore((s) => s.view?.kind === 'conversation' && s.view.id === id)
const working = useStore((s) => s.messages.some((m) => m.conversationId === id && m.run?.status === 'working'))
return (
<button className={`nav-item ${active ? 'is-active' : ''} ${unread ? 'is-unread' : ''}`} onClick={() => navigate({ kind: 'conversation', id })}>
- <AgentAvatar agent={{ name, color }} size={18} busy={working} />
+ <AgentAvatar agent={agent} size={18} busy={working} />
<span className="nav-item__label">{name}</span>
{working && <span className="pulse" title={L('Trabalhando', 'Working')} />}
{unread ? <span className="badge badge--soft">{unread}</span> : null}
diff --git a/src/renderer/src/components/Usage.tsx b/src/renderer/src/components/Usage.tsx
index 55859cc..8ef7dfd 100644
--- a/src/renderer/src/components/Usage.tsx
+++ b/src/renderer/src/components/Usage.tsx
@@ -30,7 +30,7 @@ const shortTime = (at: number): string => {
// The app's own turns go under one name; agents keep theirs.
function whoOf(id: string, agents: Agent[]): { key: string; name: string; color: string } {
const a = agents.find((x) => x.id === id)
- if (a && isTeam(a)) return { key: a.id, name: a.name, color: `var(--c-${a.color})` }
+ if (a && isTeam(a)) return { key: a.id, name: a.name, color: a.customColor ?? `var(--c-${a.color})` }
return { key: APP, name: L('Bastidores', 'Behind the scenes'), color: 'var(--text-3)' }
}
diff --git a/src/renderer/src/components/ui.tsx b/src/renderer/src/components/ui.tsx
index 006a646..da56c7f 100644
--- a/src/renderer/src/components/ui.tsx
+++ b/src/renderer/src/components/ui.tsx
@@ -1,5 +1,5 @@
import { L, lang, locale } from '../../../shared/lang'
-import { useState, type InputHTMLAttributes, type ReactNode } from 'react'
+import { useState, type CSSProperties, type InputHTMLAttributes, type ReactNode } from 'react'
import type { Agent } from '../store'
const PATHS: Record<string, ReactNode> = {
@@ -175,15 +175,22 @@ export function SleepingToucan({ size = 120 }: { size?: number }): ReactNode {
)
}
+// An agent's own color, over its class's, wherever the agent's color shows.
+export const ownColor = (agent: Partial<Pick<Agent, 'customColor'>>): CSSProperties => (agent.customColor ? ({ '--agent': agent.customColor } as CSSProperties) : {})
+
// busy: the eyes read, left to right, while the agent works. Otherwise they blink now and then.
-export function AgentAvatar({ agent, size = 32, busy }: { agent: Pick<Agent, 'name' | 'color'> & Partial<Pick<Agent, 'kind'>>; size?: number; busy?: boolean }): ReactNode {
+export function AgentAvatar({ agent, size = 32, busy }: { agent: Pick<Agent, 'name' | 'color'> & Partial<Pick<Agent, 'kind' | 'customColor' | 'picture'>>; size?: number; busy?: boolean }): ReactNode {
if (agent.kind === 'tuca') return <TucaMark size={size} />
return (
- <span className={`avatar avatar--agent c-${agent.color} ${busy ? 'is-busy' : ''}`} style={{ width: size, height: size, fontSize: size * 0.42 }}>
- <span className="avatar__eyes" aria-hidden>
- <i />
- <i />
- </span>
+ <span className={`avatar avatar--agent c-${agent.color} ${busy ? 'is-busy' : ''}`} style={{ width: size, height: size, fontSize: size * 0.42, ...ownColor(agent) }}>
+ {agent.picture ? (
+ <img className="avatar__photo" src={agent.picture} alt="" />
+ ) : (
+ <span className="avatar__eyes" aria-hidden>
+ <i />
+ <i />
+ </span>
+ )}
<span className="sr-only">{agent.name}</span>
</span>
)
diff --git a/src/renderer/src/styles.css b/src/renderer/src/styles.css
index acfb5d7..bf6ff78 100644
--- a/src/renderer/src/styles.css
+++ b/src/renderer/src/styles.css
@@ -6598,3 +6598,26 @@ kbd {
[data-os='mac'] .lightbox__bar {
padding-left: 84px; /* the window's buttons are here */
}
+
+/* An agent's own color and picture */
+.avatar__photo {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+}
+.swatch--custom {
+ position: relative;
+ overflow: hidden;
+ cursor: pointer;
+ background: var(--agent, conic-gradient(#e5484d, #f5a524, #30a46c, #0091ff, #8e4ec6, #e5484d));
+}
+.swatch--custom input {
+ position: absolute;
+ inset: 0;
+ opacity: 0;
+ cursor: pointer;
+}
+.swatch--custom.is-active {
+ overflow: visible;
+}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 0e4e90c..b4ceaab 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -55,6 +55,8 @@ export interface Agent {
handle: string
role: string
color: AgentColor
+ customColor?: string // a color of the person's own (#rrggbb), over `color`
+ picture?: string // a small picture (data URL), over the face
instructions: string
modelId: string
// Where a reply goes when modelId's subscription is out (its 5-hour or weekly limit, a 429): tried
diff --git a/test/agent-look.test.ts b/test/agent-look.test.ts
new file mode 100644
index 0000000..1019587
--- /dev/null
+++ b/test/agent-look.test.ts
@@ -0,0 +1,13 @@
+import { describe, expect, it } from 'vitest'
+import { cleanLook } from '../src/core/agent-look'
+
+describe('an agent’s color and picture', () => {
+ it('keeps a color and a small picture', () => {
+ const look = { customColor: '#FF00aa', picture: 'data:image/jpeg;base64,AAAA' }
+ expect(cleanLook(look)).toEqual(look)
+ })
+ it('drops anything else', () => {
+ for (const customColor of ['red', '#fff', '#ff00aa;background:url(x)']) expect(cleanLook({ customColor }).customColor).toBeUndefined()
+ for (const picture of ['https://x.com/a.png', 'data:image/svg+xml;base64,AAAA', 'data:image/png;base64,AA"><script>', `data:image/png;base64,${'A'.repeat(200_001)}`]) expect(cleanLook({ picture }).picture).toBeUndefined()
+ })
+})