From 3ce4e36ab29b737c8991c523a114811f640588c1 Mon Sep 17 00:00:00 2001 From: "Taylor Wilsdon (aider)" Date: Sun, 15 Dec 2024 18:48:35 -0500 Subject: [PATCH] feat: Add comprehensive console logging for file upload process --- src/lib/components/chat/MessageInput.svelte | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index a7a8343a4..c77d82231 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -90,7 +90,11 @@ }; const uploadFileHandler = async (file) => { - console.log(file); + console.log('Upload file handler called with:', { + name: file.name, + type: file.type, + size: file.size + }); const tempItemId = uuidv4(); const fileItem = { @@ -107,10 +111,12 @@ }; if (fileItem.size == 0) { + console.log('Attempted to upload empty file:', fileItem.name); toast.error($i18n.t('You cannot upload an empty file.')); return null; } + console.log('Adding file to upload queue:', fileItem); files = [...files, fileItem]; // Check if the file is an audio file and transcribe/convert it to text file if (['audio/mpeg', 'audio/wav', 'audio/ogg', 'audio/x-m4a'].includes(file['type'])) { @@ -155,13 +161,23 @@ }; const inputFilesHandler = async (inputFiles) => { + console.log('Input files handler called with:', inputFiles); inputFiles.forEach((file) => { - console.log(file, file.name.split('.').at(-1)); + console.log('Processing file:', { + name: file.name, + type: file.type, + size: file.size, + extension: file.name.split('.').at(-1) + }); if ( ($config?.file?.max_size ?? null) !== null && file.size > ($config?.file?.max_size ?? 0) * 1024 * 1024 ) { + console.log('File exceeds max size limit:', { + fileSize: file.size, + maxSize: ($config?.file?.max_size ?? 0) * 1024 * 1024 + }); toast.error( $i18n.t(`File size should not exceed {{maxSize}} MB.`, { maxSize: $config?.file?.max_size