import './coworkers.css'; import { Link } from 'react-router-dom'; import { useRuns } from '../api/hooks'; import { useAuth } from '../auth/AuthContext'; import { COWORKERS, coworkerState, type Coworker, type CoworkerState } from '../domain/coworkers'; import { CoworkerAvatar } from './CoworkerAvatar'; const STATE: Record = { working: { words: 'Working', tone: 'blue' }, waiting: { words: 'Waiting for you', tone: 'orange' }, available: { words: 'Available', tone: 'neutral' }, }; /** One AI coworker: face, name, role, what it does, and what it is doing now. Opens the Agent team page (admins), or, * when `onOpen` is given (on that page), selects the coworker there; for everyone else it is a plain card. */ export function CoworkerCard({ c, state, onOpen, pressed, linked = true }: { c: Coworker; state: CoworkerState; onOpen?: () => void; pressed?: boolean; linked?: boolean }) { const s = STATE[state]; const body = ( <> {s.words} {c.name} {c.role} {c.job} ); if (!onOpen && !linked) return
{body}
; return onOpen ? : {body}; } /** The whole AI team with live states (from the latest test runs). */ export function CoworkerGrid({ selected, onOpen, label = 'Your AI team' }: { selected?: string; onOpen?: (c: Coworker) => void; label?: string }) { const runs = useRuns(40, 0); const { can } = useAuth(); const items = runs.data?.items ?? []; return (
{COWORKERS.map((c) => ( onOpen(c) : undefined} linked={can('admin')} /> ))}
); }