Skip to content

refactor: rendering of call history contact information#40773

Merged
ggazzo merged 2 commits into
developfrom
chore/call-history-contact
Jun 3, 2026
Merged

refactor: rendering of call history contact information#40773
ggazzo merged 2 commits into
developfrom
chore/call-history-contact

Conversation

@pierre-lehnen-rc
Copy link
Copy Markdown
Contributor

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

Proposed changes (including videos or screenshots)

Reorganizes how the call history views handle rendering of contact information

Issue(s)

Derived from DMV-7

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Refactor
    • Unified contact handling and rendering for call history entries, resulting in more consistent display across internal, external, and unknown callers.
    • Improved handling of external/unnamed callers so they appear as "unknown" when name/username are missing.
    • Contact actions and row options preserved but now routed through the shared contact renderer for consistent behavior.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Jun 2, 2026

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Walkthrough

Centralizes call-history contact types into a shared definitions module, adds a CallHistoryUser router component, and updates renderers, pages, table rows, contextual bar, and a hook to use the unified contact API.

Changes

Call History Contact Unification

Layer / File(s) Summary
Contact type definitions and type guards
packages/ui-voip/src/definitions/callHistoryContacts.ts, packages/ui-voip/src/definitions/index.ts, packages/ui-voip/src/index.ts
Centralize CallHistoryInternalContact, CallHistoryExternalContact, CallHistoryUnknownContact, CallHistoryContact and three exported type-guard functions; re-export from barrels.
Base contact renderer components
packages/ui-voip/src/components/CallHistoryInternalUser.tsx, packages/ui-voip/src/components/CallHistoryExternalUser.tsx, packages/ui-voip/src/components/CallHistoryUnknownUser.tsx
Change renderers to accept a single contact prop typed to the corresponding contact shape; rename unknown component identifier.
Unified contact router component
packages/ui-voip/src/components/CallHistoryUser.tsx
Add CallHistoryUser that routes a CallHistoryContact to the appropriate renderer using exported guards.
External contact resolution
apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
Export getExternalContact to derive external/unknown contact from endpoint item; tighten isExternalCallHistoryItem and move callId to item.callId while making call optional.
Internal contact refinement
apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx
Tighten isInternalCallHistoryItem to require type === 'media-call'; declare getContact returns CallHistoryInternalContact; import internal contact as type-only.
Table row integration with contact router
packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx, packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
Redefine CallHistoryTableRowProps to derive contact via CallHistoryContact conditional types; remove table-specific contact types and guards; render via CallHistoryUser; update stories to import centralized definitions.
Call history page integration
apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
Introduce getContact to normalize contact derivation (delegates to getExternalContact, produces unknown/internal shapes); refactor row construction to use getContact; switch internal detection to isCallHistoryInternalContact; update imports.
Contextual bar integration
packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx, packages/ui-voip/src/views/CallHistoryContextualbar/index.ts
Use shared CallHistoryUser and centralized contact types/guards; remove local type definitions; update voice-extension and direct-message conditionals and barrel exports.
Row component prop type updates
apps/meteor/client/views/mediaCallHistory/CallHistoryRowExternalUser.tsx, apps/meteor/client/views/mediaCallHistory/CallHistoryRowInternalUser.tsx
Use CallHistoryExternalContact and CallHistoryInternalContact respectively in component prop typings.
Hook type updates
apps/meteor/client/views/mediaCallHistory/useMediaCallInternalHistoryActions.ts
Import and use CallHistoryInternalContact from centralized definitions; remove local exported InternalCallHistoryContact type.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • RocketChat/Rocket.Chat#37839: Introduces the initial call-history table and contact type-guard API that this PR migrates to a unified contact/router system.

Suggested reviewers

  • ggazzo
  • tassoevan
  • sampaiodiego
🚥 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 accurately summarizes the main refactoring focus: reorganizing how call history contact information is rendered across multiple components and introducing unified contact types.
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)
  • DMV-7: 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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

⚠️ No Changeset found

Latest commit: 24aecd3

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

