Skip to content

feat(content-sharing): Display pending collab#4509

Open
reneshen0328 wants to merge 2 commits intomasterfrom
add-pending-collab-to-content-sharing
Open

feat(content-sharing): Display pending collab#4509
reneshen0328 wants to merge 2 commits intomasterfrom
add-pending-collab-to-content-sharing

Conversation

@reneshen0328
Copy link
Copy Markdown
Contributor

@reneshen0328 reneshen0328 commented Apr 21, 2026

Before: We skip any pending collaborators.

After:
Screenshot 2026-04-21 at 12 03 14 PM

Summary by CodeRabbit

  • New Features

    • Support for email-based pending collaboration invites (invite email shown as pending collaborator)
    • Added a "rejected" collaboration status to represent declined requests
  • Bug Fixes

    • Pending collaborators without sufficient identity info are hidden; rejected collaborations are excluded
    • Improved external-invite detection to avoid false external flags
  • Tests

    • Updated tests for pending, rejected, and email-invite scenarios

@reneshen0328 reneshen0328 requested review from a team as code owners April 21, 2026 19:03
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Walkthrough

Extended collaboration types with an optional invite_email, added STATUS_REJECTED, and changed collaborator conversion/tests so pending collaborations with invite emails or populated accessible_by can produce pending collaborators; only rejected collaborations are ignored.

Changes

Cohort / File(s) Summary
Type definitions
src/common/types/core.js
Added optional invite_email?: string to CollaborationOptions, propagated to related collaboration types.
Status constants
src/constants.js
Added STATUS_REJECTED = 'rejected' and reordered status constant declarations (no value changes to existing constants).
Collaborator conversion logic
src/elements/content-sharing/utils/convertCollaborators.ts
Changed conversion gating to only reject STATUS_REJECTED; accept pending entries when identity resolves from invite_email or accessible_by; require a name; compute isPending, expiresAt, conditional userId and isCurrentUser; tightened isExternal checks.
Conversion tests
src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts
Updated tests to use STATUS_PENDING/STATUS_REJECTED, added positive cases for pending invites and internal pending users, and negative cases for unnamed pending and rejected entries; expanded expected converted list accordingly.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • jfox-box
  • tjuanitas

Poem

🐰 I found an invite curled in a leaf,
a name from an email brought bright relief.
Rejected tracks stay quiet, pending friends appear,
I hop with delight—collabs now draw near. 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description provides a brief overview of the change (before/after with screenshot) but lacks implementation details, test coverage explanation, and technical context required by the template. Expand the description to include implementation details, explanation of changes to types/constants, test coverage, and any breaking changes or migration notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main feature: displaying pending collaborators in content-sharing, which directly relates to the core changes across all modified files.
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 add-pending-collab-to-content-sharing

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
Copy Markdown
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.

🧹 Nitpick comments (1)
src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts (1)

58-73: LGTM — test coverage matches the new branches.

Mocks cover all three new paths (pending with invite_email, pending without, rejected), index arithmetic into mockCollaborations is correct given itemOwner is prepended, and the differing isExternal expectations between the direct convertCollab test (passes isCurrentUserOwner: false) and the convertCollabsResponse test (derives isCurrentUserOwner: true since currentUserId === ownerId) correctly reflect the implementation's short-circuit on ownership.

Optional nit: the convertCollab test uses mockCollaborations[4], mockCollaborations[3], mockCollaborations[5] by numeric index, which gets fragile as the fixture grows. Consider pulling those entries into named constants (e.g. pendingWithInviteEmail, pendingWithoutInviteEmail, rejectedCollab) to make intent obvious and avoid off-by-one breakage if someone inserts another entry.

Also applies to: 105-163, 243-295

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts`
around lines 58 - 73, The test uses fragile numeric indexes into
mockCollaborations (e.g., mockCollaborations[4], [3], [5]) inside the
convertCollab test; extract the specific fixtures into named constants (for
example pendingWithInviteEmail, pendingWithoutInviteEmail, rejectedCollab) and
reference those constants in the convertCollab and convertCollabsResponse tests
so intent is clear and adding entries to mockCollaborations won't break the
indexes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts`:
- Around line 58-73: The test uses fragile numeric indexes into
mockCollaborations (e.g., mockCollaborations[4], [3], [5]) inside the
convertCollab test; extract the specific fixtures into named constants (for
example pendingWithInviteEmail, pendingWithoutInviteEmail, rejectedCollab) and
reference those constants in the convertCollab and convertCollabsResponse tests
so intent is clear and adding entries to mockCollaborations won't break the
indexes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 379997c1-39ac-4e50-a460-e698e2586764

📥 Commits

Reviewing files that changed from the base of the PR and between 61dab4e and dbe0606.

📒 Files selected for processing (4)
  • src/common/types/core.js
  • src/constants.js
  • src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts
  • src/elements/content-sharing/utils/convertCollaborators.ts

