Skip to content

Conversation

@Prasannajaga
Copy link

@Prasannajaga Prasannajaga commented Jun 11, 2025

Changes Made

  • Drag-and-Drop Support: Added event listeners to the chat interface to handle drag-and-drop file uploads, enabling users to drop files directly into the input area.
  • Paste Support: Implemented functionality to detect and process files pasted into the chat input area (e.g., images or text and documents).
  • File Preview: Integrated a preview component above the chat input to display thumbnails for images or file icons with names for other file types, improving visual feedback.
  • Attach File Icon: Added a paperclip icon to the chat input area, allowing users to select files from their device via a file input dialog.
  • File Processing: Enabled file uploads to be processed and stored for the session, with support for sending files to the model as needed.

Testing

  • Verified drag-and-drop functionality with various file types (images, PDFs, text files).
  • Tested paste support for images and documents from the clipboard.
  • Confirmed file previews display correctly (thumbnails for images, icons for documents).
  • Validated the attach file icon triggers the file picker and processes uploads.
  • Ensured no performance degradation in the chat interface during file handling.

ScreenShots

features2
features
feature3
feature5

Notes for Reviewers

  • Please verify the UI consistency with the existing chat0 design.
  • Test edge cases, such as large files or unsupported file types.
  • Let me know if additional validation or error handling is needed.
  • Any feedback on performance optimization is welcome.

Summary by CodeRabbit

  • New Features
    • Added support for file attachments in chat messages, including uploading files via drag-and-drop, paste, or file selection.
    • Introduced file previews for attachments, with image thumbnails, text file snippets, and embedded previews for other file types.
  • User Interface
    • Enhanced chat input area to display attached files and provide options to remove them before sending.
    • Improved message display to show attached file previews alongside message text.
  • Chores
    • Updated file ignore settings to exclude package-lock.json from version control.

@vercel
Copy link

vercel bot commented Jun 11, 2025

@Prasannajaga is attempting to deploy a commit to the Harsh's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Jun 11, 2025

Walkthrough

The changes introduce file attachment support to the chat input component, enabling users to add files via drag-and-drop, paste, or file selection. New hooks and components manage file state and previews, and the message display now renders attached files. The .gitignore is updated to ignore package-lock.json.

Changes

File(s) Change Summary
.gitignore Added package-lock.json to ignored files; minor formatting update.
frontend/components/ChatInput.tsx Integrated file attachment support: file state management, UI for file input, and preview display.
frontend/components/Message.tsx Enhanced message rendering to show previews of attached files when present.
frontend/components/filePreview.tsx New component for rendering file previews (images, text, others) with clear functionality.
frontend/hooks/useFileHandler.tsx New hook to manage file input state and handlers for paste, drag-and-drop, and file selection.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatInput
    participant useFileHandler
    participant FilePreview
    participant Message

    User->>ChatInput: Drag/drop, paste, or select file
    ChatInput->>useFileHandler: Handle file event
    useFileHandler-->>ChatInput: Update file state (URLs, types, list)
    ChatInput->>FilePreview: Render file preview(s)
    User->>ChatInput: Submit message
    ChatInput->>Message: Send message with experimental_attachments
    Message->>FilePreview: Render attached file previews
Loading

Possibly related issues

Poem

🐇✨
Files now hop into chat with glee,
Drag, drop, or paste — as easy as can be!
Previews appear, a thumbnail show,
Images, text, and more in tow.
Attachments leap with every send,
The chat’s new tricks will never end!
🗂️🎉

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

frontend/components/ChatInput.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in " » eslint-config-next/core-web-vitals » /node_modules/.pnpm/eslint-config-next@15.3.2_eslint@9.28.0_jiti@2.4.2__typescript@5.8.3/node_modules/eslint-config-next/index.js".

If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting.

frontend/components/Message.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in " » eslint-config-next/core-web-vitals » /node_modules/.pnpm/eslint-config-next@15.3.2_eslint@9.28.0_jiti@2.4.2__typescript@5.8.3/node_modules/eslint-config-next/index.js".

If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting.

frontend/hooks/useFileHandler.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in " » eslint-config-next/core-web-vitals » /node_modules/.pnpm/eslint-config-next@15.3.2_eslint@9.28.0_jiti@2.4.2__typescript@5.8.3/node_modules/eslint-config-next/index.js".

If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting.

  • 1 others
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 15

🧹 Nitpick comments (1)
.gitignore (1)

44-44: Remove trailing whitespace.

-#cloudflare
-.open-next 
+#cloudflare
+.open-next
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96bccb4 and 0508633.

📒 Files selected for processing (5)
  • .gitignore (1 hunks)
  • frontend/components/ChatInput.tsx (8 hunks)
  • frontend/components/Message.tsx (2 hunks)
  • frontend/components/filePreview.tsx (1 hunks)
  • frontend/hooks/useFileHandler.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
frontend/components/ChatInput.tsx (1)
frontend/hooks/useFileHandler.tsx (1)
  • useFileHandler (3-84)
frontend/components/Message.tsx (1)
frontend/components/filePreview.tsx (1)
  • TextFilePreview (12-37)
🔇 Additional comments (1)
.gitignore (1)

45-45: Reconsider ignoring package-lock.json.

The package-lock.json file should typically be committed to version control to ensure reproducible builds and consistent dependency versions across all environments. Ignoring it can lead to "works on my machine" issues.

Consider keeping package-lock.json in version control unless there's a specific reason to exclude it (e.g., if you're using Yarn and have yarn.lock instead).

alt={attachment.name}
/>
: attachment.contentType?.startsWith("text/") ?
<TextFilePreview fileList={undefined} /> :
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix TextFilePreview receiving undefined fileList.

The TextFilePreview component is being passed undefined as the fileList prop, which will always render empty content. You need to pass the actual file data from the attachment.

The attachment object likely contains the file data or URL that should be used here. Consider either:

  1. Modifying TextFilePreview to accept a URL and fetch the content
  2. Storing the actual File object in the attachment data structure
🤖 Prompt for AI Agents
In frontend/components/Message.tsx at line 83, the TextFilePreview component is
incorrectly receiving undefined for its fileList prop, causing it to render
empty content. To fix this, pass the actual file data from the attachment object
to the fileList prop. This may involve accessing the file or URL stored in the
attachment and providing it directly to TextFilePreview, or updating the
attachment structure to include the necessary file information.

/>
: attachment.contentType?.startsWith("text/") ?
<TextFilePreview fileList={undefined} /> :
<iframe src={attachment.url} className="w-20 h-20 overflow-hidden" scrolling="no"></iframe>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security concern: Validate iframe source URLs.

Rendering arbitrary URLs in an iframe without validation could pose security risks. Consider implementing a whitelist of allowed domains or file types.

Add proper sandboxing attributes to the iframe and validate the URL source:

-<iframe src={attachment.url} className="w-20 h-20 overflow-hidden" scrolling="no"></iframe>
+<iframe 
+  src={attachment.url} 
+  className="w-20 h-20 overflow-hidden" 
+  scrolling="no"
+  sandbox="allow-scripts allow-same-origin"
+  title={attachment.name}
+></iframe>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<iframe src={attachment.url} className="w-20 h-20 overflow-hidden" scrolling="no"></iframe>
<iframe
src={attachment.url}
className="w-20 h-20 overflow-hidden"
scrolling="no"
sandbox="allow-scripts allow-same-origin"
title={attachment.name}
></iframe>
🤖 Prompt for AI Agents
In frontend/components/Message.tsx at line 84, the iframe src attribute is set
directly from attachment.url without validation, posing a security risk. Fix
this by implementing a whitelist check to ensure the URL domain or file type is
allowed before rendering. Additionally, add sandbox attributes to the iframe
element to restrict its capabilities and enhance security.

<div className='flex flex-col gap-2'>
{message.experimental_attachments
?.map((attachment, index) => (
<section key={attachment.name}>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use a unique key for attachment rendering.

Using attachment.name as the React key could cause rendering issues if multiple files have the same name.

-<section key={attachment.name}>
+<section key={`${message.id}-attachment-${index}`}>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<section key={attachment.name}>
<section key={`${message.id}-attachment-${index}`}>
🤖 Prompt for AI Agents
In frontend/components/Message.tsx at line 75, the React key for the attachment
section is set to attachment.name, which may not be unique if multiple
attachments share the same name. Update the key to use a unique identifier for
each attachment, such as a combination of attachment name and a unique property
like an ID or index, to ensure stable and correct rendering by React.

Comment on lines +106 to 109
append(userMessage, { experimental_attachments: fileList })
setInput('');
clearFiles();
adjustHeight(true);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add file validation before appending message.

Consider validating file size and type before sending to prevent issues with large files or unsupported formats.

+// Add validation before append
+if (fileList) {
+  const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
+  const file = fileList[0];
+  if (file.size > MAX_FILE_SIZE) {
+    // Show error to user
+    return;
+  }
+}
 append(userMessage, { experimental_attachments: fileList })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
append(userMessage, { experimental_attachments: fileList })
setInput('');
clearFiles();
adjustHeight(true);
// Add validation before append
if (fileList) {
const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
const file = fileList[0];
if (file.size > MAX_FILE_SIZE) {
// Show error to user
return;
}
}
append(userMessage, { experimental_attachments: fileList })
setInput('');
clearFiles();
adjustHeight(true);
🤖 Prompt for AI Agents
In frontend/components/ChatInput.tsx around lines 106 to 109, before calling
append(userMessage, { experimental_attachments: fileList }), add validation
logic to check each file's size and type in fileList. Filter out or reject files
that exceed size limits or are of unsupported formats, and only append messages
with valid files. This prevents issues caused by large or unsupported files
being sent.

Comment on lines +183 to +187
<div className="flex gap-2 items-center">
<input onChange={handleFileChange} className='hidden' type="file" name="" id="fileChange" />
<label htmlFor="fileChange">
<Plus />
</label>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve file input UI accessibility and styling.

The Plus icon button lacks proper styling and accessibility attributes.

-<label htmlFor="fileChange">
-  <Plus />
-</label>
+<label 
+  htmlFor="fileChange" 
+  className="cursor-pointer p-2 hover:bg-muted rounded-md transition-colors"
+  aria-label="Attach file"
+>
+  <Plus className="w-5 h-5" />
+</label>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div className="flex gap-2 items-center">
<input onChange={handleFileChange} className='hidden' type="file" name="" id="fileChange" />
<label htmlFor="fileChange">
<Plus />
</label>
<div className="flex gap-2 items-center">
<input onChange={handleFileChange} className='hidden' type="file" name="" id="fileChange" />
<label
htmlFor="fileChange"
className="cursor-pointer p-2 hover:bg-muted rounded-md transition-colors"
aria-label="Attach file"
>
<Plus className="w-5 h-5" />
</label>
🤖 Prompt for AI Agents
In frontend/components/ChatInput.tsx around lines 183 to 187, the file input UI
lacks proper accessibility and styling. Add appropriate ARIA attributes to the
label or input for better accessibility, such as aria-label or role. Also,
enhance the styling of the Plus icon button to make it visually clear and
interactive, for example by adding cursor pointer and focus styles to the label
element.

setContentTypes(types);
console.log("type" , types , fileUrls , fileList);

}, []);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix useCallback dependency array.

The empty dependency array is incorrect since the callback uses fileUrls and fileList in the console.log.

-}, []);
+}, [fileUrls]);

Note: After removing the console.log, the empty array would be correct.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In frontend/hooks/useFileHandler.tsx at line 17, the useCallback hook has an
empty dependency array but uses fileUrls and fileList inside its callback, which
is incorrect. To fix this, either add fileUrls and fileList to the dependency
array to ensure the callback updates when these values change, or remove the
console.log statement that references them, allowing the empty array to be
correct.

const [contentTypes, setContentTypes] = useState<string[]>([]);

