From 670f9b8daf8c78069d62cf012b20b55b23faf447 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sun, 27 Apr 2025 01:37:25 -0400 Subject: [PATCH] fix: add optional chaining to file type checks in DragDropModal and Columns to prevent runtime errors --- client/src/components/Chat/Input/Files/DragDropModal.tsx | 2 +- client/src/components/Chat/Input/Files/Table/Columns.tsx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/components/Chat/Input/Files/DragDropModal.tsx b/client/src/components/Chat/Input/Files/DragDropModal.tsx index 2abc15a45b..784116dc65 100644 --- a/client/src/components/Chat/Input/Files/DragDropModal.tsx +++ b/client/src/components/Chat/Input/Files/DragDropModal.tsx @@ -34,7 +34,7 @@ const DragDropModal = ({ onOptionSelect, setShowModal, files, isVisible }: DragD label: localize('com_ui_upload_image_input'), value: undefined, icon: , - condition: files.every((file) => file.type.startsWith('image/')), + condition: files.every((file) => file.type?.startsWith('image/')), }, ]; for (const capability of capabilities) { diff --git a/client/src/components/Chat/Input/Files/Table/Columns.tsx b/client/src/components/Chat/Input/Files/Table/Columns.tsx index 8b8f52d8e7..bc60de361f 100644 --- a/client/src/components/Chat/Input/Files/Table/Columns.tsx +++ b/client/src/components/Chat/Input/Files/Table/Columns.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react-hooks/rules-of-hooks */ import { ArrowUpDown, Database } from 'lucide-react'; import { FileSources, FileContext } from 'librechat-data-provider'; @@ -68,7 +69,7 @@ export const columns: ColumnDef[] = [ }, cell: ({ row }) => { const file = row.original; - if (file.type.startsWith('image')) { + if (file.type?.startsWith('image')) { return (
[] = [ className="relative h-10 w-10 shrink-0 overflow-hidden rounded-md" source={file.source} /> - {file.filename} + {file.filename}
); } @@ -212,4 +213,4 @@ export const columns: ColumnDef[] = [ return `${value}${suffix}`; }, }, -]; \ No newline at end of file +];