import { useState, useEffect } from 'react' import { PlayCircle, AlertCircle } from 'lucide-react' import { getTasks, getModels, runEpisode } from '../api/client' import { SOCChart, ArbitrageChart, FreqRegChart, PeakShavingChart, RewardChart } from '../components/EpisodeCharts' export default function RunEpisode() { const [tasks, setTasks] = useState([]) const [models, setModels] = useState([]) const [form, setForm] = useState({ task: 'hard', model_name: '', seed: 42 }) const [running, setRunning] = useState(false) const [result, setResult] = useState(null) const [error, setError] = useState(null) useEffect(() => { Promise.all([getTasks(), getModels()]).then(([t, m]) => { setTasks(t); setModels(m) if (m.length) setForm(f => ({ ...f, model_name: m.find(x => x.includes('hard')) || m[0] })) }) }, []) const onSubmit = async (e) => { e.preventDefault() setRunning(true); setError(null); setResult(null) try { const res = await runEpisode(form) setResult(res) } catch (err) { setError(err.response?.data?.detail || err.message) } finally { setRunning(false) } } return ( <>

Run Episode

Visualize step-by-step agent decisions on a single scenario.

{/* Controls */}
Configuration
setForm({ ...form, seed: parseInt(e.target.value) || 0 })} />
{/* Results Area */}
{error && (
Error running simulation: {error}
)} {running && (
Environment step processing in progress...
)} {result && !running && ( <>
Total Episode Reward ${result.total_reward.toLocaleString(undefined,{maximumFractionDigits:0})}
{result.task.toUpperCase()}
{result.steps.length} Steps
{['medium', 'hard'].includes(result.task) && } {result.task === 'hard' && }
)} {!result && !running && !error && (

No simulation data

Configure the scenario on the left and click Execute to visualize.

)}
) }