import { useRef, type ReactNode } from "react"; import { Button, Tooltip } from "antd"; import { ArrowUp, ImagePlus, LoaderCircle, Square, X } from "lucide-react"; import { canvasThemes } from "@/lib/canvas-theme"; import { isPlainEnterKey } from "@/lib/keyboard-event"; import type { AgentChatAttachment } from "./agent-chat-message"; export function AgentChatComposer({ prompt, attachments = [], disabled, sending, placeholder, theme, onPromptChange, onSubmit, onStop, onAddFiles, onRemoveAttachment, left, }: { prompt: string; attachments?: AgentChatAttachment[]; disabled?: boolean; sending?: boolean; placeholder: string; theme: (typeof canvasThemes)[keyof typeof canvasThemes]; onPromptChange: (value: string) => void; onSubmit: () => void; onStop?: () => void; onAddFiles?: (files: FileList | File[] | null) => void | Promise; onRemoveAttachment?: (id: string) => void; left?: ReactNode; }) { const fileInputRef = useRef(null); const canSubmit = !disabled && !sending && Boolean(prompt.trim() || attachments.length); return (
event.stopPropagation()}>
{attachments.length ? (
{attachments.map((item) => (
{item.name} {onRemoveAttachment ? ( ) : null}
))}
) : null}