Skip to content

fix: Do not register videoconf user for embedded layout#40982

Open
gabriellsh wants to merge 4 commits into
developfrom
fix/embeddedVideoconf
Open

fix: Do not register videoconf user for embedded layout#40982
gabriellsh wants to merge 4 commits into
developfrom
fix/embeddedVideoconf

Conversation

@gabriellsh

@gabriellsh gabriellsh commented Jun 16, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Embedded layout is supposed to be a controlable window that locks the user in that page, unless an external navigation (through window.postMessage) is triggered. Videoconf is not part of the supported features for embedded layout, and was incorrectly registering users that should not receive calls (those in embedded layout)

Issue(s)

Steps to test or reproduce

  • User A opens with regular layout
  • User B opens channel without User A with embedded layout (?layout=embedded in the URL)
  • User A calls User B

Further comments

Review in cubic

SUP-1056

Summary by CodeRabbit

  • Bug Fixes
    • Prevented crashes when receiving video conference calls in embedded layout mode.
    • Avoided unnecessary disconnect/reconnect work when a video conference user update is a no-op (same user while not transitioning from login and not currently connected).

@dionisio-bot

dionisio-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2821c72

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

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings 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

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ce636de5-dd3f-441b-90c8-a5bcfce3a777

📥 Commits

Reviewing files that changed from the base of the PR and between 2a3a771 and 2821c72.

📒 Files selected for processing (1)
  • apps/meteor/client/lib/VideoConfManager.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/lib/VideoConfManager.ts
📜 Recent review details
⏰ 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). (5)
  • GitHub Check: ⚙️ Variables Setup
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check

Walkthrough

VideoConfManager.updateUser gains an early-return guard when the incoming userId matches the current stored value. useUpdateVideoConfUser is updated to import useEmbeddedLayout and pass null to VideoConfManager.updateUser when the embedded layout flag is active, with embeddedLayout added to the effect dependency array.

Changes

VideoConf embedded layout and userId guard

Layer / File(s) Summary
VideoConfManager.updateUser early-exit guard
apps/meteor/client/lib/VideoConfManager.ts
Adds an identity check at the top of updateUser that returns immediately when the incoming userId equals the already-stored this.userId, preventing spurious disconnect/connect cycles.
useUpdateVideoConfUser embedded layout handling
apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts
Imports useEmbeddedLayout, reads the embedded layout flag, and passes null to VideoConfManager.updateUser when embedded; adds embeddedLayout to the effect dependency array.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 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 directly and clearly describes the main change: preventing videoconf user registration for embedded layout, which aligns with the core objective of the PR.
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.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • SUP-1056: Request failed with status code 401

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.

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.15%. Comparing base (236eef2) to head (2821c72).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40982      +/-   ##
===========================================
+ Coverage    70.14%   70.15%   +0.01%     
===========================================
  Files         3358     3358              
  Lines       129569   129572       +3     
  Branches     22457    22456       -1     
===========================================
+ Hits         90883    90899      +16     
+ Misses       35380    35360      -20     
- Partials      3306     3313       +7     
Flag Coverage Δ
e2e 59.31% <100.00%> (+0.01%) ⬆️
e2e-api 46.90% <ø> (-0.18%) ⬇️
unit 70.08% <ø> (+<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.

@cardoso cardoso force-pushed the fix/embeddedVideoconf branch from 23cf9b8 to 06e4987 Compare June 17, 2026 13:01
cardoso
cardoso previously approved these changes Jun 17, 2026

@cardoso cardoso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Confirmed the fix:

  1. User A opens with regular layout
  2. User B opens channel without User A with embedded layout
  3. User A calls User B

Before this fix: crash
After this fix: no crash

@gabriellsh gabriellsh marked this pull request as ready for review June 17, 2026 19:38
@gabriellsh gabriellsh requested a review from a team as a code owner June 17, 2026 19:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/meteor/client/lib/VideoConfManager.ts`:
- Around line 304-306: The guard condition in the updateUser method (checking if
userId === this.userId) returns early and prevents disconnect/reconnect logic
from executing when the connection state changes but userId remains the same.
Modify the guard to only return early when userId AND the connection/login state
are all unchanged; specifically, the early return should account for isConnected
and isLoggingIn changes in addition to userId identity, allowing the disconnect
logic (around lines 310-312) and reconnect logic (around lines 319-321) to
execute properly when connection or login state changes while userId stays the
same.
🪄 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: 6cb52afc-029d-4ee4-86c0-8c048136d062

📥 Commits

Reviewing files that changed from the base of the PR and between 236eef2 and ec47a8b.

📒 Files selected for processing (2)
  • apps/meteor/client/lib/VideoConfManager.ts
  • apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts
📜 Review details
⏰ 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). (4)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
🧰 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/lib/VideoConfManager.ts
  • apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts
🧠 Learnings (5)
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/lib/VideoConfManager.ts
  • apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/lib/VideoConfManager.ts
  • apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/lib/VideoConfManager.ts
  • apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/lib/VideoConfManager.ts
  • apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/lib/VideoConfManager.ts
  • apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts
🔇 Additional comments (3)
apps/meteor/client/views/root/hooks/loggedIn/useUpdateVideoConfUser.ts (3)

13-14: LGTM!


15-15: LGTM!


10-10: No action requireduseEmbeddedLayout() returns a stable boolean primitive.

The isEmbedded property in LayoutContextValue is typed as a boolean (not an object wrapper), and the context value is properly memoized in LayoutProvider.tsx. Boolean primitives are always stable references, so including embeddedLayout in the dependency array does not cause excessive re-runs.

			> Likely an incorrect or invalid review comment.

Comment thread apps/meteor/client/lib/VideoConfManager.ts Outdated

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found and verified against the latest diff

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/client/lib/VideoConfManager.ts Outdated
Fixes an issue with embedded layout where users were able to receive VideoConf calls, causing the application to crash
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.

2 participants