Skip to content

fix(sharings): deduplicate transient shared-drive entries#3933

Merged
doubleface merged 1 commit into
masterfrom
fix/doubleSharings
Jun 19, 2026
Merged

fix(sharings): deduplicate transient shared-drive entries#3933
doubleface merged 1 commit into
masterfrom
fix/doubleSharings

Conversation

@doubleface

@doubleface doubleface commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

When a folder is shared from Sharings, the view can briefly receive that same file twice: the real Drive entry and a transformed shared-drive entry. The transformed entry uses the shared-drives magic directory, which is rendered as /sharings in the file path column.

Deduplicate by document id after merging the query result with transformed shared-drive entries, and prefer the real Drive entry when both representations are present.

https://app.notion.com/p/linagora/Folders-doubling-in-sherings-38262718bad180a4ac3de913943d4707?source=copy_link

Summary by CodeRabbit

  • Bug Fixes

    • Resolved duplicate sharing entries that appeared during sharing updates. The system now automatically removes redundant entries and prioritizes the primary Drive representation when duplicates occur.
  • Tests

    • Added comprehensive test coverage for sharing deduplication functionality.

When a folder is shared from Sharings, the view can briefly receive
that same file twice: the real Drive entry and a transformed
shared-drive entry. The transformed entry uses the shared-drives magic
directory, which is rendered as /sharings in the file path column.

Deduplicate by document id after merging the query result with
transformed shared-drive entries, and prefer the real Drive entry when
both representations are present.
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

useFilteredSharings.jsx gains a new exported function, deduplicateSharingShortcuts, that derives a stable document ID from _id or id, detects "shared-drives directory" items via dir_id === SHARED_DRIVES_DIR_ID, and removes duplicate representations of the same document by retaining the real Drive entry and discarding the synthetic shared-drives shortcut. computeData is updated to pass its output through this function before returning, regardless of the withoutSharedDrives flag path. A new test file useFilteredSharings.spec.jsx adds Jest unit tests covering both deduplicateSharingShortcuts in isolation and useFilteredSharings via renderHook, validating all deduplication cases and flag-driven code paths.

Suggested reviewers

  • rezk2ll
  • JF-Cozy
  • lethemanh
  • zatteo
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: deduplicating transient shared-drive entries that appear as duplicates in the Sharings view.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/doubleSharings

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.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@bundlemon

bundlemon Bot commented Jun 18, 2026

Copy link
Copy Markdown

BundleMon

Files updated (1)
Status Path Size Limits
static/js/main.(hash).js
48.27KB (+155B +0.31%) -
Unchanged files (19)
Status Path Size Limits
static/js/cozy.(hash).js
928.17KB -
static/resource/(hash).js
336.09KB -
services/qualificationMigration.js
283.39KB -
services/dacc.js
263.13KB -
static/js/lib-react.(hash).js
43.88KB -
static/css/cozy.(hash).css
30.13KB -
static/js/lib-polyfill.(hash).js
22.77KB -
static/js/lib-router.(hash).js
21.86KB -
static/js/public.(hash).js
19.79KB -
static/css/main.(hash).css
13.57KB -
static/js/intents.(hash).js
9.2KB -
static/js/(chunkId).(hash).js
8.6KB -
manifest.webapp
3.09KB -
static/css/public.(hash).css
2.34KB -
static/js/async/(chunkId).(hash).js
2.06KB -
main/index.html
769B -
public/index.html
704B -
intents/index.html
644B -
assets/manifest.json
185B -

Total files change +153B +0.01%

Groups updated (1)
Status Path Size Limits
**/*.js
5.98MB (+155B 0%) -
Unchanged groups (2)
Status Path Size Limits
**/*.{png,svg,ico}
2.16MB -
**/*.css
77.42KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/modules/views/Sharings/useFilteredSharings.spec.jsx (1)

67-71: 💤 Low value

Consider adding a test for the reverse order scenario.

The current test verifies [sharedDrivesFolder, rootFolder][rootFolder]. Adding a test for [rootFolder, sharedDrivesFolder][rootFolder] would confirm the implementation correctly preserves the real entry regardless of input order.

🧪 Suggested additional test case
   it('deduplicates same-id transient entries by keeping the regular Drive entry', () => {
     const result = deduplicateSharingShortcuts([sharedDrivesFolder, rootFolder])

     expect(result).toEqual([rootFolder])
   })
+
+  it('keeps the regular Drive entry when it appears first', () => {
+    const result = deduplicateSharingShortcuts([rootFolder, sharedDrivesFolder])
+
+    expect(result).toEqual([rootFolder])
+  })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/modules/views/Sharings/useFilteredSharings.spec.jsx` around lines 67 -
71, Add a new test case in the same test file for the
deduplicateSharingShortcuts function that verifies the reverse input order
scenario. The test should pass the array [rootFolder, sharedDrivesFolder] to
deduplicateSharingShortcuts and assert that it still returns [rootFolder],
confirming that the function correctly preserves the regular Drive entry
regardless of whether it appears first or second in the input order.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/modules/views/Sharings/useFilteredSharings.spec.jsx`:
- Around line 67-71: Add a new test case in the same test file for the
deduplicateSharingShortcuts function that verifies the reverse input order
scenario. The test should pass the array [rootFolder, sharedDrivesFolder] to
deduplicateSharingShortcuts and assert that it still returns [rootFolder],
confirming that the function correctly preserves the regular Drive entry
regardless of whether it appears first or second in the input order.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f382c25-306b-4c3d-b94d-8df579215cf5

📥 Commits

Reviewing files that changed from the base of the PR and between 1600705 and df10f6b.

📒 Files selected for processing (2)
  • src/modules/views/Sharings/useFilteredSharings.jsx
  • src/modules/views/Sharings/useFilteredSharings.spec.jsx

@zatteo

zatteo commented Jun 18, 2026

Copy link
Copy Markdown
Member

Owner or recipient or both have the issue?

@doubleface

Copy link
Copy Markdown
Contributor Author

Owner or recipient or both have the issue?

@zatteo Only the owner

@doubleface doubleface merged commit bb252b9 into master Jun 19, 2026
6 checks passed
@doubleface doubleface deleted the fix/doubleSharings branch June 19, 2026 14:54
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.

3 participants