Skip to content

feat(files): allow image uploads in workspace files#4419

Open
waleedlatif1 wants to merge 1 commit intostagingfrom
waleedlatif1/files-png-upload
Open

feat(files): allow image uploads in workspace files#4419
waleedlatif1 wants to merge 1 commit intostagingfrom
waleedlatif1/files-png-upload

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • workspace Files upload was rejecting all images (PNG, JPG, etc.) because the accept attribute had no image extensions, even though the backend accepts any file type
  • added SUPPORTED_IMAGE_EXTENSIONS (png, jpg, jpeg, gif, webp, svg, bmp, tif, tiff, heic, heif, avif, ico) and included it in the workspace files picker
  • consolidated the duplicate local image extension list previously used by CHAT_ACCEPT_ATTRIBUTE

Type of Change

  • Bug fix

Testing

Tested manually

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)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 3, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 3, 2026 5:05am

Request Review

@gitguardian
Copy link
Copy Markdown

gitguardian Bot commented May 3, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@cursor
Copy link
Copy Markdown

cursor Bot commented May 3, 2026

PR Summary

Low Risk
Low risk UI/validation-list change that only expands allowed file extensions and labels image MIME types; main risk is inadvertently allowing unexpected image formats in the picker.

Overview
Workspace Files uploads now allow common image formats by adding SUPPORTED_IMAGE_EXTENSIONS to the file picker’s accepted extension list and labeling image/* MIME types as "Image" in the table.

Upload validation constants were consolidated by promoting the image extension list into validation.ts and reusing it for CHAT_ACCEPT_ATTRIBUTE, while also expanding supported image MIME types (e.g., TIFF/HEIC/AVIF/ICO).

Reviewed by Cursor Bugbot for commit b72e737. Configure here.

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/files-png-upload branch from 1969271 to 277b344 Compare May 3, 2026 05:02
@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/files-png-upload branch from 277b344 to 143056c Compare May 3, 2026 05:03
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 3, 2026

Greptile Summary

This PR fixes the workspace file picker rejecting image uploads by adding SUPPORTED_IMAGE_EXTENSIONS to the accepted extensions list and folding SupportedImageExtension into the SupportedMediaExtension union. It also consolidates the previously duplicated local image extension list used by CHAT_ACCEPT_ATTRIBUTE and expands SUPPORTED_IMAGE_MIME_TYPES with 7 additional formats (bmp, tiff, heic, heif, avif, x-icon). Both prior P2 concerns — incomplete MIME type coverage and the missing SupportedImageExtension in SupportedMediaExtension — are resolved in this PR.

Confidence Score: 5/5

Safe to merge — the fix is targeted and correct, with no regressions on existing paths.

All findings are P2 style/consistency observations. Both previously flagged P2s (MIME type gaps and missing SupportedImageExtension in the union) are addressed. No P0 or P1 issues found.

apps/sim/lib/uploads/utils/validation.ts — minor consistency gap with SUPPORTED_IMAGE_MIME_TYPES not being exported as a Record like its audio/video counterparts.

Important Files Changed

Filename Overview
apps/sim/lib/uploads/utils/validation.ts Adds SUPPORTED_IMAGE_EXTENSIONS constant and SupportedImageExtension type; expands SUPPORTED_IMAGE_MIME_TYPES with 7 new entries; folds SupportedImageExtension into SupportedMediaExtension; removes duplicate local extension list. Minor consistency gap: SUPPORTED_IMAGE_MIME_TYPES is still a private flat array, unlike the exported Record maps for audio and video.
apps/sim/app/workspace/[workspaceId]/files/files.tsx Imports and spreads SUPPORTED_IMAGE_EXTENSIONS into the workspace file picker's SUPPORTED_EXTENSIONS array, and adds an image/ MIME-type branch to formatFileType. Changes are straightforward and correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[File selected in picker] --> B{Which picker?}
    B -->|Workspace files| C[ACCEPT_ATTR: ext-only]
    B -->|Chat input| D[CHAT_ACCEPT_ATTRIBUTE: MIME + ext]

    C --> E[SUPPORTED_EXTENSIONS\ndoc + code + audio + video + image]
    D --> F[ACCEPT_ATTRIBUTE\ndoc MIME and ext]
    D --> G[SUPPORTED_IMAGE_MIME_TYPES\n12 MIME types]
    D --> H[SUPPORTED_IMAGE_EXTENSIONS mapped\n.png .jpg .jpeg ...]

    E --> I[SUPPORTED_IMAGE_EXTENSIONS\nnew in this PR]
    G --> I
    H --> I

    I --> J[SupportedImageExtension type]
    J --> K[SupportedMediaExtension union\ndoc + audio + video + image]
Loading

Reviews (2): Last reviewed commit: "feat(files): allow image uploads in work..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/files-png-upload branch from 143056c to b72e737 Compare May 3, 2026 05:05
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b72e737. Configure here.


if (mimeType?.startsWith('audio/')) return 'Audio'
if (mimeType?.startsWith('video/')) return 'Video'
if (mimeType?.startsWith('image/')) return 'Image'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Image files hidden when any type filter active

Medium Severity

Now that images can be uploaded, the type filter logic in filteredFiles silently excludes them whenever any type filter is active. The filter checks for 'document', 'audio', and 'video' but has no 'image' branch, so image files always hit return false. The filter dropdown also lacks an 'image' option, so there's no way for users to filter for or retain images when filtering by type.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b72e737. Configure here.

Sign up for free to 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