import React from 'react'; import { ChevronRight, Zap, RefreshCw, CheckCircle2, AlertCircle, } from 'lucide-react'; function pretty(val) { if (val == null || val === '') return '(empty)'; if (typeof val === 'object') { try { return JSON.stringify(val, null, 2); } catch { return String(val); } } try { return JSON.stringify(JSON.parse(val), null, 2); } catch { return String(val); } } export default function StepCard({ step, isRunning, isRunningAll, res, onExecute }) { const status = res?.analysis?.status; const stateClass = status === 'success' ? ' is-ok' : status === 'failed' ? ' is-err' : isRunning ? ' is-running' : ''; // endpoint is "METHOD /path" — split out method and path for display const endpointParts = (step.endpoint || '').trim().split(/\s+/); const method = endpointParts.length >= 2 ? endpointParts[0].toUpperCase() : ''; const endpointPath = endpointParts.length >= 2 ? endpointParts.slice(1).join(' ') : step.endpoint; return (
{status === 'success' ? : status === 'failed' ? : isRunning ? : step.step}
{method && {method}} {endpointPath} {isRunning && running}
{step.purpose}
{res?.token_usage && ( {res.token_usage.total_tokens.toLocaleString()} tok )} {res?.response?.status_code !== undefined && ( = 200 && res.response.status_code < 300 ? 'pill-ok' : res.response.status_code >= 400 ? 'pill-err' : 'pill-warn'}`}> {res.response.status_code} )} {status === 'failed' && ( )}
{res && (
analysis
{res.analysis.response_summary || (status === 'success' ? 'Step completed successfully.' : status === 'failed' ? 'Step encountered an error.' : 'Analyzing…')} {res.analysis.extracted_variables && Object.keys(res.analysis.extracted_variables).length > 0 && (
{Object.entries(res.analysis.extracted_variables).map(([k, v]) => ( {k} = {String(v).slice(0, 60)} ))}
)}
Request
{!res.request ? (
Preparing…
) : (
URL {res.request.url}
{res.request.headers && Object.keys(res.request.headers).filter(k => k.toLowerCase() !== 'cookie').length > 0 && ( <> Headers
{Object.entries(res.request.headers).filter(([k]) => k.toLowerCase() !== 'cookie').map(([k, v]) => (
{k}:{v}
))}
)} {res.request.query_params && Object.keys(res.request.query_params).length > 0 && ( <> Query
{Object.entries(res.request.query_params).map(([k, v]) => (
{k}={v}
))}
)} {res.request.body != null && ( <> Body
{pretty(res.request.body)}
)} {res.request.form_data && Object.keys(res.request.form_data).length > 0 && ( <> Form data
{JSON.stringify(res.request.form_data, null, 2)}
)}
)}
Response
{!res.response ? (
Waiting…
) : ( <>
{pretty(res.response.body)}
)}
)}
); }