Skip to content

fix: voice call fails if user navigates during initial connection - #41044

Merged
ggazzo merged 2 commits into
release-8.6.0from
fix/voip-deviceid-change
Jun 23, 2026
Merged

fix: voice call fails if user navigates during initial connection#41044
ggazzo merged 2 commits into
release-8.6.0from
fix/voip-deviceid-change

Conversation

@pierre-lehnen-rc

@pierre-lehnen-rc pierre-lehnen-rc commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

Issue(s)

CORE-2306

Steps to test or reproduce

Further comments

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Fixed voice call failures that could occur when switching rooms during the initial connection, improving reliability and preventing early termination in navigation scenarios.
    • Improved device ID change detection to better determine when an incoming device identifier matches the currently active one, reducing unnecessary updates during connection setup.

@dionisio-bot

dionisio-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fac1ccd

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

This PR includes changesets to release 1 package
Name Type
@rocket.chat/media-signaling 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 22, 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: 7da2b0ff-2409-4e02-88df-590e8dacf575

📥 Commits

Reviewing files that changed from the base of the PR and between cfe6085 and fac1ccd.

📒 Files selected for processing (1)
  • packages/media-signaling/src/lib/utils/isSameDeviceId.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/media-signaling/src/lib/utils/isSameDeviceId.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build

Walkthrough

Adds a new isSameDeviceId utility that normalizes ConstrainDOMString | null device identifiers into { exact, ideal } arrays and compares them as sets. Session.setDeviceId now uses this utility instead of a strict === check in its early-return guard. A patch changeset entry is included.

Changes

Device ID comparison fix for voice calls

Layer / File(s) Summary
isSameDeviceId utility
packages/media-signaling/src/lib/utils/isSameDeviceId.ts
Adds ensureStringArray (normalizes to string[]), normalizeDeviceId (converts ConstrainDOMString | null to { exact, ideal }), isSameStringArray (set equality via Set), and the exported isSameDeviceId that short-circuits on strict equality/nullish, then delegates to the normalized set comparison.
setDeviceId guard update and changeset
packages/media-signaling/src/lib/Session.ts, .changeset/tricky-comics-wink.md
Imports isSameDeviceId and replaces the deviceId === this.currentDeviceId check in the setDeviceId early-return condition with the new utility. Patch changeset added for @rocket.chat/media-signaling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and specifically describes the main fix: preventing voice call failures when users navigate during initial connection, which matches the changeset and implementation focus.
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)
  • CORE-2306: 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.

@pierre-lehnen-rc pierre-lehnen-rc added the stat: QA assured Means it has been tested and approved by a company insider label Jun 22, 2026
@pierre-lehnen-rc
pierre-lehnen-rc marked this pull request as ready for review June 22, 2026 20:27

@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.

🧹 Nitpick comments (1)
packages/media-signaling/src/lib/utils/isSameDeviceId.ts (1)

55-71: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Add targeted tests for isSameDeviceId equivalence rules.

This function defines subtle equality semantics (string vs { exact }, order-insensitive arrays, duplicate collapsing, null/empty-object normalization). Please add focused unit tests to lock this contract and prevent regressions in setDeviceId gating.

🤖 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 `@packages/media-signaling/src/lib/utils/isSameDeviceId.ts` around lines 55 -
71, Add targeted unit tests for the isSameDeviceId function to verify its subtle
equality semantics. The tests should cover: comparing string device IDs versus
normalized exact objects, verifying array order-insensitivity for both exact and
ideal properties, confirming duplicate value collapsing, and validating null and
empty-object normalization behavior. These tests should comprehensively lock the
contract to prevent regressions in setDeviceId gating logic that depends on this
function.
🤖 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 `@packages/media-signaling/src/lib/utils/isSameDeviceId.ts`:
- Around line 55-71: Add targeted unit tests for the isSameDeviceId function to
verify its subtle equality semantics. The tests should cover: comparing string
device IDs versus normalized exact objects, verifying array order-insensitivity
for both exact and ideal properties, confirming duplicate value collapsing, and
validating null and empty-object normalization behavior. These tests should
comprehensively lock the contract to prevent regressions in setDeviceId gating
logic that depends on this function.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 752536ec-6ca9-4aa5-80f4-deb73f8ba587

📥 Commits

Reviewing files that changed from the base of the PR and between ffaa115 and cfe6085.

📒 Files selected for processing (3)
  • .changeset/tricky-comics-wink.md
  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/utils/isSameDeviceId.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 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:

  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/utils/isSameDeviceId.ts
🧠 Learnings (4)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/tricky-comics-wink.md
📚 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:

  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/utils/isSameDeviceId.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:

  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/utils/isSameDeviceId.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:

  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/utils/isSameDeviceId.ts
🔇 Additional comments (2)
packages/media-signaling/src/lib/Session.ts (1)

19-19: LGTM!

Also applies to: 253-253

.changeset/tricky-comics-wink.md (1)

1-5: LGTM!

@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 across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/media-signaling/src/lib/utils/isSameDeviceId.ts">

<violation number="1" location="packages/media-signaling/src/lib/utils/isSameDeviceId.ts:33">
P1: Plain deviceId string/array is normalized as exact instead of ideal, changing ConstrainDOMString semantics. Device constraint-strength changes (ideal vs exact) can be misdetected as unchanged.</violation>
</file>

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

Re-trigger cubic

Comment thread packages/media-signaling/src/lib/utils/isSameDeviceId.ts Outdated
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.16%. Comparing base (7b54fb7) to head (fac1ccd).
⚠️ Report is 3 commits behind head on release-8.6.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           release-8.6.0   #41044      +/-   ##
=================================================
- Coverage          70.19%   70.16%   -0.03%     
=================================================
  Files               3360     3361       +1     
  Lines             129668   129690      +22     
  Branches           22485    22467      -18     
=================================================
- Hits               91017    91000      -17     
- Misses             35339    35378      +39     
  Partials            3312     3312              
Flag Coverage Δ
unit 70.07% <ø> (-0.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.

@ggazzo ggazzo added this to the 8.7.0 milestone Jun 23, 2026
@pierre-lehnen-rc
pierre-lehnen-rc changed the base branch from develop to release-8.6.0 June 23, 2026 13:54
@pierre-lehnen-rc pierre-lehnen-rc modified the milestones: 8.7.0, 8.6.0 Jun 23, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 23, 2026
@ggazzo
ggazzo merged commit 5d5edd8 into release-8.6.0 Jun 23, 2026
114 of 120 checks passed
@ggazzo
ggazzo deleted the fix/voip-deviceid-change branch June 23, 2026 14:17
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 type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants