refactor(ui-contexts,fuselage-ui-kit,ui-client): Decouple room navigation hooks from roomCoordinator and ui-contexts#41508
refactor(ui-contexts,fuselage-ui-kit,ui-client): Decouple room navigation hooks from roomCoordinator and ui-contexts#41508tassoevan wants to merge 4 commits into
Conversation
Adds a useRoomRoute hook to ui-contexts for navigating to a room from data already at hand (no API call, unlike useGoToRoom) and uses it in ParentDiscussion and RoomForewordUsernameList, removing their dependency on the Meteor-coupled roomCoordinator.
useGoToRoom was only consumed by VideoConferenceBlock, so it doesn't need to be a public ui-contexts hook. Moved it next to its sole consumer and dropped the export from @rocket.chat/ui-contexts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
useRoomRoute was only consumed by ParentDiscussion, a ui-client component, so it doesn't need to be a public ui-contexts hook. Moved it into ui-client and dropped the export from @rocket.chat/ui-contexts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
/jira ARCH-2200 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (5)
|
| Layer / File(s) | Summary |
|---|---|
Room route hook and export packages/ui-client/src/hooks/useRoomRoute.ts, packages/ui-client/src/hooks/index.ts |
Adds the memoized useRoomRoute hook and exports it through the UI client hooks package. |
Room view route consumers apps/meteor/client/views/room/Header/ParentRoom/ParentDiscussion/ParentDiscussion.tsx, apps/meteor/client/views/room/body/RoomForeword/RoomForewordUsernameList.tsx |
Replaces roomCoordinator navigation and link generation with router-based room routes, including federated and special-character room-name handling. |
Video navigation hook localization packages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/..., packages/ui-contexts/src/index.ts |
Moves useGoToRoom to a local import, updates its context imports, removes its public context export, and tests room-type-specific navigation and missing-room behavior. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Suggested labels: type: chore
🚥 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 clearly captures the main refactor: moving room navigation hooks out of roomCoordinator and ui-contexts. |
| 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. |
Warning
Review ran into problems
🔥 Problems
Errors were encountered while retrieving linked issues.
Errors (1)
- ARCH-2288: 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.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/ui-client/src/hooks/useRoomRoute.ts (1)
11-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the implementation comment.
As per coding guidelines, “Avoid code comments in the implementation.”
Proposed cleanup
-/** - * Returns a function to navigate to a room using existing room data. - * Unlike `useGoToRoom`, this doesn't make an API call - use it when you already have the room data. - */🤖 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-client/src/hooks/useRoomRoute.ts` around lines 11 - 14, Remove the implementation comment above the room navigation hook while leaving the hook and its behavior unchanged.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@packages/ui-client/src/hooks/useRoomRoute.ts`:
- Around line 11-14: Remove the implementation comment above the room navigation
hook while leaving the hook and its behavior unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 029a3de9-1820-48a8-a6a2-a1c40a8bba0b
📒 Files selected for processing (8)
apps/meteor/client/views/room/Header/ParentRoom/ParentDiscussion/ParentDiscussion.tsxapps/meteor/client/views/room/body/RoomForeword/RoomForewordUsernameList.tsxpackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/VideoConferenceBlock.tsxpackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.spec.tsxpackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.tspackages/ui-client/src/hooks/index.tspackages/ui-client/src/hooks/useRoomRoute.tspackages/ui-contexts/src/index.ts
💤 Files with no reviewable changes (1)
- packages/ui-contexts/src/index.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: 📦 Build Packages
- GitHub Check: Hacktron Security Check
- 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:
apps/meteor/client/views/room/body/RoomForeword/RoomForewordUsernameList.tsxpackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.tspackages/ui-client/src/hooks/index.tspackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/VideoConferenceBlock.tsxapps/meteor/client/views/room/Header/ParentRoom/ParentDiscussion/ParentDiscussion.tsxpackages/ui-client/src/hooks/useRoomRoute.tspackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.spec.tsx
🧠 Learnings (6)
📚 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/room/body/RoomForeword/RoomForewordUsernameList.tsxpackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/VideoConferenceBlock.tsxapps/meteor/client/views/room/Header/ParentRoom/ParentDiscussion/ParentDiscussion.tsxpackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.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:
apps/meteor/client/views/room/body/RoomForeword/RoomForewordUsernameList.tsxpackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.tspackages/ui-client/src/hooks/index.tspackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/VideoConferenceBlock.tsxapps/meteor/client/views/room/Header/ParentRoom/ParentDiscussion/ParentDiscussion.tsxpackages/ui-client/src/hooks/useRoomRoute.tspackages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.spec.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/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.tspackages/ui-client/src/hooks/index.tspackages/ui-client/src/hooks/useRoomRoute.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/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.tspackages/ui-client/src/hooks/index.tspackages/ui-client/src/hooks/useRoomRoute.ts
📚 Learning: 2026-01-19T18:08:05.314Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38169
File: packages/ui-client/src/hooks/useGoToDirectMessage.ts:20-27
Timestamp: 2026-01-19T18:08:05.314Z
Learning: Rule of Hooks: In React, hooks (including custom hooks like useGoToDirectMessage and useUserSubscriptionByName) must be called unconditionally and in the same order on every render. Do not conditionally call hooks based on values; instead, derive safe inputs if a value may be undefined (e.g., pass an empty string or undefined) and handle variations in logic outside the hook invocation. This preserves hook order and avoids violations. Apply this guideline to all files under packages/ui-client/src/hooks where hooks are used.
Applied to files:
packages/ui-client/src/hooks/index.tspackages/ui-client/src/hooks/useRoomRoute.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/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.spec.tsx
🔇 Additional comments (7)
packages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.ts (1)
3-10: LGTM!packages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/VideoConferenceBlock.tsx (1)
2-2: LGTM!Also applies to: 22-22
packages/fuselage-ui-kit/src/blocks/VideoConferenceBlock/hooks/useGoToRoom.spec.tsx (1)
1-66: LGTM!packages/ui-client/src/hooks/useRoomRoute.ts (1)
1-9: LGTM!Also applies to: 15-32
packages/ui-client/src/hooks/index.ts (1)
10-10: LGTM!apps/meteor/client/views/room/Header/ParentRoom/ParentDiscussion/ParentDiscussion.tsx (1)
2-4: LGTM!Also applies to: 14-19
apps/meteor/client/views/room/body/RoomForeword/RoomForewordUsernameList.tsx (1)
3-5: LGTM!Also applies to: 9-18
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41508 +/- ##
===========================================
- Coverage 68.69% 68.66% -0.04%
===========================================
Files 4134 4135 +1
Lines 160417 160450 +33
Branches 29312 29265 -47
===========================================
- Hits 110205 110177 -28
- Misses 45104 45159 +55
- Partials 5108 5114 +6
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…Discussion roomCoordinator.getRoomName prioritized fname over name only when the room is itself a discussion or federated, and otherwise respected UI_Allow_room_names_with_special_chars by falling back to name alone. The router-navigation refactor collapsed this to a plain `fname || name`, always preferring fname even when admins disabled special chars. Replicates the original priority for channels/groups without reintroducing the roomCoordinator dependency. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Proposed changes (including videos or screenshots)
Continues the migration off the Meteor-coupled
roomCoordinatorfor room navigation:roomCoordinatorusage inParentDiscussionandRoomForewordUsernameListwith a newuseRoomRoutehook (navigates using room data already at hand, no API call).useGoToRoomout of@rocket.chat/ui-contextsinto@rocket.chat/fuselage-ui-kit, next to its only consumer (VideoConferenceBlock), since it doesn't need to be a public ui-contexts hook.useRoomRouteout of@rocket.chat/ui-contextsinto@rocket.chat/ui-client, next to its only consumer (ParentDiscussion), for the same reason.No behavior changes for end users.
Issue(s)
Steps to test or reproduce
yarn build,yarn turbo run typecheck --force, andyarn testunitall pass.Further comments
Task: ARCH-2288
Summary by CodeRabbit
New Features
Bug Fixes
Tests