Skip to content

fix(ui-voip): Sync voice call UI state on mount in useMediaSession - #41060

Merged
ggazzo merged 2 commits into
release-8.6.0from
fix/media-call-sync
Jun 23, 2026
Merged

fix(ui-voip): Sync voice call UI state on mount in useMediaSession#41060
ggazzo merged 2 commits into
release-8.6.0from
fix/media-call-sync

Conversation

@aleksandernsilva

@aleksandernsilva aleksandernsilva commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

useMediaSession subscribed to sessionStateChange events but never read the current session state on mount, relying on a side effect of the old setDeviceId reference-equality bug to trigger an initial sync.
After e626fb9 fixed setDeviceId to use value-based comparison, that accidental sync no longer fires, leaving the hook stuck at the default closed state when a MediaCallViewProvider mounts with an already-active call.

Calling updateSessionState() immediately after subscribing ensures the hook reads the real session state on mount, fixing the popout opening in the ended state, MediaCallRoomSection not rendering, and call actions not reflecting live state.

Issue(s)

CORE-2306

Steps to test or reproduce

Further comments

Review in cubic

Summary by CodeRabbit

Bug Fixes

  • Fixed voice call UI state so it correctly reflects an already-active call when opening new views/windows during an ongoing session.
  • Improved reliability of audio input handling during voice calls by better detecting when the selected device changes, reducing failures when switching contexts (e.g., moving between rooms right as a call starts).

@dionisio-bot

dionisio-bot Bot commented Jun 23, 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 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c562f73

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

This PR includes changesets to release 2 packages
Name Type
@rocket.chat/media-signaling Patch
@rocket.chat/ui-voip 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 23, 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: 1567b748-e4b8-41d1-8760-e5823ab425b1

📥 Commits

Reviewing files that changed from the base of the PR and between 98fe35e and c562f73.

📒 Files selected for processing (5)
  • .changeset/tricky-comics-wink.md
  • .changeset/wise-years-shout.md
  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/utils/isSameDeviceId.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
✅ Files skipped from review due to trivial changes (3)
  • .changeset/tricky-comics-wink.md
  • .changeset/wise-years-shout.md
  • packages/ui-voip/src/providers/useMediaSession.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • 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:

  • packages/media-signaling/src/lib/utils/isSameDeviceId.ts
  • packages/media-signaling/src/lib/Session.ts
🧠 Learnings (3)
📚 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/utils/isSameDeviceId.ts
  • packages/media-signaling/src/lib/Session.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/utils/isSameDeviceId.ts
  • packages/media-signaling/src/lib/Session.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/utils/isSameDeviceId.ts
  • packages/media-signaling/src/lib/Session.ts
🔇 Additional comments (2)
packages/media-signaling/src/lib/utils/isSameDeviceId.ts (1)

1-71: LGTM!

packages/media-signaling/src/lib/Session.ts (1)

19-19: LGTM!

Also applies to: 253-253


Walkthrough

VoIP session UI state synchronizes immediately when views mount via useMediaSession's eager updateSessionState() call. Device ID equality comparison is added via a normalized isSameDeviceId utility to prevent unnecessary audio track switching.

Changes

VoIP Session State Fix

Layer / File(s) Summary
Immediate session state sync on mount
packages/ui-voip/src/providers/useMediaSession.ts, .changeset/wise-years-shout.md
useMediaSession invokes updateSessionState() during useEffect initialization when instance is available, ensuring newly mounted views reflect any already-active call without waiting for subsequent events. The changeset records this as a @rocket.chat/ui-voip patch.

Device ID Equality Comparison

Layer / File(s) Summary
Device ID equality utility
packages/media-signaling/src/lib/utils/isSameDeviceId.ts
New utility implements isSameDeviceId() that normalizes variable deviceId inputs (string, array, or constraint object with exact/ideal keys) and performs deduplicated set-like comparison on both the exact and ideal arrays to determine semantic equivalence.
Device ID equality integration in Session
packages/media-signaling/src/lib/Session.ts, .changeset/tricky-comics-wink.md
MediaSignalingSession.setDeviceId replaces strict === comparison with isSameDeviceId() when checking if a device change should trigger input track switching, preventing unnecessary transitions when IDs are semantically equivalent. The changeset documents this as a @rocket.chat/media-signaling patch for voice-call failures during room navigation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • RocketChat/Rocket.Chat#40422: Refactors input audio track switching and device-tracking in the same setDeviceId path that now uses the normalized isSameDeviceId comparison.
  • RocketChat/Rocket.Chat#41044: Directly related device-ID comparison fix for preventing unnecessary track switching during connection setup.

Suggested reviewers

  • tassoevan
  • ggazzo
🚥 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 title clearly identifies the main change: calling updateSessionState() on mount in useMediaSession to sync UI state, which is the primary fix described in the PR objectives.
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.

@aleksandernsilva aleksandernsilva changed the title fix: sync voice call UI state on mount in useMediaSession fix(ui-voip): Sync voice call UI state on mount in useMediaSession Jun 23, 2026
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.6.0@5d5edd8). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##             release-8.6.0   #41060   +/-   ##
================================================
  Coverage                 ?   70.14%           
================================================
  Files                    ?     3361           
  Lines                    ?   129699           
  Branches                 ?    22453           
================================================
  Hits                     ?    90983           
  Misses                   ?    35400           
  Partials                 ?     3316           
Flag Coverage Δ
e2e 59.37% <ø> (?)
e2e-api 47.16% <ø> (?)
unit 70.03% <0.00%> (?)

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.

@aleksandernsilva
aleksandernsilva marked this pull request as ready for review June 23, 2026 19:42
gabriellsh
gabriellsh previously approved these changes Jun 23, 2026
@aleksandernsilva aleksandernsilva added the stat: QA assured Means it has been tested and approved by a company insider label Jun 23, 2026

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

No issues found across 2 files

Re-trigger cubic

@aleksandernsilva aleksandernsilva added this to the 8.6.0 milestone Jun 23, 2026
@aleksandernsilva
aleksandernsilva changed the base branch from develop to release-8.6.0 June 23, 2026 19:59
@ggazzo
ggazzo merged commit 9861932 into release-8.6.0 Jun 23, 2026
47 checks passed
@ggazzo
ggazzo deleted the fix/media-call-sync branch June 23, 2026 21:14
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 type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants