Skip to content

refactor(ui-avatar): remove unnecessary ReactElement type annotations from AppAvatar, MessageAvatar, and RoomAvatar components#40804

Merged
dionisio-bot[bot] merged 1 commit into
developfrom
refactor/prepare-types-for-react-19-2
Jun 5, 2026
Merged

refactor(ui-avatar): remove unnecessary ReactElement type annotations from AppAvatar, MessageAvatar, and RoomAvatar components#40804
dionisio-bot[bot] merged 1 commit into
developfrom
refactor/prepare-types-for-react-19-2

Conversation

@tassoevan
Copy link
Copy Markdown
Member

@tassoevan tassoevan commented Jun 4, 2026

⚠️ This is part 2/23 of #40796. PR for refactor/prepare-types-for-react-19-1 must be merged first.


Proposed changes (including videos or screenshots)

As a first step towards upgrading to React 19, it handles types from @types/react looking forward the next major.

Issue(s)

Task: ARCH-2170

Steps to test or reproduce

Further comments

No runtime change is expected from it.

Summary by CodeRabbit

  • Refactor
    • Improved type definitions for avatar components to support more flexible content types
    • Cleaned up unused imports and return type annotations across avatar component files

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Jun 4, 2026

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 4, 2026

⚠️ No Changeset found

Latest commit: f87174d

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 Jun 4, 2026

Review Change Stack

Walkthrough

Type-level refactoring across three avatar components: AppAvatar and RoomAvatar remove unused ReactElement imports and drop explicit return type annotations; MessageAvatar's emoji prop is broadened from ReactElement to ReactNode for broader content support.

Changes

Avatar component type refinements

Layer / File(s) Summary
Type refinements for avatar components
packages/ui-avatar/src/components/AppAvatar.tsx, packages/ui-avatar/src/components/MessageAvatar.tsx, packages/ui-avatar/src/components/RoomAvatar.tsx
AppAvatar and RoomAvatar components remove the unused ReactElement type import and drop explicit : ReactElement return type annotations; MessageAvatar's emoji prop type is broadened from ReactElement to ReactNode to accept a wider range of renderable content.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • RocketChat/Rocket.Chat#40803: Contains a parallel type-level refactor replacing ReactElement with ReactNode for renderable content in a different component.

Suggested labels

type: chore

Suggested reviewers

  • ggazzo
  • yash-rajpal
  • MartinSchoeler
🚥 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 accurately and specifically summarizes the main changes: removing ReactElement type annotations from three avatar components as part of a React 19 preparatory refactor.
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)
  • REACT-19: Request failed with status code 401
  • ARCH-2170: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.06%. Comparing base (121e19f) to head (f87174d).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40804      +/-   ##
===========================================
+ Coverage    70.04%   70.06%   +0.02%     
===========================================
  Files         3337     3337              
  Lines       123506   123506              
  Branches     22019    21986      -33     
===========================================
+ Hits         86510    86537      +27     
+ Misses       33647    33615      -32     
- Partials      3349     3354       +5     
Flag Coverage Δ
e2e 59.42% <ø> (+<0.01%) ⬆️
e2e-api 47.12% <ø> (+0.83%) ⬆️
unit 70.81% <ø> (ø)

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.

… from AppAvatar, MessageAvatar, and RoomAvatar components
@tassoevan tassoevan force-pushed the refactor/prepare-types-for-react-19-2 branch from 85d849a to f87174d Compare June 5, 2026 03:22
@tassoevan tassoevan added this to the 8.6.0 milestone Jun 5, 2026
@tassoevan tassoevan requested a review from a team June 5, 2026 03:23
@tassoevan tassoevan marked this pull request as ready for review June 5, 2026 03:23
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)
packages/ui-avatar/src/components/MessageAvatar.tsx (1)

7-15: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use nullish check for emoji after widening to ReactNode.

After changing emoji to ReactNode, if (emoji) incorrectly treats valid nodes like 0 and '' as absent, so it renders UserAvatar instead of the provided content. Use a nullish check (emoji != null) for the branch condition.