Comment thread src/elements/content-sharing/utils/convertCollaborators.ts Outdated
Comment thread src/common/types/core.js
Comment thread src/elements/content-sharing/utils/convertCollaborators.ts Outdated
tjiang-box
tjiang-box previously approved these changes Apr 21, 2026
Comment thread src/constants.js
Comment thread src/elements/content-sharing/utils/convertCollaborators.ts Outdated
Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts`:
- Around line 347-363: The test currently passes mockOwnerId as the "current
user" which short-circuits owner logic; update the call to
convertCollabsResponse to pass a non-owner current user id (e.g., a new/mock
nonOwnerId) so the code exercises the "owner email has no domain" path using
ownerWithoutEmailDomain and verifies externalInvite.isExternal is computed from
the domain fallback rather than the owner short-circuit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1b0e8f2e-76aa-4eb6-b548-05c450d8f72a

📥 Commits

Reviewing files that changed from the base of the PR and between dbe0606 and 21d18f2.

📒 Files selected for processing (2)
  • src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts
  • src/elements/content-sharing/utils/convertCollaborators.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/elements/content-sharing/utils/convertCollaborators.ts

Comment thread src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts Outdated
@reneshen0328 reneshen0328 force-pushed the add-pending-collab-to-content-sharing branch from 21d18f2 to a040981 Compare April 21, 2026 23:51
Copy link
Copy Markdown
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.

♻️ Duplicate comments (1)
src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts (1)

347-363: ⚠️ Potential issue | 🟡 Minor

Make this test avoid the owner short-circuit.

Line 356 still passes mockOwnerId, so isExternal: false can be satisfied because the current user is the owner rather than because the owner email has no domain. Use a non-owner current user id here.

Proposed test adjustment
             const result = convertCollabsResponse(
                 mockCollaborationsFromApi,
-                mockOwnerId,
+                'non-owner-user-id',
                 ownerWithoutEmailDomain,
                 mockAvatarUrlMap,
             );
 
             const externalInvite = result.find(collab => collab.email === 'bbear@external.example.com');
-            expect(externalInvite.isExternal).toBe(false);
+            expect(externalInvite).toMatchObject({ isExternal: false });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts`
around lines 347 - 363, The test currently passes mockOwnerId into
convertCollabsResponse which short-circuits owner logic; replace that argument
with a non-owner id (e.g., mockNonOwnerId or any id !== mockOwnerId) so the code
path that checks ownerWithoutEmailDomain.email (the owner object) is exercised;
keep the rest of the test (ownerWithoutEmailDomain, mockCollaborationsFromApi,
mockAvatarUrlMap, and the expectation on externalInvite.isExternal) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts`:
- Around line 347-363: The test currently passes mockOwnerId into
convertCollabsResponse which short-circuits owner logic; replace that argument
with a non-owner id (e.g., mockNonOwnerId or any id !== mockOwnerId) so the code
path that checks ownerWithoutEmailDomain.email (the owner object) is exercised;
keep the rest of the test (ownerWithoutEmailDomain, mockCollaborationsFromApi,
mockAvatarUrlMap, and the expectation on externalInvite.isExternal) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b238ba66-32ff-4efa-86b0-ab63ed3b642f

📥 Commits

Reviewing files that changed from the base of the PR and between 21d18f2 and a040981.

📒 Files selected for processing (2)
  • src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts
  • src/elements/content-sharing/utils/convertCollaborators.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/elements/content-sharing/utils/convertCollaborators.ts

Comment thread src/elements/content-sharing/utils/convertCollaborators.ts
@reneshen0328 reneshen0328 force-pushed the add-pending-collab-to-content-sharing branch from a040981 to 074b213 Compare April 22, 2026 00:00
Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/elements/content-sharing/utils/convertCollaborators.ts`:
- Around line 35-49: The guard that only assigns collabId/collabEmail/collabName
when accessibleBy?.name is present drops identity for partial accessible_by
objects; update the logic in convertCollaborators (the block setting collabId,
collabEmail, collabName from accessibleBy) to populate collabId from
accessibleBy.id and collabEmail from accessibleBy.login whenever those fields
exist (independently of accessibleBy.name), and only override collabName if
accessibleBy.name is truthy; also ensure the later check that returns null uses
collabName || collabEmail to allow pending invites to survive (apply the same
fix to the similar branch around the other conditional referenced in the diff).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e875b75f-c282-4a60-9891-0251a92b7c2d

📥 Commits

Reviewing files that changed from the base of the PR and between a040981 and 074b213.

📒 Files selected for processing (2)
  • src/elements/content-sharing/utils/__tests__/convertCollaborators.test.ts
  • src/elements/content-sharing/utils/convertCollaborators.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/elements/content-sharing/utils/tests/convertCollaborators.test.ts

Comment thread src/elements/content-sharing/utils/convertCollaborators.ts
Comment thread src/elements/content-sharing/utils/convertCollaborators.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants