import React, { useEffect, useRef } from 'react'; const ACTION_CONFIG = { reply: { icon: '↩', color: '#3b82f6', label: 'Reply' }, schedule: { icon: '📅', color: '#8b5cf6', label: 'Schedule' }, delegate: { icon: '→', color: '#f97316', label: 'Delegate' }, ignore: { icon: '✕', color: '#64748b', label: 'Ignore' }, }; const PRIORITY_COLORS = { 5: '#ef4444', 4: '#f59e0b', 3: '#eab308', 2: '#22c55e', 1: '#94a3b8' }; export default function TimelinePanel({ history }) { const endRef = useRef(null); useEffect(() => { endRef.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'end' }); }, [history.length]); return (
📊 Action Timeline {history.length} actions
{history.length === 0 ? (
No actions yet — click Watch AI Play or select an email above
) : (
{history.map((entry, i) => { const cfg = ACTION_CONFIG[entry.action] || ACTION_CONFIG.ignore; const positive = entry.reward >= 0; const isLast = i === history.length - 1; return (
{/* Connector line */} {i > 0 &&
} {/* Step badge */}
{entry.step + 1}
{/* Card */}
{entry.time} {cfg.icon} {cfg.label} {positive ? '+' : ''}{entry.reward.toFixed(3)}
{entry.email_subject}
); })}
)}
); }