Download web/src/components/CoworkerCard.tsx from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.54 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/CoworkerCard.tsx
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/components/CoworkerCard.tsx
-
curl -L -o CoworkerCard.tsx https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/CoworkerCard.tsx
2.54 kB
| 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<CoworkerState, { words: string; tone: string }> = { | |
| 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 = ( | |
| <> | |
| <span className="cw-card-head pw-hatch-diag" aria-hidden /> | |
| <span className="pw-status cw-card-state" data-variant="outline" data-tone={s.tone}>{s.words}</span> | |
| <CoworkerAvatar name={c.name} size={52} working={state === 'working'} /> | |
| <span className="cw-card-name">{c.name}</span> | |
| <span className="cw-card-role">{c.role}</span> | |
| <span className="cw-card-job">{c.job}</span> | |
| </> | |
| ); | |
| if (!onOpen && !linked) return <div className="cw-card" data-state={state} data-static data-testid={`coworker-${c.key}`}>{body}</div>; | |
| return onOpen | |
| ? <button type="button" className="cw-card" data-state={state} aria-pressed={pressed} onClick={onOpen} data-testid={`coworker-${c.key}`}>{body}</button> | |
| : <Link to="/agents" className="cw-card" data-state={state} data-testid={`coworker-${c.key}`}>{body}</Link>; | |
| } | |
| /** 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 ( | |
| <div className="cw-grid" role="region" aria-label={label} tabIndex={0}> | |
| {COWORKERS.map((c) => ( | |
| <CoworkerCard key={c.key} c={c} state={coworkerState(c, items)} pressed={onOpen ? selected === c.key : undefined} onOpen={onOpen ? () => onOpen(c) : undefined} linked={can('admin')} /> | |
| ))} | |
| </div> | |
| ); | |
| } | |