Skip to content

Conversation

@dougfabris
Copy link
Member

@dougfabris dougfabris commented Nov 11, 2025

Proposed changes (including videos or screenshots)

Issue(s)

Closes #35661

Steps to test or reproduce

  1. Go to a room you not joined
  2. Open room info
  3. Leave option shouldn't be displayed

Further comments

CORE-1534

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where users without an active room subscription could access the leave room action. The leave room option is now only available to subscribed room members.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Nov 11, 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 Nov 11, 2025

🦋 Changeset detected

Latest commit: 4364024

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/mock-providers Patch
@rocket.chat/meteor Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch

Not sure what this means? Click here to learn what changesets are.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Walkthrough

Fixes the leave room action availability issue by changing the action's visibility logic to check user subscription status instead of a hardcoded joined flag. Updates the useRoomLeave hook to use subscription-based presence validation, adds corresponding test coverage, and updates the mock provider to safely handle undefined subscriptions.

Changes

Cohort / File(s) Summary
Core Hook Fix
apps/meteor/client/views/room/contextualBar/Info/hooks/actions/useRoomLeave.tsx
Removed optional joined parameter; replaced with subscription-based presence check via useUserSubscription(room._id). Updated translation hook imports from ui-contexts to react-i18next. Method signature changed from useRoomLeave(room: IRoom, joined = true) to useRoomLeave(room: IRoom).
Test Coverage
apps/meteor/client/views/room/contextualBar/Info/hooks/actions/useRoomLeave.spec.ts
New test file verifying the hook returns the leave function when user has subscription and returns null when subscription is absent.
Mock Provider Update
packages/mock-providers/src/MockedAppRootBuilder.tsx
Modified querySubscriptions to return this.subscriptions ?? [] instead of this.subscriptions. Changed private field subscriptions from SubscriptionWithRoom[] to `SubscriptionWithRoom[]
Changeset Metadata
.changeset/modern-onions-repair.md
Recorded patch-level version updates for @rocket.chat/mock-providers and @rocket.chat/meteor with description of the leave room action fix.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RoomInfo as Room Info View
    participant Hook as useRoomLeave Hook
    participant API as useUserSubscription

    User->>RoomInfo: Opens room information panel
    RoomInfo->>Hook: Calls useRoomLeave(room)
    Hook->>API: Queries subscription for room._id
    
    alt User has subscription
        API-->>Hook: Returns subscription object
        Hook->>Hook: canLeave = true
        Hook-->>RoomInfo: Returns leave function
        RoomInfo->>RoomInfo: Shows Leave button
    else User lacks subscription
        API-->>Hook: Returns undefined
        Hook->>Hook: canLeave = false
        Hook-->>RoomInfo: Returns null
        RoomInfo->>RoomInfo: Hides Leave button
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Specific areas requiring attention:
    • Verification that useUserSubscription correctly retrieves subscription state for all room types
    • Confirmation that the mock provider's optional chaining (this.subscriptions ?? []) doesn't affect existing tests or providers
    • Test coverage completeness for edge cases (null/undefined room IDs, deleted subscriptions)

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • aleksandernsilva
  • ggazzo

Poem

🐰 A subscription check now guards the door,
No leave for those who joined before—nay, more!
If subscribed you are, the button you'll see,
If not, it's hidden—fair and free! 🎀

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: preventing the Leave room action from being available to users without subscription, which directly addresses the issue.
Linked Issues check ✅ Passed The PR changes directly address the linked issues by replacing the joined parameter with a subscription check in useRoomLeave, ensuring the Leave action is only available to subscribed users.
Out of Scope Changes check ✅ Passed All changes are scoped to the issue fix: removing the joined parameter, adding subscription-based presence checks, updating test coverage, and adjusting mock provider behavior for consistency.
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.
✨ 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 fix/leave-room-display

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.

@dougfabris dougfabris added this to the 7.13.0 milestone Nov 11, 2025
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.99%. Comparing base (0691514) to head (4364024).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37477      +/-   ##
===========================================
+ Coverage    68.97%   68.99%   +0.02%     
===========================================
  Files         3358     3358              
  Lines       114240   114241       +1     
  Branches     20537    20537              
===========================================
+ Hits         78792    78825      +33     
+ Misses       33359    33328      -31     
+ Partials      2089     2088       -1     
Flag Coverage Δ
e2e 57.44% <100.00%> (+<0.01%) ⬆️
e2e-api 43.86% <ø> (+1.04%) ⬆️

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.

@dougfabris dougfabris marked this pull request as ready for review November 14, 2025 17:44
@dougfabris dougfabris requested a review from a team as a code owner November 14, 2025 17:44
@aleksandernsilva
Copy link
Contributor

@dougfabris Could you add steps to reproduce to the PR description?

@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Nov 14, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Nov 14, 2025
@kodiakhq kodiakhq bot merged commit e1682d2 into develop Nov 14, 2025
46 checks passed
@kodiakhq kodiakhq bot deleted the fix/leave-room-display branch November 14, 2025 20:26
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.

Leave button for channels is available even if the user isn't subscribed to the channel

3 participants