Skip to content

Conversation

@aleksandernsilva
Copy link
Contributor

@aleksandernsilva aleksandernsilva commented Dec 26, 2025

Proposed changes (including videos or screenshots)

This PR fixes a bug causing the room members list to not be updated once a invitation is revoked via user info contextual bar. In addition the members list query key was moved to the common file following our best practices.

Issue(s)

FB-170

Steps to test or reproduce

  • Open a federated room with at least one Pending invitation.
  • Open the Members List from the room header.
  • Click on the pending user to open their User Info sidebar.
  • Click the "Revoke Invitation" button.
  • Observe the success toast/indicator in the sidebar.
  • Return to or look at the Members List.
  • Observe: The revoked user is still listed in the "Members" group despite the invitation being canceled.

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Member lists now automatically refresh when users are removed from rooms, eliminating the need for manual page reloads.

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

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Dec 26, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Dec 26, 2025

⚠️ No Changeset found

Latest commit: be9b733

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

@aleksandernsilva aleksandernsilva added this to the 8.0.0 milestone Dec 26, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

Walkthrough

Centralizes member list query keys and introduces automatic cache invalidation after user removal from a room, ensuring the member list updates reactively without manual refresh. Fixes state drift where revoked federated invitations weren't reflected immediately in the members list.

Changes

Cohort / File(s) Summary
Query Key Centralization
apps/meteor/client/lib/queryKeys.ts
Added roomsQueryKeys.members() function with conditional path construction for type and filter parameters, providing a single source of truth for member list query keys
Query Key Integration
apps/meteor/client/views/hooks/useMembersList.ts
Replaced manual array-based query keys with centralized roomsQueryKeys.members() calls in both cache updates and hook initialization
Cache Invalidation
apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx
Integrated useQueryClient to invalidate members query cache after successful user removal, triggering automatic list refresh

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • MartinSchoeler
  • ggazzo
  • tassoevan

Poem

🐰 A query key unified, so clean and bright,
When members are removed, the cache takes flight!
No more stale invites in the UI's sight,
React Query whispers, the list feels right. ✨

Pre-merge checks and finishing touches

✅ 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 describes the main bug fix—members list not updating after invite revocation—which directly aligns with the changeset's core objective.
Linked Issues check ✅ Passed The PR successfully implements the fix for FB-170 by centralizing the members query key and invalidating it after user removal, ensuring reactive updates.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the members list reactivity issue; no unrelated modifications were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch regression/members-list-revoke

📜 Recent 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 c805070 and be9b733.

📒 Files selected for processing (3)
  • apps/meteor/client/lib/queryKeys.ts
  • apps/meteor/client/views/hooks/useMembersList.ts
  • apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx
🧰 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/hooks/useMembersList.ts
  • apps/meteor/client/lib/queryKeys.ts
  • apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx
🧠 Learnings (7)
📓 Common learnings
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37532
File: ee/packages/federation-matrix/src/FederationMatrix.ts:920-927
Timestamp: 2025-12-09T20:01:07.355Z
Learning: In Rocket.Chat's federation invite handling (ee/packages/federation-matrix/src/FederationMatrix.ts), when a user rejects an invite via federationSDK.rejectInvite(), the subscription cleanup happens automatically through an event-driven flow: Matrix emits a leave event back, which is processed by handleLeave() in ee/packages/federation-matrix/src/events/member.ts, and that function calls Room.performUserRemoval() to clean up the subscription. No explicit cleanup is needed in the reject branch of handleInvite() because the leave event handler takes care of it.
<!-- </add_learning>
📚 Learning: 2025-12-02T22:23:49.593Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37654
File: apps/meteor/client/hooks/useAppSlashCommands.ts:32-38
Timestamp: 2025-12-02T22:23:49.593Z
Learning: In apps/meteor/client/hooks/useAppSlashCommands.ts, the `data?.forEach((command) => slashCommands.add(command))` call during render is intentional. The query is configured with `structuralSharing: false` to prevent React Query from keeping stable data references, and `slashCommands.add` is idempotent, so executing on every render is acceptable and ensures the command registry stays current.

Applied to files:

  • apps/meteor/client/views/hooks/useMembersList.ts
  • apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx
📚 Learning: 2025-11-27T17:56:26.050Z
Learnt from: MartinSchoeler
Repo: RocketChat/Rocket.Chat PR: 37557
File: apps/meteor/client/views/admin/ABAC/AdminABACRooms.tsx:115-116
Timestamp: 2025-11-27T17:56:26.050Z
Learning: In Rocket.Chat, the GET /v1/abac/rooms endpoint (implemented in ee/packages/abac/src/index.ts) only returns rooms where abacAttributes exists and is not an empty array (query: { abacAttributes: { $exists: true, $ne: [] } }). Therefore, in components consuming this endpoint (like AdminABACRooms.tsx), room.abacAttributes is guaranteed to be defined for all returned rooms, and optional chaining before calling array methods like .join() is sufficient without additional null coalescing.

Applied to files:

  • apps/meteor/client/views/hooks/useMembersList.ts
  • apps/meteor/client/lib/queryKeys.ts
  • apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.

Applied to files:

  • apps/meteor/client/lib/queryKeys.ts
  • apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings (mapping subscription documents to room IDs), never undefined, even when user has no room subscriptions.

