Skip to content

fix(chat): render HEIC attachments and restyle composer file chips - #6361

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/composer-attachment-chips
Aug 7, 2026
Merged

fix(chat): render HEIC attachments and restyle composer file chips#6361
waleedlatif1 merged 3 commits into
stagingfrom
fix/composer-attachment-chips

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Composer previewed every attachment via URL.createObjectURL of the raw bytes. No browser decodes HEVC-coded HEIF, so a HEIC rendered a broken glyph — and since the upload-completion handler never replaced that blob URL, it stayed broken even once a server derivative existed.
  • HEIC/HEIF now skip the blob and pick up the serve URL (preview=1) once the upload lands, so the JPEG derivative renders. Other images keep their blob URL — no extra round trip for a thumbnail the browser can already draw.
  • Added an onError fallback: if the image still fails (transcode unavailable, 401/409), the type icon shows instead of a broken glyph.
  • Documents now render as labelled cards — icon badge, filename, type — instead of a 9px extension caption. Media keeps the thumbnail. Both are 48px so a mixed row shares a baseline.
  • Fixed a blob-URL leak: the unmount cleanup had [] deps closing over the first render's empty array, so it revoked nothing, ever.

Type of Change

  • Bug fix

Testing

tsc --noEmit, lint, check:api-validation clean. 1013 tests pass. Four new tests on the chip; verified the two behavioral ones fail without their fix.

Not yet verified in a browser — pill proportions against the 48px tiles and the overlapping remove badge need a visual check.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

The composer previewed every attachment through URL.createObjectURL of the
raw bytes. No browser decodes HEVC-coded HEIF, so a HEIC showed a broken
glyph, and the upload-completion handler never replaced that blob URL — so
it stayed broken even once a derivative was available.
- Skip the blob for HEIC/HEIF and pick up the serve URL (preview=1) once the
upload lands, so the server derivative renders.
- Fall back to the type icon if the image still fails to decode.
- Documents render as labelled cards (icon, name, type) instead of a 9px
extension caption; media keeps a thumbnail.
- Fix a blob-URL leak: the unmount cleanup closed over the first render's
empty array and revoked nothing.
@vercel

vercelBot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedAug 7, 2026 1:57am

Request Review

@cursor

cursorBot commented Aug 7, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches upload preview lifecycle and blob URL revocation in a shared hook; UI-only risk is mostly layout/styling in the composer, but incorrect preview URLs could still affect attachment display after upload.

Overview
Fixes composer attachment previews for HEIC/HEIF and refreshes how file chips look in the chat composer.

Preview pipeline: Attachments no longer always use URL.createObjectURL on raw bytes. HEIC/HEIF skip blob previews and, after upload, use the mothership serve URL (preview=1) for a JPEG derivative. Other images still use blob URLs when the browser can decode them. Upload completion now sets previewUrl via getMothershipAttachmentPreviewUrl when there was no local preview. use-file-attachments fixes blob URL leaks by revoking only blob: URLs, using a ref for unmount/remove/clear/restore cleanup, and keeping state updaters pure under StrictMode.

Chip UI:AttachedFilesList splits into AttachedFileChip with two 48px-tall shapes—media thumbnails vs document cards (icon, filename, extension)—stable HEIC layout before preview exists, and onError on images to show the type icon when decode fails. Surfaces, remove badge, and upload overlay styling are updated for the composer shell.

Tests: Four Vitest/jsdom cases cover document vs image rendering, HEIC thumbnail shape without preview, and preview error fallback.

Reviewed by Cursor Bugbot for commit 710767e. Configure here.

@greptile-apps

greptile-appsBot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds server-rendered previews for HEIC/HEIF attachments, improves attachment chip presentation and fallback behavior, and corrects blob URL cleanup.

  • Uses server-generated image derivatives for formats browsers cannot decode locally.
  • Restyles media and document attachments as aligned 48px chips.
  • Revokes locally created object URLs during removal, replacement, clearing, failed uploads, and unmount.
  • Adds focused rendering and image-error fallback tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

FilenameOverview
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list/attached-files-list.test.tsxAdds focused chip-rendering tests and now uses the required absolute aliases, fully resolving the previous import finding.
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/attached-files-list/attached-files-list.tsxIntroduces distinct media and document chip layouts with image-error fallback and accessible removal controls.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments.tsRoutes HEIC/HEIF previews through server derivatives and centralizes safe blob URL cleanup across attachment lifecycle operations.

Reviews (3): Last reviewed commit: "chore(chat): use the absolute alias for ..." | Re-trigger Greptile

The composer is --white in light and --surface-4 in dark. The chip reused
chipFilledFillTokens (--surface-5 / dark:--surface-4), which assumes a page
background, so in dark mode the chip fill matched its own container exactly
and only the border showed. Same for the remove badge, which sits on the
shell and was 5/255 from it.
- Chip fills --surface-5 in both themes and hover steps away from the shell
in each theme's 'raised' direction.
- Remove badge uses --surface-6, readable on white and on --surface-4.
- Cap the document card at min(220px,100%) so a long filename truncates on a
narrow viewport instead of overflowing the composer.
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit a016489. Configure here.

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 710767e. Configure here.

@waleedlatif1
waleedlatif1 merged commit 8694f55 into stagingAug 7, 2026
24 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/composer-attachment-chips branch August 7, 2026 02:00
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@waleedlatif1