From 25b247354f0c25fed87f82513122e5fb7ceadcce Mon Sep 17 00:00:00 2001 From: starmorph Date: Mon, 19 May 2025 20:52:38 -0700 Subject: [PATCH] CR: cn utility, refactor accepted files, nextImage --- .../thread/ContentBlocksPreview.tsx | 9 +++- src/components/thread/messages/human.tsx | 4 +- src/components/ui/MultimodalPreview.tsx | 45 +++++++++++-------- src/hooks/use-file-upload.tsx | 7 +-- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/components/thread/ContentBlocksPreview.tsx b/src/components/thread/ContentBlocksPreview.tsx index 1c1caa0..0ee6664 100644 --- a/src/components/thread/ContentBlocksPreview.tsx +++ b/src/components/thread/ContentBlocksPreview.tsx @@ -1,6 +1,7 @@ import React from "react"; import type { Base64ContentBlock } from "@langchain/core/messages"; import { MultimodalPreview } from "../ui/MultimodalPreview"; +import { cn } from "@/lib/utils"; interface ContentBlocksPreviewProps { blocks: Base64ContentBlock[]; @@ -9,15 +10,19 @@ interface ContentBlocksPreviewProps { className?: string; } +/** + * Renders a preview of content blocks with optional remove functionality. + * Uses cn utility for robust class merging. + */ export const ContentBlocksPreview: React.FC = ({ blocks, onRemove, size = "md", - className = "", + className, }) => { if (!blocks.length) return null; return ( -
+
{blocks.map((block, idx) => ( )} {/* Render text if present, otherwise fallback to file/image name */} - {contentString && - contentString !== "Other" && - contentString !== "Multimodal message" ? ( + {contentString ? (

{contentString}

diff --git a/src/components/ui/MultimodalPreview.tsx b/src/components/ui/MultimodalPreview.tsx index 714ec91..369b485 100644 --- a/src/components/ui/MultimodalPreview.tsx +++ b/src/components/ui/MultimodalPreview.tsx @@ -1,7 +1,8 @@ import React from "react"; import { File, Image as ImageIcon, X as XIcon } from "lucide-react"; import type { Base64ContentBlock } from "@langchain/core/messages"; - +import { cn } from "@/lib/utils"; +import Image from "next/image"; export interface MultimodalPreviewProps { block: Base64ContentBlock; removable?: boolean; @@ -14,7 +15,7 @@ export const MultimodalPreview: React.FC = ({ block, removable = false, onRemove, - className = "", + className, size = "md", }) => { // Sizing @@ -38,13 +39,13 @@ export const MultimodalPreview: React.FC = ({ if (size === "sm") imgClass = "rounded-md object-cover h-10 w-10 text-base"; if (size === "lg") imgClass = "rounded-md object-cover h-24 w-24 text-xl"; return ( -
- + {String(block.metadata?.name {removable && (