Applied to files:

  • apps/meteor/client/lib/queryKeys.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings by mapping subscription documents to room IDs, never undefined, even when user has no room subscriptions.

Applied to files:

  • apps/meteor/client/lib/queryKeys.ts
📚 Learning: 2025-09-16T13:33:49.237Z
Learnt from: cardoso
Repo: RocketChat/Rocket.Chat PR: 36890
File: apps/meteor/tests/e2e/e2e-encryption/e2ee-otr.spec.ts:21-26
Timestamp: 2025-09-16T13:33:49.237Z
Learning: The im.delete API endpoint accepts either a `roomId` parameter (requiring the actual DM room _id) or a `username` parameter (for the DM partner's username). Constructing slug-like identifiers like `user2${Users.userE2EE.data.username}` doesn't work for this endpoint.

Applied to files:

  • apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx
🧬 Code graph analysis (3)
apps/meteor/client/views/hooks/useMembersList.ts (1)
apps/meteor/client/lib/queryKeys.ts (1)
  • roomsQueryKeys (13-33)
apps/meteor/client/lib/queryKeys.ts (1)
packages/apps-engine/src/definition/rooms/index.ts (1)
  • RoomType (14-14)
apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx (2)
packages/mock-providers/src/MockedAppRootBuilder.tsx (1)
  • queryClient (270-280)
apps/meteor/client/lib/queryKeys.ts (1)
  • roomsQueryKeys (13-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (3)
apps/meteor/client/lib/queryKeys.ts (1)

29-32: LGTM! Smart query key design for invalidation.

The conditional structure creates a base key when type and filter are omitted, which serves as a prefix for React Query's invalidateQueries. When useRemoveUserAction calls this with only rid and roomType, it invalidates all member queries for that room regardless of their type/filter parameters. This enables the reactive update fix described in the PR objectives.

apps/meteor/client/views/hooks/useMembersList.ts (1)

8-8: Excellent refactoring to centralized query keys.

The migration from inline array-based keys to roomsQueryKeys.members() ensures consistency between the query definition (line 140) and cache updates (line 77). This also enables the invalidation strategy in useRemoveUserAction.tsx to work correctly.

Also applies to: 77-77, 140-140

apps/meteor/client/views/room/hooks/useUserInfoActions/actions/useRemoveUserAction.tsx (1)

15-15: Core fix for reactive members list updates!

The query invalidation on line 75 directly addresses FB-170. After a successful user removal, invalidating with the base query key (room._id, room.t) triggers React Query's prefix matching, causing all member list queries for that room to refetch automatically. This eliminates the need for manual refresh when revoking federated invitations.

The invalidation placement in the onSuccess callback is correct—it only invalidates after the backend confirms the removal succeeded.

Also applies to: 20-20, 39-39, 75-75


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.

@aleksandernsilva
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aleksandernsilva aleksandernsilva changed the base branch from develop to release-8.0.0 December 26, 2025 16:03
@codecov
Copy link

codecov bot commented Dec 26, 2025

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.65%. Comparing base (0f9345a) to head (be9b733).
⚠️ Report is 12 commits behind head on release-8.0.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           release-8.0.0   #37981      +/-   ##
=================================================
+ Coverage          70.64%   70.65%   +0.01%     
=================================================
  Files               3143     3143              
  Lines             108687   108700      +13     
  Branches           19493    19562      +69     
=================================================
+ Hits               76785    76806      +21     
+ Misses             29903    29897       -6     
+ Partials            1999     1997       -2     
Flag Coverage Δ
e2e 60.19% <33.33%> (+<0.01%) ⬆️
e2e-api 47.43% <ø> (-0.06%) ⬇️
unit 71.79% <85.71%> (+0.01%) ⬆️

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.

@github-actions
Copy link
Contributor

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.1GiB 1.1GiB +11MiB
rocketchat 355MiB 345MiB +11MiB
omnichannel-transcript-service 132MiB 132MiB -51B
queue-worker-service 132MiB 132MiB -87B
ddp-streamer-service 126MiB 126MiB +513B
account-service 113MiB 113MiB -173B
authorization-service 111MiB 111MiB -415B
presence-service 111MiB 111MiB +988B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/16 01:28", "11/17 23:50", "11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/26 16:19 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "rocketchat" [0.36, 0.35, 0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.1GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-37981
  • Baseline: develop
  • Timestamp: 2025-12-26 16:19:35 UTC
  • Historical data points: 30

Updated: Fri, 26 Dec 2025 16:19:36 GMT

@aleksandernsilva aleksandernsilva marked this pull request as ready for review December 26, 2025 17:00
@aleksandernsilva aleksandernsilva requested a review from a team as a code owner December 26, 2025 17:00
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 3 files

@aleksandernsilva aleksandernsilva added the stat: QA assured Means it has been tested and approved by a company insider label Dec 26, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 26, 2025
@kodiakhq kodiakhq bot merged commit 65bbb5e into release-8.0.0 Dec 26, 2025
49 of 50 checks passed
@kodiakhq kodiakhq bot deleted the regression/members-list-revoke branch December 26, 2025 20:34
@aleksandernsilva aleksandernsilva added stat: QA assured Means it has been tested and approved by a company insider and removed stat: QA assured Means it has been tested and approved by a company insider labels Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants