Skip to content

Feat/copilot files#886

Merged
Sg312 merged 10 commits intostagingfrom
feat/copilot-files
Aug 6, 2025
Merged

Feat/copilot files#886
Sg312 merged 10 commits intostagingfrom
feat/copilot-files

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Aug 5, 2025

Summary

Adds file uploads to the copilot

Fixes #(issue)

Type of Change

  • New feature

Testing

Manual testing

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 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2025 11:58pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Aug 5, 2025 11:58pm

@vercel vercel bot temporarily deployed to Preview – docs August 5, 2025 23:42 Inactive
@vercel vercel bot temporarily deployed to Preview – docs August 5, 2025 23:44 Inactive
@Sg312 Sg312 marked this pull request as ready for review August 5, 2025 23:44
} else if (uploadType === 'chat') {
prefix = 'chat/'
} else if (uploadType === 'copilot') {
prefix = `${userId}/`
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the full path ooc? Or is it just all the files are under the user id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's the copilot bucket/userid/uuid-filename

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 adds comprehensive file upload functionality to the copilot chat feature. The implementation enables users to attach various file types (images, documents, PDFs) to their chat messages, which are then processed and sent to the Anthropic AI model for analysis.

The changes introduce a multi-layered architecture:

  1. Storage Layer: Extends the existing S3/Azure Blob storage system with copilot-specific buckets/containers, adding S3_COPILOT_CONFIG and BLOB_COPILOT_CONFIG configurations. Files are organized with user-specific prefixes (userId/) for proper isolation.

  2. API Layer: Updates multiple API endpoints including /api/files/presigned for secure file uploads, /api/files/serve for file retrieval with bucket-specific routing, and /api/copilot/chat for processing file attachments alongside messages.

  3. Type System: Introduces the MessageFileAttachment interface across multiple files, defining the structure for file metadata (id, s3_key, filename, media_type, size) that flows through the entire system.

  4. UI Components: Enhances the copilot chat interface with drag-and-drop file upload, thumbnail previews, and file attachment display. The UserInput component handles file processing and S3 uploads, while CopilotMessage renders attachments with appropriate icons and thumbnails.

  5. File Processing: Adds file-utils.ts with utilities to convert various file types into Anthropic-compatible message content, supporting both images and documents with proper MIME type detection and base64 encoding.

The integration maintains backward compatibility by making file attachments optional throughout the system. The implementation follows established patterns in the codebase for storage configuration, API design, and component architecture. Files are uploaded to S3 via presigned URLs, stored with user-specific organization, and their metadata is persisted in chat message records for conversation continuity.

Confidence score: 2/5

  • This PR has significant performance and security issues that could cause problems in production
  • Score lowered due to synchronous file downloading on every message, lack of file size validation, and potential memory issues with large file processing
  • Pay close attention to apps/sim/app/api/copilot/chat/route.ts which downloads files synchronously and could cause timeouts or memory issues with large files

Context used:

Context - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used to maintain type safety. (link)

15 files reviewed, 8 comments

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs August 5, 2025 23:54 Inactive
@Sg312 Sg312 merged commit 94368eb into staging Aug 6, 2025
5 checks passed
waleedlatif1 pushed a commit that referenced this pull request Aug 6, 2025
* Connects to s3

* Checkpoint

* File shows in message

* Make files clickable

* User input image

* Persist thumbnails

* Drag and drop files

* Lint

* Fix isdev

* Dont re-download files on rerender
@waleedlatif1 waleedlatif1 deleted the feat/copilot-files branch August 8, 2025 07:34
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
* Connects to s3

* Checkpoint

* File shows in message

* Make files clickable

* User input image

* Persist thumbnails

* Drag and drop files

* Lint

* Fix isdev

* Dont re-download files on rerender
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.

2 participants