import { useEffect, useRef, useState } from "react"; import { LoaderCircle, MoreHorizontal, Pencil, X } from "lucide-react"; import { Button } from "@/shared/ui/button"; import { cn } from "@/shared/ui/cn"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/shared/ui/dropdown-menu"; import type { AgentInputDelivery, AgentResponseInput } from "../api/client"; import type { AgentCommandPanelPresentation } from "./agent-command-panel"; type AgentPendingInputsProps = { presentation: AgentCommandPanelPresentation; inputs: AgentResponseInput[]; onDeliveryChange?: (id: string, delivery: AgentInputDelivery) => Promise | void; onEdit?: (id: string) => Promise | void; onCancel?: (id: string) => Promise | void; }; const menuItemClassName = "min-h-10 rounded-lg border border-transparent px-2.5 py-2 text-xs focus:border-[var(--action-border-hover)] focus:bg-[var(--action-selection-soft-hover)] data-[highlighted]:border-[var(--action-border-hover)] data-[highlighted]:bg-[var(--action-selection-soft-hover)]"; export function AgentPendingInputs({ presentation, inputs, onDeliveryChange, onEdit, onCancel }: AgentPendingInputsProps) { const [busyId, setBusyId] = useState(null); const listRef = useRef(null); const latestId = inputs.at(-1)?.id; useEffect(() => { const list = listRef.current; if (list) list.scrollTop = list.scrollHeight; }, [latestId]); const performAction = (id: string, action: () => Promise | void) => { setBusyId(id); void Promise.resolve().then(action).catch(() => {}).finally(() => setBusyId(null)); }; if (!inputs.length) return null; return (

等待处理 {inputs.length}

    {inputs.map((input) => (
  • {input.delivery === "queue" ? "排队" : "引导"} performAction(input.id, () => onEdit?.(input.id))}> 编辑消息 处理方式 { if (onDeliveryChange && (delivery === "steer" || delivery === "queue")) { void Promise.resolve().then(() => onDeliveryChange(input.id, delivery)).catch(() => {}); } }}> 引导当前任务 排队处理 performAction(input.id, () => onCancel?.(input.id))}> 关闭排队
  • ))}
); } function PendingInputText({ text }: { text: string }) { const [expanded, setExpanded] = useState(false); const [overflows, setOverflows] = useState(false); const textRef = useRef(null); useEffect(() => { const node = textRef.current; if (!node) return; const measure = () => { setOverflows(node.scrollHeight > Number.parseFloat(getComputedStyle(node).lineHeight) * 2 + 1); }; const observer = new ResizeObserver(measure); observer.observe(node); measure(); return () => observer.disconnect(); }, [text]); useEffect(() => { if (expanded) textRef.current?.parentElement?.scrollIntoView({ block: "nearest" }); }, [expanded]); return (

{text}

{overflows ? : null}
); }