Skip to content

feat: Contact name and avatar resolution for external voice calls#40484

Open
aleksandernsilva wants to merge 3 commits into
developfrom
feat/voice-identity-lookup
Open

feat: Contact name and avatar resolution for external voice calls#40484
aleksandernsilva wants to merge 3 commits into
developfrom
feat/voice-identity-lookup

Conversation

@aleksandernsilva
Copy link
Copy Markdown
Contributor

@aleksandernsilva aleksandernsilva commented May 11, 2026

Proposed changes (including videos or screenshots)

This pull request introduces a new feature for SIP identity lookup via a user-defined custom field, improving the ability to match incoming SIP calls to Rocket.Chat users. It also enhances external call history records by storing additional contact information, and includes a migration to backfill missing contact names. Several settings and API changes support this new functionality, and internationalization updates provide user-facing descriptions.

SIP Identity Lookup Feature:

  • Added new settings to enable SIP identity lookup via a custom user field, with configuration options and alerts for recommended MongoDB indexing. [1] [2] [3] [4]
  • Extended the SIP settings structure and server logic to include the new identity lookup configuration, and ensured the CastDirector is configured accordingly. [1] [2] [3] [4] [5] [6]
  • Updated the CastDirector to look up users by the specified custom field if enabled, falling back to extension-based lookup. [1] [2] [3]

Call History Enhancements:

  • Added contactName and contactUsername fields to external call history items, and updated the service to populate these fields. [1] [2] [3]
  • Improved the API and client-side code to handle and display the new contact fields for external calls. [1] [2] [3]

Data Migration:

  • Introduced migration v336 to backfill missing contactName fields in existing external call history entries, using the extension as a fallback. [1] [2]

SIP Call Handling Improvements:

  • Enhanced SIP invite parsing to robustly extract the caller's display name from multiple SIP headers.

User Model Extension:

  • Added a new method to the user model for finding users by a custom field value, supporting the identity lookup feature. [1] [2]

Issue(s)

DMV-2
DMV-3

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • New Features

    • Added SIP identity lookup via custom fields to match external callers with Rocket.Chat users
    • External contacts in call history now display names, usernames, and avatars when available
    • Enhanced contact information rendering across media call views
  • Documentation

    • Added translation strings for SIP identity lookup configuration (English and Portuguese)

Review Change Stack

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 11, 2026

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
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

⚠️ No Changeset found

Latest commit: 9213b67

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Walkthrough

This PR introduces SIP identity lookup via custom fields, enriches external call history with contact metadata (name, username), and refactors VoIP peer information types to use an external boolean discriminant throughout the component hierarchy, replacing runtime property checks.

Changes

SIP Identity Lookup & Call History Enrichment

Layer / File(s) Summary
SIP Contracts & Settings
ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts, ee/packages/media-calls/src/definition/IMediaCallServer.ts, ee/packages/media-calls/src/definition/common.ts, ee/packages/media-calls/src/server/CastDirector.ts, ee/packages/media-calls/src/server/MediaCallServer.ts, ee/packages/media-calls/src/server/getDefaultSettings.ts, apps/meteor/ee/server/settings/voip.ts, ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
ICastDirectorSettings contract and configure() method enable identity lookup configuration; CastDirector now queries users by SIP identifier first, then custom field fallback; SIP invite headers are parsed with priority order (X-RocketChat-Caller-Name, p-asserted-identity, from); VoIP settings gate SIP identity lookup and connection parameters behind conditional enableQuery.
Call History Data & Enrichment
packages/core-typings/src/ICallHistoryItem.ts, packages/model-typings/src/models/IUsersModel.ts, packages/models/src/models/Users.ts, apps/meteor/server/services/media-call/service.ts, apps/meteor/app/api/server/v1/call-history.ts
IExternalMediaCallHistoryItem defines contactName and contactUsername as plain strings; UsersRaw.findOneByCustomFieldValue queries users by dynamic custom field; saveExternalCallToHistory populates contact name from displayName with fallback, and includes both name and username; API filtering expands $or to match on contactName and contactUsername regex patterns.
Call History UI Components
packages/ui-voip/src/components/CallHistoryExternalUser.tsx, apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx, apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx, packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx, packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx, packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
CallHistoryExternalUser now renders avatar from username and conditionally displays name; call history pages/tables map external contact fields (name, username, number); types make username optional and support name/username in contact objects.
PeerInfo Discriminated Union
packages/ui-voip/src/context/definitions.d.ts, packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx, packages/ui-voip/src/components/PeerInfo/InternalUser.tsx, packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx, packages/ui-voip/src/components/PeerInfo/index.ts, packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
PeerInfoProps becomes a discriminated union keyed by external: true | false; new ExternalUser component conditionally renders InternalUser or PhoneNumber; InternalUserProps is exported for reuse; stories demonstrate external peer rendering variants with/without displayName and avatarUrl.
PeerInfo Derivation Utilities
packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts, packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts, packages/ui-voip/src/providers/useMediaSession.ts
deriveExternalPeerInfoFromInstanceContact adds external: true and conditionally includes displayName; deriveInternalPeerInfoFromInstanceContact adds external: false; derivePeerInfoFromInstanceState sets external: false for unconfirmed calls; useMediaSession injects external field and refactors avatar URL computation from contact username or user id.
PeerInfo Hooks & Providers
packages/ui-voip/src/context/usePeerAutocomplete.ts, packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
usePeerAutocomplete passes external: true when selecting first-option phone number, and external: false when selecting existing peer; MockedMediaCallProvider sets external: false in mock peerInfo state and returned values.
PeerInfo View Components
packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx, packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx, packages/ui-voip/src/hooks/useMediaCallAction.ts
OngoingCall/OngoingCallWithScreen conditionally add slots and remoteMuted props based on peerInfo.external; hangup button user label uses peerInfo.displayName || peerInfo.number for external, peerInfo.displayName otherwise; useMediaCallAction simplifies displayName derivation with direct fallback.
Tests & Internationalization
packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx, packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx, packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx, packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts, packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts, packages/i18n/src/locales/en.i18n.json, packages/i18n/src/locales/pt-BR.i18n.json
Test fixtures updated to include external boolean flag in all PeerInfo expectations across hooks, derivation utilities, and view components; SIP identity lookup i18n strings added (enabled label, database index alert, custom field name/description) in English and Portuguese.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • RocketChat/Rocket.Chat#39870: Reorganizes media-signaling exports and introduces AnyMediaCallData/getState patterns that align with this PR's use of instance.getState and participant contact derivation in PeerInfo utilities.
🚥 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 'feat: Contact name and avatar resolution for external voice calls' accurately and concisely describes the main objective of the PR, which is to add contact name and avatar resolution capabilities for external voice calls through identity lookup.
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 (2)
  • DMV-2: Request failed with status code 401
  • DMV-3: Request failed with status code 401

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 aleksandernsilva force-pushed the feat/voice-identity-lookup branch 2 times, most recently from fc5e7a7 to cc1ce77 Compare May 11, 2026 22:38
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 80.35714% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.61%. Comparing base (6b2afb3) to head (9213b67).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40484      +/-   ##
===========================================
- Coverage    69.64%   69.61%   -0.04%     
===========================================
  Files         3318     3321       +3     
  Lines       121981   122571     +590     
  Branches     21791    21922     +131     
===========================================
+ Hits         84948    85322     +374     
- Misses       33701    33916     +215     
- Partials      3332     3333       +1     
Flag Coverage Δ
e2e 59.02% <ø> (+0.01%) ⬆️
e2e-api 46.27% <66.66%> (-0.08%) ⬇️
unit 70.36% <81.13%> (-0.09%) ⬇️

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 force-pushed the feat/voice-identity-lookup branch from cc1ce77 to 060cfd3 Compare May 12, 2026 13:49
@aleksandernsilva
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

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

