"use client"; import { memo, useState, useCallback } from "react"; import { IconFile, IconPhoto } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Dialog, DialogContent } from "@kandev/ui/dialog"; import type { ImageContextItem } from "@/lib/types/context"; import { IMAGE_PREVIEW_DIALOG_CONTENT_CLASSNAME, ImagePreviewContent, } from "@/components/task/chat/image-preview-dialog"; import { ContextChip } from "./context-chip"; export const ImageItem = memo(function ImageItem({ item }: { item: ImageContextItem }) { const [dialogOpen, setDialogOpen] = useState(false); const previewSrc = item.attachment.preview; const deliveryMode = item.attachment.deliveryMode; const deliveryDescription = deliveryMode === "path" ? "Upload into the workspace so the agent can read or edit the file." : "Send as prompt context for visual understanding. The agent will not get a file path."; let leadingIcon; const handleClick = useCallback(() => { setDialogOpen(true); }, []); const preview = previewSrc ? (
Preview {item.onDeliveryModeChange && (

{deliveryDescription}

)}
) : undefined; if (deliveryMode === "path") { leadingIcon = ( ); } else if (!previewSrc) { leadingIcon = ; } return ( <> {previewSrc && ( )} ); });