Suggested fix
-	if (emoji) {
+	if (emoji != null) {
 		return (
 			<AvatarContainer size={size} {...props}>
 				{emoji}
 			</AvatarContainer>
 		);
 	}
🤖 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-avatar/src/components/MessageAvatar.tsx` around lines 7 - 15, The
conditional in MessageAvatar that currently checks emoji truthiness should be
changed to a nullish check so valid ReactNode values like 0 or '' are treated as
provided; update the branch that decides whether to render the emoji versus
<UserAvatar> to use emoji != null (or emoji !== null && emoji !== undefined)
when inspecting the emoji prop.
🤖 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 `@packages/ui-avatar/src/components/MessageAvatar.tsx`:
- Around line 7-15: The conditional in MessageAvatar that currently checks emoji
truthiness should be changed to a nullish check so valid ReactNode values like 0
or '' are treated as provided; update the branch that decides whether to render
the emoji versus <UserAvatar> to use emoji != null (or emoji !== null && emoji
!== undefined) when inspecting the emoji prop.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4b845b2a-76d6-42b3-982d-661941dd02bb

📥 Commits

Reviewing files that changed from the base of the PR and between 121e19f and f87174d.

📒 Files selected for processing (3)
  • packages/ui-avatar/src/components/AppAvatar.tsx
  • packages/ui-avatar/src/components/MessageAvatar.tsx
  • packages/ui-avatar/src/components/RoomAvatar.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: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

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

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/ui-avatar/src/components/MessageAvatar.tsx
  • packages/ui-avatar/src/components/AppAvatar.tsx
  • packages/ui-avatar/src/components/RoomAvatar.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:42.118Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs, removing endpoint types and validators from `rocket.chat/rest-typings` (e.g., `UserRegisterParamsPOST`, `/v1/users.register` entry) is the *required* migration pattern per RocketChat/Rocket.Chat-Open-API#150 Rule 7 ("No More rest-typings or Manual Typings"). The endpoint type is re-exposed via a module augmentation `.d.ts` file in the consuming package (e.g., `packages/web-ui-registration/src/users-register.d.ts`). This is NOT a breaking change — the correct changeset bump for `rocket.chat/rest-typings` in this scenario is `minor`, not `major`. Do not flag this as a breaking change during OpenAPI migration reviews.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 39414
File: apps/meteor/app/api/server/v1/rooms.ts:1241-1297
Timestamp: 2026-03-10T08:13:52.153Z
Learning: In the RocketChat/Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1/rooms.ts, the pattern `ajv.compile<void>({...})` is intentionally used for the 200 response schema even when the endpoint returns `{ success: true }`. This is an established convention across all migrated endpoints (rooms.leave, rooms.favorite, rooms.delete, rooms.muteUser, rooms.unmuteUser). Do not flag this as a type mismatch during reviews of these migration PRs.
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 39553
File: apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts:179-181
Timestamp: 2026-03-20T13:51:23.302Z
Learning: In `apps/meteor/app/integrations/server/methods/incoming/updateIncomingIntegration.ts`, the truthiness guards `...(integration.avatar && { avatar })`, `...(integration.emoji && { emoji })`, `...(integration.alias && { alias })`, and `...(integration.script && { script })` in the `$set` payload of `updateIncomingIntegration` are intentional. Empty-string values for these fields should NOT overwrite the stored value — only truthy values are persisted. Do not flag these as bugs preventing explicit clears.
📚 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-avatar/src/components/MessageAvatar.tsx
  • packages/ui-avatar/src/components/AppAvatar.tsx
  • packages/ui-avatar/src/components/RoomAvatar.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-avatar/src/components/MessageAvatar.tsx
  • packages/ui-avatar/src/components/AppAvatar.tsx
  • packages/ui-avatar/src/components/RoomAvatar.tsx
🔇 Additional comments (2)
packages/ui-avatar/src/components/AppAvatar.tsx (1)

9-10: LGTM!

packages/ui-avatar/src/components/RoomAvatar.tsx (1)

17-24: LGTM!

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.

1 issue found across 3 files

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

Re-trigger cubic

Comment thread packages/ui-avatar/src/components/MessageAvatar.tsx
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Jun 5, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 5, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jun 5, 2026
Merged via the queue into develop with commit f85d853 Jun 5, 2026
82 of 84 checks passed
@dionisio-bot dionisio-bot Bot deleted the refactor/prepare-types-for-react-19-2 branch June 5, 2026 13:46
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