@coderabbitai coderabbitai Bot added the type: feature Pull requests that introduces new feature label May 12, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ee/packages/media-calls/src/server/CastDirector.ts (1)

95-97: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Preserve SIP contact when user is resolved via custom field.

At Line 95, a custom-field match without freeSwitchExtension builds a list with sip: null, so requiredType: 'sip' can incorrectly return null for a valid SIP identifier.

🔧 Proposed fix
-		const list = user
-			? this.buildContactListForUser(user, defaultContactInfo)
+		const list = user
+			? this.buildContactListForUser({ ...user, freeSwitchExtension: user.freeSwitchExtension ?? sipExtension }, defaultContactInfo)
 			: this.buildContactListForExtension(sipExtension, defaultContactInfo);
🤖 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 `@ee/packages/media-calls/src/server/CastDirector.ts` around lines 95 - 97, The
contact list creation can end up with sip: null when a user is matched via a
custom field but lacks freeSwitchExtension; update the logic so
buildContactListForUser (or the place that constructs the contact object after
resolving user) preserves or falls back to the provided sipExtension (the
sipExtension parameter passed into the ternary) when the resolved user's
freeSwitchExtension/contact.sip is missing — i.e., if contact.sip is falsy,
assign sipExtension before returning the list so requiredType: 'sip' will return
a valid SIP identifier; ensure similar fallback is not needed in
buildContactListForExtension which already consumes sipExtension.
🧹 Nitpick comments (1)
packages/models/src/models/Users.ts (1)

2768-2775: ⚡ Quick win

Consider adding active user filter for identity lookup use case.

The new findOneByCustomFieldValue method doesn't filter by active: true. Based on the PR context (SIP identity lookup for external calls), you likely want to match only active users. Other similar lookup methods like findOneByFreeSwitchExtension also don't filter by active status, but for identity resolution in active call scenarios, filtering inactive users would be safer.

💡 Suggested refinement
 findOneByCustomFieldValue<T extends Document = IUser>(fieldName: string, value: unknown, options: FindOptions<IUser> = {}) {
   return this.findOne<T>(
     {
+      active: true,
       [`customFields.${fieldName}`]: value,
     } as Filter<IUser>,
     options,
   );
 }
