Skip to content

Conversation

@gabriellsh
Copy link
Member

@gabriellsh gabriellsh commented Jan 15, 2026

Proposed changes (including videos or screenshots)

Issue(s)

ARCH-1658

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Refactor
    • Consolidated hook imports and shared utilities across the client and UI packages.
    • Tightened callback assumptions for DOM refs, simplifying internal lifecycle handling.
    • Removed an obsolete ref-utility hook and its test suite.
    • Reorganized internal hook exports between packages to streamline usage.

✏️ Tip: You can customize this high-level summary in your review settings.

@gabriellsh gabriellsh requested a review from a team as a code owner January 15, 2026 15:26
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 15, 2026

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

@changeset-bot
Copy link

changeset-bot bot commented Jan 15, 2026

⚠️ No Changeset found

Latest commit: 98a7300

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
Contributor

coderabbitai bot commented Jan 15, 2026

Walkthrough

This PR migrates consumers of useSafeRefCallback from @rocket.chat/ui-client to @rocket.chat/fuselage-hooks, removes the original useSafeRefCallback implementation and its tests, and tightens ref callback types by removing runtime null-check guards across multiple consumers.

Changes

Cohort / File(s) Summary
Import migration & consolidation
apps/meteor/client/components/message/content/attachments/file/hooks/useReloadOnError.tsx, apps/meteor/client/views/room/MessageList/hooks/useJumpToMessage.ts, apps/meteor/client/views/room/body/hooks/useGetMore.ts, apps/meteor/client/views/room/body/hooks/useListIsAtBottom.ts, apps/meteor/client/views/room/body/hooks/useRestoreScrollPosition.ts, apps/meteor/client/views/room/composer/RoomComposer/hooks/useAutoGrow.ts, apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx, apps/meteor/client/views/room/hooks/useIsVisible.ts, packages/ui-voip/src/context/useMediaStream.ts, packages/ui-voip/src/hooks/VoipPopupDraggable/DraggableCore.ts
Updated imports to @rocket.chat/fuselage-hooks and consolidated multiple imports into single lines.
Ref callback signature tightening / null-check removal
(same files as above)
Narrowed ref callback parameter types from `HTMLElement
Public API cleanup: remove re-exports
packages/ui-client/src/hooks/index.ts, packages/ui-client/src/hooks/useSafeRefCallback/index.ts
Removed re-export of useSafeRefCallback from ui-client barrel index files.
Implementation removal
packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.ts
Deleted the useSafeRefCallback hook implementation (types, memoized cleanup logic, and export).
Test removal
packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.spec.tsx
Removed unit test file for useSafeRefCallback.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

stat: ready to merge

Suggested reviewers

  • ggazzo
  • tassoevan
  • MartinSchoeler

Poem

🐰 I hopped through imports, light and spry,
Repointed refs and waved nulls goodbye.
Files trimmed tidy, tests set free,
A cleaner burrow — come celebrate with me! 🎉

🚥 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 describes the main objective of replacing useSafeRefCallback imports from ui-client with fuselage-hooks' version, matching the primary change across multiple files.
Linked Issues check ✅ Passed The PR successfully implements the objective from ARCH-1658 by replacing useSafeRefCallback imports from ui-client with fuselage-hooks and removing the ui-client implementation.
Out of Scope Changes check ✅ Passed All changes are within scope: updating imports, removing the old ui-client implementation, adjusting callback signatures for non-null guarantees, and deleting related tests are all necessary for the migration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/replaceUseSafeRefCallback


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4d634a4 and ff74e1b.

📒 Files selected for processing (14)
  • apps/meteor/client/components/message/content/attachments/file/hooks/useReloadOnError.tsx
  • apps/meteor/client/views/room/MessageList/hooks/useJumpToMessage.ts
  • apps/meteor/client/views/room/body/hooks/useGetMore.ts
  • apps/meteor/client/views/room/body/hooks/useListIsAtBottom.ts
  • apps/meteor/client/views/room/body/hooks/useRestoreScrollPosition.ts
  • apps/meteor/client/views/room/composer/RoomComposer/hooks/useAutoGrow.ts
  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
  • apps/meteor/client/views/room/hooks/useIsVisible.ts
  • packages/ui-client/src/hooks/index.ts
  • packages/ui-client/src/hooks/useSafeRefCallback/index.ts
  • packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.spec.tsx
  • packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.ts
  • packages/ui-voip/src/context/useMediaStream.ts
  • packages/ui-voip/src/hooks/VoipPopupDraggable/DraggableCore.ts
💤 Files with no reviewable changes (4)
  • packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.ts
  • packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.spec.tsx
  • packages/ui-client/src/hooks/index.ts
  • packages/ui-client/src/hooks/useSafeRefCallback/index.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/ui-voip/src/hooks/VoipPopupDraggable/DraggableCore.ts
  • apps/meteor/client/views/room/hooks/useIsVisible.ts
  • apps/meteor/client/views/room/body/hooks/useListIsAtBottom.ts
🧰 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/room/MessageList/hooks/useJumpToMessage.ts
  • apps/meteor/client/views/room/body/hooks/useGetMore.ts
  • apps/meteor/client/views/room/composer/RoomComposer/hooks/useAutoGrow.ts
  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
  • apps/meteor/client/components/message/content/attachments/file/hooks/useReloadOnError.tsx
  • packages/ui-voip/src/context/useMediaStream.ts
  • apps/meteor/client/views/room/body/hooks/useRestoreScrollPosition.ts
🧠 Learnings (4)
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: UserBridge.doGetUserRoomIds in packages/apps-engine/src/server/bridges/UserBridge.ts has a bug where it implicitly returns undefined when the app lacks read permission (missing return statement in the else case of the permission check).

Applied to files:

  • apps/meteor/client/views/room/MessageList/hooks/useJumpToMessage.ts
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.

Applied to files:

  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
📚 Learning: 2025-11-04T16:49:19.107Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.

Applied to files:

  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
📚 Learning: 2025-11-19T18:20:07.720Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: packages/i18n/src/locales/en.i18n.json:918-921
Timestamp: 2025-11-19T18:20:07.720Z
Learning: Repo: RocketChat/Rocket.Chat — i18n/formatting
Learning: This repository uses a custom message formatting parser in UI blocks/messages; do not assume standard Markdown rules. For keys like Call_ended_bold, Call_not_answered_bold, Call_failed_bold, and Call_transferred_bold in packages/i18n/src/locales/en.i18n.json, retain the existing single-asterisk emphasis unless maintainers request otherwise.

Applied to files:

  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
⏰ 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). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (7)
apps/meteor/client/views/room/body/hooks/useRestoreScrollPosition.ts (1)

1-1: Migration to fuselage-hooks is correct.

The import change and callback signature update properly leverage useSafeRefCallback from @rocket.chat/[email protected], which guarantees non-null node values. The cleanup function return pattern (lines 27-30) is supported and consistently used across the codebase. The handleWrapperScroll.cancel() call is valid per the withThrottling implementation.

apps/meteor/client/views/room/MessageList/hooks/useJumpToMessage.ts (1)

2-2: Import consolidation looks good.

This aligns with the PR objective of using @rocket.chat/fuselage-hooks.

apps/meteor/client/components/message/content/attachments/file/hooks/useReloadOnError.tsx (1)

135-148: No null guard needed—useSafeRefCallback handles null internally.

useSafeRefCallback from @rocket.chat/fuselage-hooks safely suppresses null callbacks on unmount, so the callback will not receive null as a parameter. The non-nullable signature (node: HTMLAudioElement) at line 137 is correct and aligns with the established pattern throughout the codebase (e.g., useMediaStream.ts, useJumpToMessage.ts, useListIsAtBottom.ts). The code is safe as written.

apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx (1)

3-3: Confirm fuselage-hooks ref callback never receives null here.
node.addEventListener now runs without a null guard. If useSafeRefCallback can pass null on unmount, this will crash. Please verify the hook contract; if null is possible, reintroduce a guard before attaching listeners.

Also applies to: 357-366

apps/meteor/client/views/room/body/hooks/useGetMore.ts (1)

1-1: Validate non-null callback behavior in useSafeRefCallback.
This setup now assumes element is always non-null. If the hook can pass null on unmount, the observer/listener setup will throw. Please verify the fuselage-hooks contract and add a null guard if necessary.

Also applies to: 22-90

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

1-1: Please verify useSafeRefCallback does not forward null for audio refs.
The callback now unconditionally uses node (srcObject/play). If null can be passed, this will throw during unmount. Confirm the fuselage-hooks behavior; add a guard if needed.

Also applies to: 32-48

apps/meteor/client/views/room/composer/RoomComposer/hooks/useAutoGrow.ts (1)

1-1: No null guard needed—useSafeRefCallback filters null before invoking the inner callback.

The hook wraps a callback that does not accept null and returns a React RefCallback<T> that accepts null. The "safe" design ensures null is never passed to the inner callback (lines 21–45). This pattern is consistent throughout the codebase (e.g., useMediaStream.ts line 25–32). The callback's unconditional use of node is safe.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

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

🤖 Fix all issues with AI agents
In `@apps/meteor/client/views/room/MessageList/hooks/useJumpToMessage.ts`:
- Around line 51-54: In useJumpToMessage's callback (the arrow fn with parameter
node: HTMLElement) the guard incorrectly checks an undefined symbol "scroll";
remove that check and only guard on listRef/existing values that are in scope
(e.g., if (!listRef || !node) return;), or replace it with the correct in-scope
ref if there was meant to be a scrollRef name. Update the guard to reference
only declared variables (listRef, node, or an actual scrollRef) and remove the
stray "scroll" check so the function's behavior matches the refactor.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1c7066f and 4d634a4.

📒 Files selected for processing (14)
  • apps/meteor/client/components/message/content/attachments/file/hooks/useReloadOnError.tsx
  • apps/meteor/client/views/room/MessageList/hooks/useJumpToMessage.ts
  • apps/meteor/client/views/room/body/hooks/useGetMore.ts
  • apps/meteor/client/views/room/body/hooks/useListIsAtBottom.ts
  • apps/meteor/client/views/room/body/hooks/useRestoreScrollPosition.ts
  • apps/meteor/client/views/room/composer/RoomComposer/hooks/useAutoGrow.ts
  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
  • apps/meteor/client/views/room/hooks/useIsVisible.ts
  • packages/ui-client/src/hooks/index.ts
  • packages/ui-client/src/hooks/useSafeRefCallback/index.ts
  • packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.spec.tsx
  • packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.ts
  • packages/ui-voip/src/context/useMediaStream.ts
  • packages/ui-voip/src/hooks/VoipPopupDraggable/DraggableCore.ts
💤 Files with no reviewable changes (4)
  • packages/ui-client/src/hooks/useSafeRefCallback/index.ts
  • packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.ts
  • packages/ui-client/src/hooks/index.ts
  • packages/ui-client/src/hooks/useSafeRefCallback/useSafeRefCallback.spec.tsx
🧰 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/context/useMediaStream.ts
  • apps/meteor/client/views/room/hooks/useIsVisible.ts
  • apps/meteor/client/components/message/content/attachments/file/hooks/useReloadOnError.tsx
  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
  • packages/ui-voip/src/hooks/VoipPopupDraggable/DraggableCore.ts
  • apps/meteor/client/views/room/composer/RoomComposer/hooks/useAutoGrow.ts
  • apps/meteor/client/views/room/body/hooks/useListIsAtBottom.ts
  • apps/meteor/client/views/room/MessageList/hooks/useJumpToMessage.ts
  • apps/meteor/client/views/room/body/hooks/useGetMore.ts
  • apps/meteor/client/views/room/body/hooks/useRestoreScrollPosition.ts
🧠 Learnings (3)
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.

Applied to files:

  • apps/meteor/client/views/room/hooks/useIsVisible.ts
  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
📚 Learning: 2025-11-04T16:49:19.107Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.

Applied to files:

  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
📚 Learning: 2025-11-19T18:20:07.720Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: packages/i18n/src/locales/en.i18n.json:918-921
Timestamp: 2025-11-19T18:20:07.720Z
Learning: Repo: RocketChat/Rocket.Chat — i18n/formatting
Learning: This repository uses a custom message formatting parser in UI blocks/messages; do not assume standard Markdown rules. For keys like Call_ended_bold, Call_not_answered_bold, Call_failed_bold, and Call_transferred_bold in packages/i18n/src/locales/en.i18n.json, retain the existing single-asterisk emphasis unless maintainers request otherwise.

Applied to files:

  • apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx
⏰ 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). (4)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (17)
apps/meteor/client/views/room/hooks/useIsVisible.ts (1)

1-1: LGTM! Import migration and callback signature are correct.

The import consolidation from @rocket.chat/fuselage-hooks is valid, and the removal of the | null type from the callback parameter aligns with how useSafeRefCallback is used throughout the codebase. The cleanup function pattern (lines 18-20) correctly returns the observer disconnect handler.

apps/meteor/client/views/room/MessageList/hooks/useJumpToMessage.ts (1)

2-2: LGTM!

Import consolidation correctly aligns with the PR objective of migrating useSafeRefCallback to @rocket.chat/fuselage-hooks.

apps/meteor/client/views/room/body/hooks/useGetMore.ts (2)

1-1: LGTM!

Import migration from @rocket.chat/ui-client to @rocket.chat/fuselage-hooks is correct.


20-94: LGTM - Safe removal of null guard.

The assumption that useSafeRefCallback only invokes the callback with non-null elements is correct. This pattern is consistently used across 10+ files in the codebase (useIsVisible.ts, MessageBox.tsx, useAutoGrow.ts, useRestoreScrollPosition.ts, useJumpToMessage.ts, useListIsAtBottom.ts, useReloadOnError.tsx, and others), all with non-null element types and no null guards in the callback body.

apps/meteor/client/views/room/body/hooks/useListIsAtBottom.ts (2)

1-1: LGTM!

Clean import consolidation from @rocket.chat/fuselage-hooks.


35-70: Implementation signature is correct.

The callback signature (node: HTMLElement) is appropriate for useSafeRefCallback. The codebase consistently uses this pattern across multiple files without null checks (e.g., useRestoreScrollPosition.ts), confirming the hook guarantees non-null node invocation. The cleanup function is properly returned.

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

1-1: Import migration is correct.

The import source change from @rocket.chat/ui-client to @rocket.chat/fuselage-hooks is confirmed. The useSafeRefCallback API is consistently used across the codebase from the same source, and no conflicts or incompatibilities are present.


30-52: No issues found.

The code is correct. useSafeRefCallback filters null values before invoking the inner callback, making the type narrowing from HTMLAudioElement | null to HTMLAudioElement safe and the node.srcObject access valid.

apps/meteor/client/views/room/body/hooks/useRestoreScrollPosition.ts (2)

1-1: API compatibility of useSafeRefCallback from fuselage-hooks is verified.

The hook from @rocket.chat/fuselage-hooks is already consistently used across the codebase (useMediaStream.ts, DraggableCore.ts, useJumpToMessage.ts, useListIsAtBottom.ts, useGetMore.ts, useIsVisible.ts, MessageBox.tsx, useAutoGrow.ts, useReloadOnError.tsx) with the same callback signature pattern: non-nullable element types (HTMLElement, HTMLAudioElement, HTMLTextAreaElement) with direct property access and no null checks. The import change maintains the same API contract and is safe.


10-34: Unable to definitively verify the null-safety assumption without access to the @rocket.chat/fuselage-hooks implementation source. The codebase pattern and type signatures suggest that useSafeRefCallback safely handles null before invoking the callback (only calling it when the element is mounted), which would make the non-nullable callback signature (node: HTMLElement) correct. However, this requires verification against the external package's implementation to confirm.

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

3-3: Verify that useSafeRefCallback from @rocket.chat/fuselage-hooks guards against null before invoking the callback.

React ref callbacks receive null on unmount. The three wrapped callbacks (lines 534, 543, 565) lack internal null-checks but call methods like getBoundingClientRect() that would fail on null. Confirm the fuselage-hooks implementation does not pass null to the provided callback, or add null-guards within each callback.

apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx (2)

3-3: LGTM!

Clean import consolidation—grouping useSafeRefCallback with other hooks from @rocket.chat/fuselage-hooks.


357-369: The callback's null-handling is safe. useSafeRefCallback from @rocket.chat/fuselage-hooks guarantees that the callback is only invoked when the node is non-null and runs cleanup when the ref becomes null or the component unmounts. The code correctly relies on this contract—no null guard is needed, and no runtime errors will occur on unmount.

apps/meteor/client/components/message/content/attachments/file/hooks/useReloadOnError.tsx (2)

1-1: LGTM on import consolidation.

Clean consolidation of both hooks from the same package.


135-148: Verify useSafeRefCallback contract in library documentation.

The callback assumes node is always non-null and directly invokes methods without null checks. Confirm that useSafeRefCallback from @rocket.chat/fuselage-hooks (v0.38.1) guarantees the callback is only invoked when the element is mounted, never with null. If this contract is not documented or guaranteed by the library, add a null guard in the callback before accessing the node.

apps/meteor/client/views/room/composer/RoomComposer/hooks/useAutoGrow.ts (2)

1-1: Import migration looks correct.

The import source change from @rocket.chat/ui-client to @rocket.chat/fuselage-hooks aligns with the PR objective.


19-47: Verify the null-handling contract of useSafeRefCallback.

The callback accesses node directly without null checks (e.g., shouldScrollToBottom(node), node.style.height, node.addEventListener). React's RefCallback<T> type signature is (instance: T | null) => void, meaning the callback can be invoked with null when the ref is removed or unmount occurs. This code assumes useSafeRefCallback prevents null calls; without confirming this behavior in the fuselage-hooks implementation, the code may be unsafe. Either add a null guard (if (!node) return;) or document the assumption that useSafeRefCallback guarantees non-null invocation.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

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

No issues found across 14 files

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.67%. Comparing base (a7b87fe) to head (98a7300).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38201      +/-   ##
===========================================
+ Coverage    70.65%   70.67%   +0.02%     
===========================================
  Files         3136     3135       -1     
  Lines       108627   108592      -35     
  Branches     19574    19549      -25     
===========================================
+ Hits         76745    76746       +1     
+ Misses       29872    29834      -38     
- Partials      2010     2012       +2     
Flag Coverage Δ
e2e 60.30% <100.00%> (+0.01%) ⬆️
e2e-api 48.10% <ø> (-0.99%) ⬇️
unit 71.74% <90.90%> (+0.05%) ⬆️

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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

📦 Docker Image Size Report

➡️ Changes

Service Current Baseline Change Percent
sum of all images 0B 0B 0B
account-service 0B 0B 0B
authorization-service 0B 0B 0B
ddp-streamer-service 0B 0B 0B
omnichannel-transcript-service 0B 0B 0B
presence-service 0B 0B 0B
queue-worker-service 0B 0B 0B
rocketchat 0B 0B 0B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "01/17 15:14 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.00]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "queue-worker-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "rocketchat" [0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.00]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.4GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 0B
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-38201
  • Baseline: develop
  • Timestamp: 2026-01-17 15:14:21 UTC
  • Historical data points: 30

Updated: Sat, 17 Jan 2026 15:14:22 GMT

@juliajforesti juliajforesti added the stat: QA assured Means it has been tested and approved by a company insider label Jan 16, 2026
@juliajforesti juliajforesti force-pushed the chore/replaceUseSafeRefCallback branch from d70ebd8 to ff74e1b Compare January 16, 2026 14:42
@dougfabris dougfabris added stat: QA assured Means it has been tested and approved by a company insider and removed stat: QA assured Means it has been tested and approved by a company insider labels Jan 16, 2026
@dougfabris dougfabris added this to the 8.1.0 milestone Jan 16, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 16, 2026
@kodiakhq kodiakhq bot merged commit 37e7b75 into develop Jan 17, 2026
44 checks passed
@kodiakhq kodiakhq bot deleted the chore/replaceUseSafeRefCallback branch January 17, 2026 15:36
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants