diff --git a/client/src/components/Chat/Messages/Content/Image.tsx b/client/src/components/Chat/Messages/Content/Image.tsx index 85c3fdb3f2..ba4f65671a 100644 --- a/client/src/components/Chat/Messages/Content/Image.tsx +++ b/client/src/components/Chat/Messages/Content/Image.tsx @@ -46,13 +46,33 @@ const Image = ({ [placeholderDimensions, height, width], ); - const downloadImage = () => { - const link = document.createElement('a'); - link.href = imagePath; - link.download = altText; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); + const downloadImage = async () => { + try { + const response = await fetch(imagePath); + if (!response.ok) { + throw new Error(`Failed to fetch image: ${response.status}`); + } + + const blob = await response.blob(); + const url = window.URL.createObjectURL(blob); + + const link = document.createElement('a'); + link.href = url; + link.download = altText || 'image.png'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + window.URL.revokeObjectURL(url); + } catch (error) { + console.error('Download failed:', error); + const link = document.createElement('a'); + link.href = imagePath; + link.download = altText || 'image.png'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + } }; return ( diff --git a/client/src/components/Chat/Messages/MessageAudio.tsx b/client/src/components/Chat/Messages/MessageAudio.tsx index 29805e7afb..eb4c52a407 100644 --- a/client/src/components/Chat/Messages/MessageAudio.tsx +++ b/client/src/components/Chat/Messages/MessageAudio.tsx @@ -14,6 +14,9 @@ function MessageAudio(props: TMessageAudio) { }; const SelectedTTS = TTSComponents[engineTTS]; + if (!SelectedTTS) { + return null; + } return ; }