import { Paperclip, MessageSquare, Upload } from "lucide-react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; import { Button } from "@/components/ui/button"; import { useRef } from "react"; interface FileAttachmentDropdownProps { onFileSelect: ( files: FileList, type: "chat-context" | "upload-to-codebase", ) => void; disabled?: boolean; className?: string; } export function FileAttachmentDropdown({ onFileSelect, disabled, className, }: FileAttachmentDropdownProps) { const chatContextFileInputRef = useRef(null); const uploadToCodebaseFileInputRef = useRef(null); const handleChatContextClick = () => { chatContextFileInputRef.current?.click(); }; const handleUploadToCodebaseClick = () => { uploadToCodebaseFileInputRef.current?.click(); }; const handleFileChange = ( e: React.ChangeEvent, type: "chat-context" | "upload-to-codebase", ) => { if (e.target.files && e.target.files.length > 0) { onFileSelect(e.target.files, type); // Clear the input value so the same file can be selected again e.target.value = ""; } }; return ( <> Attach file as chat context Example use case: screenshot of the app to point out a UI issue Upload file to codebase Example use case: add an image to use for your app Attach files {/* Hidden file inputs */} handleFileChange(e, "chat-context")} className="hidden" multiple accept=".jpg,.jpeg,.png,.gif,.webp,.txt,.md,.js,.ts,.html,.css,.json,.csv" /> handleFileChange(e, "upload-to-codebase")} className="hidden" multiple accept=".jpg,.jpeg,.png,.gif,.webp,.txt,.md,.js,.ts,.html,.css,.json,.csv" /> ); }