@pierre-lehnen-rc pierre-lehnen-rc changed the title chore: refactor rendering of call history contact information refactor: rendering of call history contact information Jun 2, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 85.18519% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.74%. Comparing base (d7f19f8) to head (24aecd3).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40773      +/-   ##
===========================================
- Coverage    69.75%   69.74%   -0.01%     
===========================================
  Files         3327     3330       +3     
  Lines       123135   123157      +22     
  Branches     21991    21925      -66     
===========================================
+ Hits         85887    85900      +13     
+ Misses       33895    33891       -4     
- Partials      3353     3366      +13     
Flag Coverage Δ
unit 70.47% <95.65%> (+0.03%) ⬆️

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.

@pierre-lehnen-rc pierre-lehnen-rc force-pushed the chore/call-history-contact branch from 297a5aa to c753f42 Compare June 2, 2026 19:34
@pierre-lehnen-rc pierre-lehnen-rc marked this pull request as ready for review June 2, 2026 20:14
@pierre-lehnen-rc pierre-lehnen-rc requested a review from a team as a code owner June 2, 2026 20:14
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: 2

Caution

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

⚠️ Outside diff range comments (1)
apps/meteor/client/views/mediaCallHistory/CallHistoryRowInternalUser.tsx (1)

70-80: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Pass through contact.voiceCallExtension to preserve the widget’s callerId display

useMediaCallInternalHistoryActions forwards contact.voiceCallExtension as callerId, but CallHistoryRowInternalUser builds a narrowed contact without voiceCallExtension, so the widget’s callerId UI will render empty (no compile error because voiceCallExtension is optional).