🤖 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/models/src/models/Users.ts` around lines 2768 - 2775, The
findOneByCustomFieldValue method currently queries only on customFields and
should also restrict to active users for identity lookup; update the query
inside findOneByCustomFieldValue (and consider same for
findOneByFreeSwitchExtension if relevant) to include active: true (e.g., merge
`{ active: true }` with the existing filter or use an $and array) so the
returned IUser is guaranteed active while preserving the provided options and
types (keep the existing T extends Document and Filter<IUser> usage).
🤖 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.

Outside diff comments:
In `@ee/packages/media-calls/src/server/CastDirector.ts`:
- Around line 95-97: The contact list creation can end up with sip: null when a
user is matched via a custom field but lacks freeSwitchExtension; update the
logic so buildContactListForUser (or the place that constructs the contact
object after resolving user) preserves or falls back to the provided
sipExtension (the sipExtension parameter passed into the ternary) when the
resolved user's freeSwitchExtension/contact.sip is missing — i.e., if
contact.sip is falsy, assign sipExtension before returning the list so
requiredType: 'sip' will return a valid SIP identifier; ensure similar fallback
is not needed in buildContactListForExtension which already consumes
sipExtension.

---

Nitpick comments:
In `@packages/models/src/models/Users.ts`:
- Around line 2768-2775: The findOneByCustomFieldValue method currently queries
only on customFields and should also restrict to active users for identity
lookup; update the query inside findOneByCustomFieldValue (and consider same for
findOneByFreeSwitchExtension if relevant) to include active: true (e.g., merge
`{ active: true }` with the existing filter or use an $and array) so the
returned IUser is guaranteed active while preserving the provided options and
types (keep the existing T extends Document and Filter<IUser> usage).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec461bdb-af54-4ba3-b521-d62645a003ec

📥 Commits

Reviewing files that changed from the base of the PR and between 6b2afb3 and 060cfd3.

⛔ Files ignored due to path filters (3)
  • packages/ui-voip/src/components/PeerInfo/__snapshots__/PeerInfo.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/CallHistoryContextualbar/__snapshots__/CallHistoryContextualbar.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/MediaCallHistoryTable/__snapshots__/MediaCallHistoryTable.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (41)
  • apps/meteor/app/api/server/v1/call-history.ts
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • apps/meteor/ee/server/settings/voip.ts
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/server/startup/migrations/index.ts
  • apps/meteor/server/startup/migrations/v336.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/i18n/src/locales/pt-BR.i18n.json
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/models/src/models/Users.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
📜 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). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • apps/meteor/server/startup/migrations/v336.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/startup/migrations/index.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/ee/server/settings/voip.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/models/src/models/Users.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
🧠 Learnings (11)
📚 Learning: 2026-02-26T19:22:29.385Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryActions.tsx:40-40
Timestamp: 2026-02-26T19:22:29.385Z
Learning: For TSX files in the UI VOIP package, ensure that when a media session state is 'unavailable', the voiceCall action is excluded from the actions object passed to CallHistoryActions so it does not render in the menu. This filtering should occur upstream (before getItems is called) to avoid tooltips or UI hints for unavailable actions. If there are multiple actions with availability states, implement a centralized helper to filter actions based on session state.

Applied to files:

  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
📚 Learning: 2026-05-05T12:34:29.042Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 40331
File: packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx:69-69
Timestamp: 2026-05-05T12:34:29.042Z
Learning: In Rocket.Chat’s `packages/ui-voip` UI (e.g., media/call widgets), voice/media calls are only supported in Direct Message (DM) rooms. Rocket.Chat models a DM as a “room” with exactly two participants, so handlers like `onClickDirectMessage` are the correct destination—even when the UI text/element says “Open in room” (e.g., on the shared screen card/`StreamCard`). During review, don’t flag a “DM vs room” mismatch for these cases; they intentionally map to the same destination.

Applied to files:

  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
📚 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/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • apps/meteor/server/startup/migrations/v336.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/startup/migrations/index.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/ee/server/settings/voip.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/models/src/models/Users.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/server/startup/migrations/v336.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/startup/migrations/index.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/ee/server/settings/voip.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/models/src/models/Users.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/server/startup/migrations/v336.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/startup/migrations/index.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • apps/meteor/server/services/media-call/service.ts
  • apps/meteor/ee/server/settings/voip.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • packages/models/src/models/Users.ts
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
Learning: Adopt the monorepo-wide Jest testMatch pattern: <rootDir>/src/**/*.spec.{ts,js,mjs} (represented here as '**/src/**/*.spec.{ts,js,mjs}') to ensure spec files under any package's src directory are picked up consistently across all packages in the Rocket.Chat monorepo. Apply this pattern in jest.config.ts for all relevant packages to maintain uniform test discovery.

Applied to files:

  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
📚 Learning: 2026-02-23T17:53:06.802Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:06.802Z
Learning: During PR reviews that touch endpoint files under apps/meteor/app/api/server/v1, enforce strict scope: if a PR targets a specific endpoint (e.g., rooms.favorite), do not propose changes to unrelated endpoints (e.g., rooms.invite) unless maintainers explicitly request them. Focus feedback on the touched endpoint's behavior, API surface, and related tests; avoid broad cross-endpoint changes in the same PR unless requested.

Applied to files:

  • apps/meteor/app/api/server/v1/call-history.ts
📚 Learning: 2026-02-24T19:09:01.522Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:01.522Z
Learning: In Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1, avoid introducing logic changes. Only perform scope-tight changes that preserve behavior; style-only cleanups (e.g., removing inline comments) may be deferred to follow-ups to keep the migration PR focused.

Applied to files:

  • apps/meteor/app/api/server/v1/call-history.ts
🔇 Additional comments (42)
packages/ui-voip/src/components/PeerInfo/InternalUser.tsx (1)

6-6: LGTM!

packages/ui-voip/src/context/definitions.d.ts (1)

5-5: LGTM!

Also applies to: 15-18

packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts (1)

8-8: LGTM!

packages/ui-voip/src/providers/MockedMediaCallProvider.tsx (1)

36-36: LGTM!

Also applies to: 89-89

packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts (1)

32-32: LGTM!

Also applies to: 72-72, 108-108

packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts (1)

11-11: LGTM!

Also applies to: 13-13, 23-23

packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts (1)

13-13: LGTM!

Also applies to: 23-23, 34-34, 39-50, 63-63, 76-76, 93-93, 108-108

packages/ui-voip/src/providers/useMediaSession.ts (1)

145-145: LGTM!

Also applies to: 178-188, 194-197, 214-217

packages/ui-voip/src/hooks/useMediaCallAction.ts (1)

25-25: LGTM!

packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx (1)

76-76: LGTM!

Also applies to: 101-101, 135-135, 159-159

packages/ui-voip/src/context/usePeerAutocomplete.ts (1)

68-68: LGTM!

Also applies to: 79-79

packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx (1)

128-128: LGTM!

Also applies to: 169-169, 181-181, 195-195, 209-209

packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx (1)

4-8: LGTM!

Also applies to: 10-16, 18-18

packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx (1)

5-5: LGTM!

Also applies to: 8-9, 12-12

packages/ui-voip/src/components/PeerInfo/index.ts (1)

2-2: LGTM!

packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx (1)

65-66: LGTM!

Also applies to: 68-70, 72-90

packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx (1)

66-66: LGTM!

Also applies to: 108-110

packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx (1)

53-53: LGTM!

Also applies to: 77-79

packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx (1)

122-122: LGTM!

Also applies to: 133-133, 168-168, 190-190, 251-251, 272-272, 306-306, 324-324

packages/i18n/src/locales/pt-BR.i18n.json (1)

5842-5845: LGTM!

packages/i18n/src/locales/en.i18n.json (1)

5862-5865: LGTM!

ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts (1)

459-484: LGTM!

Also applies to: 490-490, 492-492

ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts (1)

7-12: LGTM!

Also applies to: 39-39

apps/meteor/ee/server/settings/voip.ts (1)

42-76: LGTM!

Also applies to: 81-81, 88-88, 95-95, 102-102, 109-109

apps/meteor/server/startup/migrations/index.ts (1)

44-44: LGTM!

ee/packages/media-calls/src/server/getDefaultSettings.ts (1)

11-14: LGTM!

apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx (1)

18-19: LGTM!

apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx (1)

137-137: LGTM!

ee/packages/media-calls/src/server/MediaCallServer.ts (1)

13-13: LGTM!

Also applies to: 144-144

apps/meteor/app/api/server/v1/call-history.ts (1)

124-135: LGTM!

packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx (1)

81-90: LGTM!

ee/packages/media-calls/src/definition/IMediaCallServer.ts (1)

25-28: LGTM!

packages/core-typings/src/ICallHistoryItem.ts (1)

51-52: LGTM!

apps/meteor/server/services/media-call/service.ts (2)

186-200: LGTM!


392-395: LGTM!

packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx (2)

33-34: LGTM!


86-86: LGTM!

apps/meteor/server/startup/migrations/v336.ts (1)

5-25: LGTM!

packages/model-typings/src/models/IUsersModel.ts (1)

445-445: LGTM!

packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx (1)

14-15: LGTM!

Also applies to: 71-73

packages/ui-voip/src/components/CallHistoryExternalUser.tsx (1)

1-3: LGTM!

Also applies to: 7-8, 12-19, 22-22, 28-31

ee/packages/media-calls/src/server/CastDirector.ts (1)

5-8: LGTM!

Also applies to: 16-20, 93-94, 102-126

@aleksandernsilva aleksandernsilva force-pushed the feat/voice-identity-lookup branch 2 times, most recently from 4f16bb1 to 22816c4 Compare May 12, 2026 14:41
@aleksandernsilva aleksandernsilva force-pushed the feat/voice-identity-lookup branch from 22816c4 to 9213b67 Compare May 12, 2026 18:54
@aleksandernsilva aleksandernsilva marked this pull request as ready for review May 12, 2026 21:09
@aleksandernsilva aleksandernsilva requested review from a team as code owners May 12, 2026 21:09
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 `@ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts`:
- Around line 442-467: getDisplayNameFromInvite returns early when a
higher-priority header exists but normalizes to an empty/whitespace string;
update the checks in getDisplayNameFromInvite so that after calling removeQuotes
on each header value (X-RocketChat-Caller-Name, p-asserted-identity.name,
from.name) you only return that value if the result is non-empty (e.g., trimmed
length > 0), otherwise continue to the next header; ensure removeQuotes is used
consistently for all three header branches so empty/whitespace names are skipped
and lower-priority headers can be considered.
🪄 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: 55117612-aef2-4b1c-9cc9-888f10b1411c

📥 Commits

Reviewing files that changed from the base of the PR and between 060cfd3 and 9213b67.

⛔ Files ignored due to path filters (3)
  • packages/ui-voip/src/components/PeerInfo/__snapshots__/PeerInfo.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/CallHistoryContextualbar/__snapshots__/CallHistoryContextualbar.spec.tsx.snap is excluded by !**/*.snap
  • packages/ui-voip/src/views/MediaCallHistoryTable/__snapshots__/MediaCallHistoryTable.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (40)
  • apps/meteor/app/api/server/v1/call-history.ts
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • apps/meteor/ee/server/settings/voip.ts
  • apps/meteor/server/services/media-call/service.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/CastDirector.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/i18n/src/locales/pt-BR.i18n.json
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/models/src/models/Users.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
💤 Files with no reviewable changes (1)
  • apps/meteor/app/api/server/v1/call-history.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/ui-voip/src/providers/MockedMediaCallProvider.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.spec.ts
  • packages/i18n/src/locales/pt-BR.i18n.json
🚧 Files skipped from review as they are similar to previous changes (31)
  • packages/ui-voip/src/hooks/useMediaCallAction.ts
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.spec.ts
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • ee/packages/media-calls/src/definition/IMediaCallServer.ts
  • packages/ui-voip/src/components/PeerInfo/ExternalUser.tsx
  • packages/ui-voip/src/components/PeerInfo/InternalUser.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceState.ts
  • ee/packages/media-calls/src/server/getDefaultSettings.ts
  • packages/core-typings/src/ICallHistoryItem.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCall.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/hooks/useMediaCallAction.spec.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
  • ee/packages/media-calls/src/definition/IMediaCallCastDirector.ts
  • apps/meteor/server/services/media-call/service.ts
  • packages/ui-voip/src/components/PeerInfo/index.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/models/src/models/Users.ts
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.stories.tsx
  • packages/ui-voip/src/utils/derivePeerInfoFromInstanceContact.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx
  • packages/ui-voip/src/components/PeerInfo/PeerInfo.tsx
  • packages/ui-voip/src/context/usePeekMediaSessionPeerInfo.spec.tsx
  • apps/meteor/ee/server/settings/voip.ts
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/context/usePeerAutocomplete.spec.tsx
  • ee/packages/media-calls/src/server/CastDirector.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
📜 Review details
🧰 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/mediaCallHistory/CallHistoryPage.tsx
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
🧠 Learnings (4)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
📚 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/views/mediaCallHistory/CallHistoryPage.tsx
  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.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:

  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.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:

  • ee/packages/media-calls/src/definition/common.ts
  • ee/packages/media-calls/src/server/MediaCallServer.ts
  • ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
  • packages/ui-voip/src/context/usePeerAutocomplete.ts
🔇 Additional comments (6)
ee/packages/media-calls/src/server/MediaCallServer.ts (1)

13-13: LGTM!

apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx (1)

137-137: LGTM!

ee/packages/media-calls/src/definition/common.ts (1)

9-9: LGTM!

ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts (1)

472-472: LGTM!

Also applies to: 474-474, 483-487

packages/ui-voip/src/context/usePeerAutocomplete.ts (2)

79-84: LGTM!


68-69: 🏗️ Heavy lift

No action required. The code at lines 68-69 properly implements the discriminated union pattern with complete type safety.

The PeerInfo type is correctly defined in definitions.d.ts as a union of InternalPeerInfo (with external: false) and ExternalPeerInfo (with external: true). The external peer creation at line 68 correctly provides all required fields (external and number), and consumers like TransferModal.tsx properly distinguish between variants using field presence checks ('userId' in peer and 'number' in peer).

Comment on lines +442 to 467
private static getDisplayNameFromInvite(req: SrfRequest): string | undefined {
const removeQuotes = (str: string): string => str.replace(/^"|"$/g, '').trim();

if (req.callingNumber && typeof req.callingNumber === 'string') {
const userContact = await mediaCallDirector.cast.getContactForExtensionNumber(req.callingNumber, { preferredType: 'sip' });
if (userContact) {
return userContact;
if (req.has('X-RocketChat-Caller-Name')) {
const headerValue = req.get('X-RocketChat-Caller-Name');
if (headerValue) {
return removeQuotes(headerValue);
}
}

return null;
if (req.has('p-asserted-identity')) {
const pAssertedIdentity = req.getParsedHeader('p-asserted-identity');
if (pAssertedIdentity?.name) {
return removeQuotes(pAssertedIdentity.name);
}
}

if (req.has('from')) {
const fromHeader = req.getParsedHeader('from');
if (fromHeader?.name) {
return removeQuotes(fromHeader.name);
}
}

return undefined;
}
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Skip empty/whitespace display-name values before returning.

If a higher-priority header exists but normalizes to an empty string, the function returns too early and ignores lower-priority headers with valid names.

Suggested fix
 private static getDisplayNameFromInvite(req: SrfRequest): string | undefined {
-	const removeQuotes = (str: string): string => str.replace(/^"|"$/g, '').trim();
+	const normalizeDisplayName = (str?: string): string | undefined => {
+		if (!str) {
+			return undefined;
+		}
+		const normalized = str.replace(/^"|"$/g, '').trim();
+		return normalized.length > 0 ? normalized : undefined;
+	};

 	if (req.has('X-RocketChat-Caller-Name')) {
-		const headerValue = req.get('X-RocketChat-Caller-Name');
-		if (headerValue) {
-			return removeQuotes(headerValue);
+		const headerValue = normalizeDisplayName(req.get('X-RocketChat-Caller-Name'));
+		if (headerValue) {
+			return headerValue;
 		}
 	}

 	if (req.has('p-asserted-identity')) {
 		const pAssertedIdentity = req.getParsedHeader('p-asserted-identity');
-		if (pAssertedIdentity?.name) {
-			return removeQuotes(pAssertedIdentity.name);
+		const assertedName = normalizeDisplayName(pAssertedIdentity?.name);
+		if (assertedName) {
+			return assertedName;
 		}
 	}

 	if (req.has('from')) {
 		const fromHeader = req.getParsedHeader('from');
-		if (fromHeader?.name) {
-			return removeQuotes(fromHeader.name);
+		const fromName = normalizeDisplayName(fromHeader?.name);
+		if (fromName) {
+			return fromName;
 		}
 	}

 	return undefined;
 }
🤖 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 `@ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts` around lines
442 - 467, getDisplayNameFromInvite returns early when a higher-priority header
exists but normalizes to an empty/whitespace string; update the checks in
getDisplayNameFromInvite so that after calling removeQuotes on each header value
(X-RocketChat-Caller-Name, p-asserted-identity.name, from.name) you only return
that value if the result is non-empty (e.g., trimmed length > 0), otherwise
continue to the next header; ensure removeQuotes is used consistently for all
three header branches so empty/whitespace names are skipped and lower-priority
headers can be considered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant