import React, { useState } from 'react' import type { Observation, Task } from '../types' import { panelStyle, titleStyle } from '../App' interface Props { tasks: Task[] activeTask: string onSelect: (id: string) => void onReset: (id: string) => void loading: boolean obs: Observation | null } const diffColor = (d: string) => d === 'easy' ? '#22c55e' : d === 'medium' ? '#f59e0b' : d === 'medium-hard' ? '#f97316' : '#ef4444' const diffLabel = (d: string) => d === 'easy' ? '๐ŸŸข' : d === 'medium' ? '๐ŸŸก' : d === 'medium-hard' ? '๐ŸŸ ' : '๐Ÿ”ด' export function TaskSelector({ tasks, activeTask, onSelect, onReset, loading, obs }: Props) { const [judgeRunning, setJudgeRunning] = useState(false) const [judgeResult, setJudgeResult] = useState(null) const runJudge = async () => { setJudgeRunning(true) setJudgeResult(null) try { const r = await fetch('/judge/run_all', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ seed: 42 }), }) const data = await r.json() const avg = (data.avg_score * 100).toFixed(1) const verdict = data.verdict || '' const lines = [`avg: ${avg}% โ€” ${verdict.slice(0, 60)}`] for (const [tid, td] of Object.entries(data.tasks || {})) { const score = ((td as Record).score * 100).toFixed(0) lines.push(`${tid.replace('_', ' ')}: ${score}%`) } setJudgeResult(lines.join('\n')) } catch (e) { setJudgeResult(`Error: ${e}`) } finally { setJudgeRunning(false) } } return (
๐ŸŽฏ Tasks
{tasks.map(t => (
onSelect(t.id)} style={{ padding: '0.6rem 0.75rem', borderRadius: '0.5rem', cursor: 'pointer', marginBottom: '0.4rem', transition: 'all 0.15s', border: `1px solid ${activeTask === t.id ? diffColor(t.difficulty) + '66' : '#1e2d4a'}`, background: activeTask === t.id ? diffColor(t.difficulty) + '12' : 'transparent', borderLeft: `3px solid ${diffColor(t.difficulty)}`, }}>
{diffLabel(t.difficulty)} {t.name}
{t.description}
max {t.max_steps} steps ยท {t.difficulty}
))} {/* Judge Evaluation Button */} {judgeResult && (
            {judgeResult}
          
โ†’ Full JSON result โ†—
)}
) }