Astra: PO/GL actions, usage coverage, assisted sign-in, self-healing, recorder, new top navigation and theme (172a4e22a2bf)
fb62a97 verified Download web/src/components/GraphView.tsx from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 3.82 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/GraphView.tsx
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/components/GraphView.tsx
-
curl -L -o GraphView.tsx https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/GraphView.tsx
3.82 kB
| import { Text } from '@mantine/core'; | |
| import { AGENT_BY_NODE, ENGINE_LABEL, ENGINE_TONE, ENGINE_WORDS, stepName } from '../domain/agents'; | |
| import type { NodeState } from '../hooks/useRunStream'; | |
| import { Pill } from './common'; | |
| // Order of the co-worker graph (coworker/graph/build.py), shown as the vertical "workflow" of step cards. | |
| export const LAYOUT: { phase: string; nodes: string[] }[] = [ | |
| { phase: 'Research', nodes: ['scout', 'research_module', 'synthesizer'] }, | |
| { phase: 'Design', nodes: ['test_generator', 'approval_gate'] }, | |
| { phase: 'Data + scripts', nodes: ['data_planner', 'data_executor', 'script_builder'] }, | |
| { phase: 'Execute', nodes: ['sign_in_gate', 'executor', 'self_heal'] }, | |
| { phase: 'Triage', nodes: ['triage', 'human_review', 'ticket'] }, | |
| { phase: 'Report', nodes: ['reporter', 'learner'] }, | |
| ]; | |
| const STATE_TONE: Record<NodeState, string> = { pending: 'neutral', running: 'ink', done: 'green', error: 'red', waiting: 'amber', skipped: 'neutral' }; | |
| const STATE_LABEL: Record<NodeState, string> = { pending: 'pending', running: 'running', done: 'done', error: 'failed', waiting: 'waiting for you', skipped: 'skipped' }; | |
| type States = Record<string, { state: NodeState; count: number; modules: string[] }>; | |
| /** Vertical workflow: one step card per node, dashed connectors, live state pill. `states` omitted = design view. */ | |
| export function GraphView({ states, compact = false, nowFor }: { states?: States; compact?: boolean; nowFor?: (node: string) => { words?: string; connected: boolean } }) { | |
| return ( | |
| <div role="list" aria-label="graph nodes"> | |
| {LAYOUT.flatMap((col) => col.nodes.map((n, i) => ({ n, phase: i === 0 ? col.phase : null }))).map(({ n, phase }) => { | |
| const a = AGENT_BY_NODE[n]; | |
| const s = states?.[n] ?? { state: 'pending' as NodeState, count: 0, modules: [] }; | |
| return ( | |
| <div key={n}> | |
| {phase && !compact && <Text className="fpt-tree-title" mt={10} mb={4}>{phase}</Text>} | |
| <div role="listitem" aria-label={`${n} ${s.state}`} data-testid={`node-${n}`} data-state={s.state} | |
| className={`fpt-card fpt-step${s.state === 'running' ? ' fpt-live' : ''}`} | |
| style={{ opacity: s.state === 'skipped' ? 0.55 : 1, borderStyle: s.state === 'skipped' ? 'dashed' : 'solid', | |
| borderColor: s.state === 'waiting' ? 'var(--pill-amber-fg)' : s.state === 'running' ? 'var(--pill-ink-fg)' : undefined }}> | |
| <div style={{ display: 'flex', alignItems: 'center', gap: 8, justifyContent: 'space-between' }}> | |
| <span style={{ display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 }}> | |
| <span className="fpt-dot" style={{ background: `var(--pill-${a?.tone ?? 'neutral'}-fg)` }} aria-hidden /> | |
| <Text size="sm" fw={600} truncate title={`graph node: ${n}`}>{compact ? stepName(n) : a?.name ?? n}</Text> | |
| {s.count > 1 && <Pill tone="lav">x{s.count}</Pill>} | |
| </span> | |
| {states ? <Pill tone={STATE_TONE[s.state]}>{STATE_LABEL[s.state]}</Pill> | |
| : a && (() => { | |
| // design view: the pill is the engine the agent is designed for; the tooltip says what serves it now | |
| const now = nowFor?.(n); | |
| const tip = `Designed for: ${ENGINE_WORDS[a.engine]}.${now?.words ? ` ${now.words}.` : ''} (technical: ${ENGINE_LABEL[a.engine]})`; | |
| return <Pill tone={ENGINE_TONE[a.engine]} outline={!!now && !now.connected} title={tip}>{ENGINE_WORDS[a.engine]}</Pill>; | |
| })()} | |
| </div> | |
| {!compact && s.modules.length > 0 && <Text size="xs" c="dimmed" mt={4}>workers: {s.modules.join(', ')}</Text>} | |
| </div> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| ); | |
| } | |