import { num, timeAgo } from "../lib/format"; type Intent = { id: number; ts: string; strategy: string; symbol: string; side: string; qty: number; order_type: string; limit_price: number | null; trail_percent: number | null; details_json: string; submitted: number; alpaca_order_id: string | null; status: string | null; }; function statusTone(status: string | null, submitted: number): string { if (status === "blocked") return "text-down"; if (status === "error") return "text-down"; if (submitted) return "text-up"; if (status === "dry_run") return "text-mute"; return "text-warn"; } export function IntentsTable({ intents }: { intents: Intent[] }) { if (!intents.length) return (
No strategy intents recorded yet. Run the bot once: alpaclaudia tick.
); return (
Bot intents (latest 200)
{intents.length}
{intents.map((i) => { let rationale = ""; let blockedReason = ""; try { const d = JSON.parse(i.details_json || "{}"); rationale = d.rationale || ""; blockedReason = d.blocked_reason || d.error || ""; } catch {} const tone = statusTone(i.status, i.submitted); return ( ); })}
When Strategy Symbol Side Type Qty Outcome Rationale
{timeAgo(i.ts)} {i.strategy} {i.symbol} {i.side} {i.order_type} {num(i.qty, 0)} {i.status || (i.submitted ? "submitted" : "pending")} {rationale} {blockedReason && (
blocked: {blockedReason}
)}
); }