Skip to content

Comments

fix: allow uploading multiple same-size files via drag-and-drop#38109

Closed
dodaa08 wants to merge 3 commits intoRocketChat:developfrom
dodaa08:fix/DragNDrop-MultipleFilesWithSameSize
Closed

fix: allow uploading multiple same-size files via drag-and-drop#38109
dodaa08 wants to merge 3 commits intoRocketChat:developfrom
dodaa08:fix/DragNDrop-MultipleFilesWithSameSize

Conversation

@dodaa08
Copy link
Contributor

@dodaa08 dodaa08 commented Jan 8, 2026

Proposed changes (including videos or screenshots)

Previously, when multiple files were dragged and dropped into a chat, files with the same size were incorrectly treated as duplicates and only one would upload.
This fix changes the deduplication logic to identify files using their name, size, and modification time together, ensuring that different files with matching sizes are correctly uploaded while still preventing true duplicates.

Changed the key from file.size to ${file.name}-${file.size}-${file.lastModified}.

Local Testing With new key logic

Screencast.From.2026-01-08.23-16-32.mp4

Issue(s)

Closes #38108

Steps to test or reproduce

  1. Create two text files with the same size but different names:
    echo "Hello World 123" > file1.txt
    echo "Different Text!" > file2.txt
  2. Open any channel, team, or direct message
  3. Drag and drop both files simultaneously into the message input area
  4. Before fix: Only one file uploads
  5. After fix: Multiple files upload correctly

Further comments

Let me know if there's a better approach or if any changes are needed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved file upload duplicate detection by using a combination of file name, size, and modification time to identify duplicates more accurately instead of size alone.

✏️ Tip: You can customize this high-level summary in your review settings.

- Changed deduplication key from file.size to file.name-file.size-file.lastModified
- Allows uploading multiple files with the same size but different names
@dodaa08 dodaa08 requested a review from a team as a code owner January 8, 2026 18:17
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 8, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2026

⚠️ No Changeset found

Latest commit: d2e73f3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

Walkthrough

The deduplication mechanism for file uploads was updated to identify duplicate files using a composite key of file name, size, and lastModified timestamp instead of size alone. The tracking Set type changed from storing numbers to storing strings accordingly.

Changes

Cohort / File(s) Summary
File Upload Deduplication Logic
apps/meteor/client/views/room/body/hooks/useFileUploadDropTarget.ts
Changed deduplication key from file size (number) to composite string key combining name, size, and lastModified timestamp; updated Set type from Set<number> to Set<string>

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • sampaiodiego

Poem

🐰 A file finds its twin through a better key now,
Name and size and time—what a clever vow!
No more size alone in the dedup game,
Three traits combined seal a file's true name. 📎✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: allowing multiple files of the same size to be uploaded via drag-and-drop by fixing the deduplication logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
apps/meteor/client/views/room/body/hooks/useFileUploadDropTarget.ts (1)

44-52: LGTM! The composite key fix resolves the duplicate file issue.

The deduplication logic now correctly distinguishes files with the same size by including name and lastModified timestamp in the key. This solves the reported bug where same-size files were incorrectly treated as duplicates.

♻️ Optional improvements

1. Eliminate theoretical key collision risk:

While extremely unlikely in practice, the hyphen-separated format could theoretically produce collisions. Consider using JSON.stringify for a collision-proof approach:

 const getUniqueFiles = () => {
   const uniqueFiles: File[] = [];
-  const st: Set<string> = new Set();
+  const seenKeys: Set<string> = new Set();
   files.forEach((file) => {
-    const key = `${file.name}-${file.size}-${file.lastModified}`;
-    if (!st.has(key)) {
+    const key = JSON.stringify({ name: file.name, size: file.size, lastModified: file.lastModified });
+    if (!seenKeys.has(key)) {
       uniqueFiles.push(file);
-      st.add(key);
+      seenKeys.add(key);
     }
   });
   return uniqueFiles;
 };

2. Improve variable naming:

Rename st to seenKeys or uniqueKeys for better readability (shown in diff above).

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c42bb36 and ea80baa.

📒 Files selected for processing (1)
  • apps/meteor/client/views/room/body/hooks/useFileUploadDropTarget.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/room/body/hooks/useFileUploadDropTarget.ts

@shouryapratap132006
Copy link

Hi maintainers
Thanks for the review and feedback!

This change is a small client-side bug fix and shouldn’t require a version bump, so I believe a changeset is not needed here. Please let me know if you’d prefer one to be added.

I don’t have permission to add labels or milestones, could you please help by adding the required stat: QA assured label and assigning the appropriate milestone/project if everything looks good?

Happy to make any further adjustments if needed.
Thanks.

@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.75%. Comparing base (e22b852) to head (d2e73f3).
⚠️ Report is 99 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38109      +/-   ##
===========================================
- Coverage    70.77%   70.75%   -0.03%     
===========================================
  Files         3158     3158              
  Lines       109355   109355              
  Branches     19648    19671      +23     
===========================================
- Hits         77397    77375      -22     
- Misses       29934    29947      +13     
- Partials      2024     2033       +9     
Flag Coverage Δ
e2e 60.35% <100.00%> (+0.02%) ⬆️
e2e-api 48.02% <ø> (ø)
unit 71.87% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KevLehman
Copy link
Member

Closed in favor of #32703

@KevLehman KevLehman closed this Feb 18, 2026
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.

Drag-and-drop upload fails to upload multiple files with the same size

3 participants