import { useState } from 'react'; import { Button } from '@/components/ui/Button'; import { Badge } from '@/components/ui/Codex'; import type { DirectorAction } from '@/lib/assistant/director'; import { actionSummary } from './actionSummary'; import type { ApplyResult } from './useDirectorAction'; /** * A proposed state change. Approve-each: it only mutates the game when the human * clicks Apply, which routes through the rules kernel. If no `onApply` is given it * renders as a passive preview. */ export function ActionCard({ action, onApply, }: { action: DirectorAction; onApply?: (a: DirectorAction) => Promise; }) { const [busy, setBusy] = useState(false); const [result, setResult] = useState(null); const apply = async () => { if (!onApply) return; setBusy(true); try { setResult(await onApply(action)); } finally { setBusy(false); } }; return (
{result ? (result.ok ? 'applied' : 'skipped') : 'change'} {actionSummary(action)} {onApply && !result && ( )}
{result && !result.ok &&

{result.message}

}
); }