import { ArrowRight, FileText } from "lucide-react"; import { Handle, Position, type NodeProps } from "@xyflow/react"; import type { CanvasNodeData } from "@/lib/layout"; import type { AgentDecisionProjection, CanvasItem } from "@/lib/types"; import { CardFields } from "@/components/flow/CardFields"; import { SourceComparisonButton } from "@/components/flow/SourceComparisonButton"; export function AgentDecisionCard({ data }: NodeProps) { const node = data as unknown as CanvasNodeData; const item = node.item; if (!item) return null; const decision = decisionFor(item); if (!decision) return null; return
{ if (event.target !== event.currentTarget) return; if (event.key === "Enter" || event.key === " ") { event.preventDefault(); node.onOpen(item, "business"); } }} >
{decision.actor.label} {decisionTypeLabel(decision.decisionType)}
{authorityLabel(decision.authority)}

{item.title}

; } export function decisionFor(item: CanvasItem): AgentDecisionProjection | undefined { if (item.itemType === "story") return item.decision; if (item.itemType === "multipath-review") return item.review.decisionProjection; if (item.itemType === "multipath-decision") return item.decision.decisionProjection; return undefined; } function actorTone(decision: AgentDecisionProjection) { if (decision.actor.role === "main") return "main"; if (decision.actor.role === "implementer") return "implementer"; return "evaluator"; } export const authorityLabel = (authority: AgentDecisionProjection["authority"]) => ({ final: "最终决定", recommendation: "评审建议", "implementation-scope": "本方案内有效" } as const)[authority]; export const decisionTypeLabel = (type: AgentDecisionProjection["decisionType"]) => ({ direction: "方向决定", tradeoff: "取舍决定", evaluation: "评审判断", creative: "创作处理" } as const)[type];