const actions = useMediaCallInternalHistoryActions({
	contact: {
		_id: contact._id,
		username: contact.username ?? '',
		name: contact.name,
		displayName: contact.name || contact.username,
	},
	messageId,
	messageRoomId: rid,
	openUserInfo: onClickUserInfo ? (userId) => onClickUserInfo(userId, rid) : 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 `@apps/meteor/client/views/mediaCallHistory/CallHistoryRowInternalUser.tsx`
around lines 70 - 80, CallHistoryRowInternalUser is creating a narrowed contact
object missing voiceCallExtension so useMediaCallInternalHistoryActions can't
pass a callerId; update the object passed to useMediaCallInternalHistoryActions
to include contact.voiceCallExtension (preserve it on the contact you build) so
the widget's callerId display is populated (refer to
useMediaCallInternalHistoryActions, CallHistoryRowInternalUser, and the
contact.voiceCallExtension property).
🧹 Nitpick comments (1)
packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx (1)

17-23: ⚡ Quick win

The conditional type for contact is redundant and forces an unsafe cast downstream.

Each branch resolves T to the exact type it just tested against (T extends CallHistoryInternalContact ? CallHistoryInternalContact : ...), so the whole conditional is equivalent to contact: T. The added complexity also forces consumers to cast (see MediaCallHistoryTable.stories.tsx Line 85, as CallHistoryInternalContact). Collapsing it to contact: T with a default keeps the same behavior and lets callers use the full CallHistoryContact union without a cast.

♻️ Proposed simplification
-import type {
-	CallHistoryContact,
-	CallHistoryExternalContact,
-	CallHistoryInternalContact,
-	CallHistoryUnknownContact,
-} from '../../definitions';
+import type { CallHistoryContact } from '../../definitions';

-export type CallHistoryTableRowProps<T extends CallHistoryContact> = {
+export type CallHistoryTableRowProps<T extends CallHistoryContact = CallHistoryContact> = {
 	_id: string;
-	contact: T extends CallHistoryInternalContact
-		? CallHistoryInternalContact
-		: T extends CallHistoryExternalContact
-			? CallHistoryExternalContact
-			: CallHistoryUnknownContact;
+	contact: T;
 	type: 'outbound' | 'inbound';

The story can then drop the cast and use CallHistoryTableRowProps<CallHistoryContact> (or the bare CallHistoryTableRowProps).

🤖 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/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx`
around lines 17 - 23, The generic conditional type on CallHistoryTableRowProps
(contact: T extends CallHistoryInternalContact ? CallHistoryInternalContact : T
extends CallHistoryExternalContact ? CallHistoryExternalContact :
CallHistoryUnknownContact) is redundant and forces unsafe casts; simplify by
making contact: T (or contact?: T = CallHistoryContact as the default generic)
so the prop preserves the original union and callers can pass CallHistoryContact
without casting—update the CallHistoryTableRowProps generic signature
accordingly and remove downstream casts (e.g., in
MediaCallHistoryTable.stories.tsx).
🤖 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 `@packages/ui-voip/src/definitions/callHistoryContacts.ts`:
- Around line 28-30: Replace the negative fallback logic in
isCallHistoryExternalContact with an explicit discriminant check: instead of
returning !isCallHistoryUnknownContact(contact) &&
!isCallHistoryInternalContact(contact), test for the presence and type of the
external contact property (e.g., 'number' in contact && typeof contact.number
=== "string") so malformed objects lacking number won't be misclassified; keep
references to the other guards (isCallHistoryUnknownContact,
isCallHistoryInternalContact) only if still needed for additional validation.
- Around line 24-26: The type guard isCallHistoryInternalContact mixes type
discrimination with value validation by checking Boolean(contact._id); remove
the value check and only discriminate by the presence of the property. Update
isCallHistoryInternalContact to return "'_id' in contact" (no Boolean coercion)
so it solely identifies a CallHistoryInternalContact by the _id property and
does not reject valid but falsy IDs; refer to the isCallHistoryInternalContact
function and the CallHistoryContact / CallHistoryInternalContact types when
making the change.

---

Outside diff comments:
In `@apps/meteor/client/views/mediaCallHistory/CallHistoryRowInternalUser.tsx`:
- Around line 70-80: CallHistoryRowInternalUser is creating a narrowed contact
object missing voiceCallExtension so useMediaCallInternalHistoryActions can't
pass a callerId; update the object passed to useMediaCallInternalHistoryActions
to include contact.voiceCallExtension (preserve it on the contact you build) so
the widget's callerId display is populated (refer to
useMediaCallInternalHistoryActions, CallHistoryRowInternalUser, and the
contact.voiceCallExtension property).

---

Nitpick comments:
In `@packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx`:
- Around line 17-23: The generic conditional type on CallHistoryTableRowProps
(contact: T extends CallHistoryInternalContact ? CallHistoryInternalContact : T
extends CallHistoryExternalContact ? CallHistoryExternalContact :
CallHistoryUnknownContact) is redundant and forces unsafe casts; simplify by
making contact: T (or contact?: T = CallHistoryContact as the default generic)
so the prop preserves the original union and callers can pass CallHistoryContact
without casting—update the CallHistoryTableRowProps generic signature
accordingly and remove downstream casts (e.g., in
MediaCallHistoryTable.stories.tsx).
🪄 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: 04a2c045-76e6-482c-b4f2-ff95d2cb1a9e

📥 Commits

Reviewing files that changed from the base of the PR and between da1de5f and c753f42.

⛔ Files ignored due to path filters (1)
  • packages/ui-voip/src/views/CallHistoryContextualbar/__snapshots__/CallHistoryContextualbar.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (17)
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryRowExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryRowInternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx
  • apps/meteor/client/views/mediaCallHistory/useMediaCallInternalHistoryActions.ts
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/CallHistoryInternalUser.tsx
  • packages/ui-voip/src/components/CallHistoryUnknownUser.tsx
  • packages/ui-voip/src/components/CallHistoryUser.tsx
  • packages/ui-voip/src/definitions/callHistoryContacts.ts
  • packages/ui-voip/src/definitions/index.ts
  • packages/ui-voip/src/index.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/index.ts
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.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: cubic · AI code reviewer
  • 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/ui-voip/src/components/CallHistoryUnknownUser.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/index.ts
  • packages/ui-voip/src/index.ts
  • packages/ui-voip/src/definitions/index.ts
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/CallHistoryInternalUser.tsx
  • packages/ui-voip/src/definitions/callHistoryContacts.ts
  • apps/meteor/client/views/mediaCallHistory/CallHistoryRowInternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/components/CallHistoryUser.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryRowExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/useMediaCallInternalHistoryActions.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
🧠 Learnings (9)
📚 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/components/CallHistoryUnknownUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/CallHistoryInternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/components/CallHistoryUser.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.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/components/CallHistoryUnknownUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/CallHistoryInternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/components/CallHistoryUser.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.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/components/CallHistoryUnknownUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/CallHistoryInternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryRowInternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/components/CallHistoryUser.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryRowExternalUser.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • 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:

  • packages/ui-voip/src/components/CallHistoryUnknownUser.tsx
  • packages/ui-voip/src/views/CallHistoryContextualbar/index.ts
  • packages/ui-voip/src/index.ts
  • packages/ui-voip/src/definitions/index.ts
  • packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx
  • packages/ui-voip/src/components/CallHistoryExternalUser.tsx
  • packages/ui-voip/src/components/CallHistoryInternalUser.tsx
  • packages/ui-voip/src/definitions/callHistoryContacts.ts
  • apps/meteor/client/views/mediaCallHistory/CallHistoryRowInternalUser.tsx
  • packages/ui-voip/src/views/MediaCallHistoryTable/CallHistoryTableRow.tsx
  • packages/ui-voip/src/components/CallHistoryUser.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryRowExternalUser.tsx
  • apps/meteor/client/views/mediaCallHistory/useMediaCallInternalHistoryActions.ts
  • packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryContextualbar.tsx
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryExternal.tsx
  • apps/meteor/client/views/mediaCallHistory/CallHistoryPage.tsx
📚 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/ui-voip/src/views/CallHistoryContextualbar/index.ts
  • packages/ui-voip/src/index.ts
  • packages/ui-voip/src/definitions/index.ts
  • packages/ui-voip/src/definitions/callHistoryContacts.ts
  • apps/meteor/client/views/mediaCallHistory/useMediaCallInternalHistoryActions.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/ui-voip/src/views/CallHistoryContextualbar/index.ts
  • packages/ui-voip/src/index.ts
  • packages/ui-voip/src/definitions/index.ts
  • packages/ui-voip/src/definitions/callHistoryContacts.ts
  • apps/meteor/client/views/mediaCallHistory/useMediaCallInternalHistoryActions.ts
📚 Learning: 2025-12-18T15:18:23.819Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37773
File: apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx:24-34
Timestamp: 2025-12-18T15:18:23.819Z
Learning: In apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx, the claim is that internal call history items always have contactId equal to either caller.id or callee.id, so getContact will not produce undefined. Treat this as a file-specific guarantee and avoid adding guards that rely on other data sources in this path. If this invariant holds, you can rely on contact resolution not returning undefined, but consider adding a lightweight runtime assertion or a failing guard when the invariant is violated (e.g., throw or log) to surface unexpected data instead of silently handling undefined. This guideline applies only to this file path and should not be assumed project-wide without verification.

Applied to files:

  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx
📚 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/views/mediaCallHistory/useMediaCallInternalHistoryActions.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/views/mediaCallHistory/useMediaCallInternalHistoryActions.ts
🔇 Additional comments (18)
packages/ui-voip/src/views/MediaCallHistoryTable/MediaCallHistoryTable.stories.tsx (1)

82-93: LGTM!

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

48-58: LGTM!


145-225: LGTM!

packages/ui-voip/src/definitions/callHistoryContacts.ts (2)

1-18: LGTM!


20-22: LGTM!

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

1-3: LGTM!

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

15-16: LGTM!

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

1-27: LGTM!

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

1-37: LGTM!

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

1-17: LGTM!

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

1-23: LGTM!

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

1-62: LGTM!

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

1-64: LGTM!

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

20-22: LGTM!

Also applies to: 37-37, 65-65, 85-85, 95-95

packages/ui-voip/src/views/CallHistoryContextualbar/index.ts (1)

2-2: LGTM!

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

2-2: LGTM!

Also applies to: 7-7

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

4-4: LGTM!

Also applies to: 11-11

apps/meteor/client/views/mediaCallHistory/useMediaCallInternalHistoryActions.ts (1)

4-4: LGTM!

Also applies to: 8-8

Comment thread packages/ui-voip/src/definitions/callHistoryContacts.ts
Comment thread packages/ui-voip/src/definitions/callHistoryContacts.ts
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

2 issues found across 18 files

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

Re-trigger cubic

Comment thread packages/ui-voip/src/definitions/callHistoryContacts.ts
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)
apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx (1)

24-35: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fail fast instead of manufacturing an invalid internal contact.

contact ?? {} turns an invariant break into a malformed CallHistoryInternalContact: _id can be undefined, but the function still returns a value typed as a valid internal contact. That makes the failure much harder to diagnose and can break downstream actions that assume a real user id. Please keep the stronger return type and throw or log when item.contactId matches neither caller nor callee.

Suggested fix
 const getContact = (item: InternalCallEndpointData['item'], call: InternalCallEndpointData['call']): CallHistoryInternalContact => {
 	const { caller, callee } = call ?? {};
 	const contact = caller?.id === item.contactId ? caller : callee;
-	const { id, sipExtension, username, displayName, ...rest } = contact ?? {};
+	if (!contact) {
+		throw new Error(`Unable to resolve internal call contact for contactId "${item.contactId}"`);
+	}
+
+	const { id, sipExtension, username, displayName, ...rest } = contact;
 	return {
 		...rest,
 		_id: id,
 		username: username ?? '',
 		name: displayName,
 		displayName,
 		voiceCallExtension: sipExtension,
 	};
 };

Based on learnings: item.contactId is guaranteed to match either caller.id or callee.id in this file, so unexpected misses should be surfaced rather than silently handled.

🤖 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 `@apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx`
around lines 24 - 35, The getContact function currently masks a missing contact
by using contact ?? {} which can produce a CallHistoryInternalContact with
undefined _id; instead, detect when caller?.id and callee?.id do not match
item.contactId and immediately surface the error (throw or processLogger.error +
throw) so callers never receive an invalid contact. In getContact, locate the
contact resolution logic (caller, callee, contact) and replace the fallback with
an explicit check: if no contact found, log/throw a clear error referencing
item.contactId and the call object, otherwise destructure contact and return the
well-typed CallHistoryInternalContact as before. Ensure the thrown message
includes item.contactId and call identifiers for debugging.
🤖 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 `@apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx`:
- Around line 24-35: The getContact function currently masks a missing contact
by using contact ?? {} which can produce a CallHistoryInternalContact with
undefined _id; instead, detect when caller?.id and callee?.id do not match
item.contactId and immediately surface the error (throw or processLogger.error +
throw) so callers never receive an invalid contact. In getContact, locate the
contact resolution logic (caller, callee, contact) and replace the fallback with
an explicit check: if no contact found, log/throw a clear error referencing
item.contactId and the call object, otherwise destructure contact and return the
well-typed CallHistoryInternalContact as before. Ensure the thrown message
includes item.contactId and call identifiers for debugging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1b7da18e-28e4-4e6d-96a1-3f50505d5ad2

📥 Commits

Reviewing files that changed from the base of the PR and between c753f42 and 24aecd3.

📒 Files selected for processing (1)
  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.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). (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • 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:

  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx
🧠 Learnings (3)
📚 Learning: 2025-12-18T15:18:23.819Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37773
File: apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx:24-34
Timestamp: 2025-12-18T15:18:23.819Z
Learning: In apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx, the claim is that internal call history items always have contactId equal to either caller.id or callee.id, so getContact will not produce undefined. Treat this as a file-specific guarantee and avoid adding guards that rely on other data sources in this path. If this invariant holds, you can rely on contact resolution not returning undefined, but consider adding a lightweight runtime assertion or a failing guard when the invariant is violated (e.g., throw or log) to surface unexpected data instead of silently handling undefined. This guideline applies only to this file path and should not be assumed project-wide without verification.

Applied to files:

  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.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:

  • apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.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/MediaCallHistoryInternal.tsx

@ggazzo ggazzo added this to the 8.6.0 milestone Jun 3, 2026
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Jun 3, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 3, 2026
@ggazzo ggazzo merged commit 5ef921e into develop Jun 3, 2026
46 of 48 checks passed
@ggazzo ggazzo deleted the chore/call-history-contact branch June 3, 2026 00:34
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: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants