From 270909e26ec56c4cc00ca3379356b2bc5794e6a9 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Wed, 2 Dec 2026 10:08:07 -0800 Subject: [PATCH] fix: show gif and upper-case image keys in object storage as images Co-Authored-By: Claude Opus 5.5 --- frontend/src/lib/components/S3FilePickerInner.svelte | 7 ++----- .../src/lib/components/copilot/chat/files/fileTools.ts | 2 +- frontend/src/lib/utils.ts | 7 +++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/frontend/src/lib/components/S3FilePickerInner.svelte b/frontend/src/lib/components/S3FilePickerInner.svelte index 89c23e84ae..7fb04b7704 100644 --- a/frontend/src/lib/components/S3FilePickerInner.svelte +++ b/frontend/src/lib/components/S3FilePickerInner.svelte @@ -59,6 +59,7 @@ displayDate, displaySize, emptyString, + isS3ImageKey, parseS3Object, sendUserToast, type S3Object, @@ -871,11 +872,7 @@ } if (fileMetadata) { fileMetadata.mimeType = - ((fileKey.endsWith('.png') || - fileKey.endsWith('.jpg') || - fileKey.endsWith('.jpeg') || - fileKey.endsWith('.webp')) && - 'Image') || + (isS3ImageKey(fileKey) && 'Image') || (fileKey.endsWith('.pdf') && 'PDF') || filePreview.contentType } diff --git a/frontend/src/lib/components/copilot/chat/files/fileTools.ts b/frontend/src/lib/components/copilot/chat/files/fileTools.ts index 897661047b..322ac27dbe 100644 --- a/frontend/src/lib/components/copilot/chat/files/fileTools.ts +++ b/frontend/src/lib/components/copilot/chat/files/fileTools.ts @@ -391,7 +391,7 @@ export const showImageTool: SessionTool<{}> = { } const s3 = parsed.s3! if (!isS3ImageKey(s3.s3)) { - return `"${s3.s3}" is not an image the viewer can show (png, jpeg or webp).` + return `"${s3.s3}" is not an image the viewer can show (png, jpeg, gif or webp).` } openImage( { kind: 'url', url: s3ImagePreviewUrl(workspace, s3) }, diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 2beaa4312a..685646bc92 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -1943,11 +1943,10 @@ export function parseS3Object(s3Object: S3Object): { s3: string; storage?: strin return { storage: match?.[1] || undefined, s3: match?.[2] ?? '' } } -const S3_IMAGE_EXTENSIONS = ['.png', '.jpeg', '.jpg', '.webp'] - -/** Whether a result's S3 object renders as an image. */ +/** Whether a result's S3 object renders as an image: the extensions `load_image_preview` serves + * with an image type, in any case, as the AI session's `read_s3_file` reads them. */ export function isS3ImageKey(key: string): boolean { - return S3_IMAGE_EXTENSIONS.some((ext) => key.endsWith(ext)) + return /\.(png|jpe?g|gif|webp)$/i.test(key) } /** The workspace's preview URL for an S3 image a job returned. */