const processFiles = useCallback((files: FileList) => {
const urls = Array.from(files).map((file) => URL.createObjectURL(file));
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Prevent memory leaks by revoking object URLs.

Object URLs created with URL.createObjectURL must be revoked to prevent memory leaks.

Store the URLs and revoke them when clearing or before creating new ones:

 const processFiles = useCallback((files: FileList) => {
+  // Revoke previous URLs
+  fileUrls.forEach(url => URL.revokeObjectURL(url));
+  
   const urls = Array.from(files).map((file) => URL.createObjectURL(file));

Also update clearFiles:

 const clearFiles = useCallback(() =>{
+  fileUrls.forEach(url => URL.revokeObjectURL(url));
   setFileList(undefined);

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In frontend/hooks/useFileHandler.tsx at line 9, the code creates object URLs
with URL.createObjectURL but does not revoke them, causing potential memory
leaks. Modify the code to store the generated URLs in a variable or state, and
ensure that before creating new URLs or when clearing files, you call
URL.revokeObjectURL on each stored URL to release the memory. Also update the
clearFiles function to revoke all stored URLs before clearing them.

// Optional: handle pasted text if needed
const text = event.clipboardData.getData('text/plain');
if (text) {
document.execCommand('insertText', false, text);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace deprecated document.execCommand.

document.execCommand is deprecated and should not be used. Consider using the modern Clipboard API or letting the browser handle text paste naturally.

-document.execCommand('insertText', false, text);
+// Let the default paste behavior handle text insertion
+// or use: navigator.clipboard.writeText(text);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
document.execCommand('insertText', false, text);
// Let the default paste behavior handle text insertion
// or use: navigator.clipboard.writeText(text);
🤖 Prompt for AI Agents
In frontend/hooks/useFileHandler.tsx at line 44, replace the deprecated
document.execCommand('insertText', false, text) with a modern approach. Use the
Clipboard API's navigator.clipboard.writeText(text) if you want to
programmatically copy text, or alternatively, allow the browser to handle text
insertion naturally without forcing it via execCommand. Adjust the code to avoid
using execCommand and adopt the Clipboard API or native input handling.

setFileUrls(urls);
setFileList(files);
setContentTypes(types);
console.log("type" , types , fileUrls , fileList);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove console.log statement.

Debug logging should not be included in production code.

-console.log("type" , types , fileUrls , fileList);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log("type" , types , fileUrls , fileList);
// (Remove the debug log; no replacement needed)
🤖 Prompt for AI Agents
In frontend/hooks/useFileHandler.tsx at line 15, remove the console.log
statement that outputs "type", types, fileUrls, and fileList to eliminate debug
logging from production code.

Comment on lines +8 to +17
const processFiles = useCallback((files: FileList) => {
const urls = Array.from(files).map((file) => URL.createObjectURL(file));
const types = Array.from(files).map((file) => file.type);

setFileUrls(urls);
setFileList(files);
setContentTypes(types);
console.log("type" , types , fileUrls , fileList);

}, []);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add file validation for size and quantity.

The file processing should validate file size and limit the number of files to prevent performance issues.

 const processFiles = useCallback((files: FileList) => {
+  const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
+  const MAX_FILES = 5;
+  
+  if (files.length > MAX_FILES) {
+    console.error(`Maximum ${MAX_FILES} files allowed`);
+    return;
+  }
+  
+  for (const file of Array.from(files)) {
+    if (file.size > MAX_FILE_SIZE) {
+      console.error(`File ${file.name} exceeds maximum size of 10MB`);
+      return;
+    }
+  }
+  
   const urls = Array.from(files).map((file) => URL.createObjectURL(file));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const processFiles = useCallback((files: FileList) => {
const urls = Array.from(files).map((file) => URL.createObjectURL(file));
const types = Array.from(files).map((file) => file.type);
setFileUrls(urls);
setFileList(files);
setContentTypes(types);
console.log("type" , types , fileUrls , fileList);
}, []);
const processFiles = useCallback((files: FileList) => {
const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
const MAX_FILES = 5;
if (files.length > MAX_FILES) {
console.error(`Maximum ${MAX_FILES} files allowed`);
return;
}
for (const file of Array.from(files)) {
if (file.size > MAX_FILE_SIZE) {
console.error(`File ${file.name} exceeds maximum size of 10MB`);
return;
}
}
const urls = Array.from(files).map((file) => URL.createObjectURL(file));
const types = Array.from(files).map((file) => file.type);
setFileUrls(urls);
setFileList(files);
setContentTypes(types);
console.log("type", types, fileUrls, fileList);
}, []);
🤖 Prompt for AI Agents
In frontend/hooks/useFileHandler.tsx around lines 8 to 17, add validation to the
processFiles function to check each file's size against a defined maximum limit
and ensure the total number of files does not exceed a set quantity limit. If
any file is too large or the number of files is too many, prevent further
processing and optionally provide feedback. Implement these checks before
creating object URLs and updating state to avoid performance issues.

@senbo1
Copy link
Owner

senbo1 commented Jun 24, 2025

this looks good, but we will first need a way to store these somewhere(S3 or somewhere), since we can't fill indexxed db with large files.

@Prasannajaga
Copy link
Author

@senbo1 any update on this ?

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