Skip to content

fix(copilot): limit uploads to images#1176

Merged
Sg312 merged 1 commit intostagingfrom
fix/copilot-uploads
Aug 29, 2025
Merged

fix(copilot): limit uploads to images#1176
Sg312 merged 1 commit intostagingfrom
fix/copilot-uploads

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Aug 29, 2025

Summary

Limit copilot uploads to images

Fixes #(issue)

Type of Change

  • Bug fix

Testing

Manual

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

vercel bot commented Aug 29, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Aug 29, 2025 2:17am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Aug 29, 2025 2:17am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR implements restrictions for copilot file uploads to only accept image files. The changes span multiple layers of the application architecture:

Core Changes:

  • Adds a new isImageFileType utility function in file-utils.ts that validates MIME types against supported image formats (JPEG, JPG, PNG, GIF, WebP, SVG)
  • Modifies the presigned upload route to enforce image-only validation for copilot uploads, throwing validation errors for unsupported file types
  • Updates the copilot user input component to filter out non-image files during processing and restricts the HTML file input to accept='image/*'
  • Changes the default SIM agent API URL from staging to production (https://staging.agent.sim.ai to https://agent.sim.ai)

The implementation follows a layered validation approach: frontend filtering prevents non-image selection, client-side processing skips non-image files with warning logs, and backend validation provides the final security barrier. This ensures that copilot functionality is restricted to visual content processing, which aligns with typical AI copilot use cases that focus on image analysis rather than document processing.

The existing document upload functionality for other parts of the application (like knowledge bases) remains unchanged, as evidenced by the existing isSupportedFileType function and comprehensive MIME type mappings that continue to support various document formats.

PR Description Notes:

  • The PR description is incomplete with placeholder text and no actual issue number referenced
  • Testing section and checkboxes are left blank

Confidence score: 3/5

  • This PR requires careful review due to the production API URL change and incomplete validation coverage
  • Score reflects concerns about the API environment switch and potential UX inconsistencies in file handling
  • Pay close attention to the API URL change in constants.ts and the user input validation logic

4 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

Comment on lines +67 to +75
const imageTypes = [
'image/jpeg',
'image/jpg',
'image/png',
'image/gif',
'image/webp',
'image/svg+xml',
]
return imageTypes.includes(mimeType.toLowerCase())
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider extracting this to a constant to maintain consistency with existing patterns like MIME_TYPE_MAPPING

Comment on lines +68 to +69
'image/jpeg',
'image/jpg',
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: image/jpg is not a standard MIME type - image/jpeg covers both .jpg and .jpeg extensions

@Sg312 Sg312 merged commit cadfcdb into staging Aug 29, 2025
5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/copilot-uploads branch August 29, 2025 05:01
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
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