refactor: migrate SidePanelInternal to Virtua - #41255
Conversation
|
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 |
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
ChangesSidepanel virtua migration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant SidePanelInternal
participant CustomVirtuaScrollbars
participant Virtualizer
participant SidePanelVirtualItem
participant SidepanelListItem
SidePanelInternal->>CustomVirtuaScrollbars: render scroll viewport
CustomVirtuaScrollbars->>Virtualizer: provide virtualized room list
Virtualizer->>SidePanelVirtualItem: render indexed room item
SidePanelVirtualItem->>SidepanelListItem: forward room props and styles
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx (1)
125-136: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd edge-case tests for empty and undefined
rooms.The current test only covers the happy path with two rooms. Consider adding tests for:
rooms={[]}— verifiesSidePanelNoResultsrenders and the emptyVirtualizerdoesn't crash.rooms={undefined}(if applicable perSidePanelProps) — verifies noTypeErrorfromrooms.map().This is especially important given the
rooms?.lengthoptional chaining on Line 77 ofSidePanelInternal.tsx, which suggestsundefinedis a valid input.🤖 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/navigation/sidepanel/SidePanelInternal.spec.tsx` around lines 125 - 136, The current SidePanelInternal.spec.tsx test only covers the populated rooms path; add coverage for empty and undefined rooms to match the optional handling in SidePanelInternal. Add a test for SidePanel with rooms as an empty array to verify SidePanelNoResults renders and Virtua still mounts without crashing, and if SidePanelProps allows it, add a test for rooms being undefined to ensure the component does not throw from any rooms.map usage. Use the existing SidePanel and SidePanelNoResults behavior as the anchor points for locating the relevant assertions.
🤖 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 `@apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx`:
- Around line 11-43: The SidePanel spec is missing the focus/navigation context
required by SidepanelListWrapper, so the test can fail when
useSidebarListNavigation() calls useFocusManager(). Fix this by either wrapping
the rendered SidePanel in the same FocusScope-backed context used by the real
navigation tree or by mocking useSidebarListNavigation in this spec. Use the
existing SidepanelListWrapper and useSidebarListNavigation symbols to locate the
setup and keep the mock/context consistent with the component tree.
---
Nitpick comments:
In `@apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx`:
- Around line 125-136: The current SidePanelInternal.spec.tsx test only covers
the populated rooms path; add coverage for empty and undefined rooms to match
the optional handling in SidePanelInternal. Add a test for SidePanel with rooms
as an empty array to verify SidePanelNoResults renders and Virtua still mounts
without crashing, and if SidePanelProps allows it, add a test for rooms being
undefined to ensure the component does not throw from any rooms.map usage. Use
the existing SidePanel and SidePanelNoResults behavior as the anchor points for
locating the relevant assertions.
🪄 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: fe15597f-3f80-4b8e-a526-1c646a2da0ca
📒 Files selected for processing (3)
apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsxapps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsxapps/meteor/client/views/navigation/sidepanel/SidepanelListWrapper.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: cubic · AI code reviewer
🧰 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/navigation/sidepanel/SidepanelListWrapper.tsxapps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsxapps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx
🧠 Learnings (3)
📚 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/navigation/sidepanel/SidepanelListWrapper.tsxapps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsxapps/meteor/client/views/navigation/sidepanel/SidePanelInternal.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/navigation/sidepanel/SidepanelListWrapper.tsxapps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsxapps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx
📚 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:
apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx
🔇 Additional comments (4)
apps/meteor/client/views/navigation/sidepanel/SidepanelListWrapper.tsx (1)
3-17: LGTM!apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.tsx (2)
14-33: LGTM!
77-91: 🩺 Stability & Availability
rooms.map()is safe here.SidePanelProps.roomsis required (R[]), so this path can’t receiveundefined.> Likely an incorrect or invalid review comment.apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx (1)
78-102: LGTM!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/GSoC-2026-virtual-list-project #41255 +/- ##
======================================================================
Coverage ? 69.18%
======================================================================
Files ? 3468
Lines ? 135829
Branches ? 23721
======================================================================
Hits ? 93968
Misses ? 38458
Partials ? 3403
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…al items react-virtuoso previously forwarded index as data-item-index onto each rendered SidepanelListItem, which the feature-preview E2E spec asserts on directly (data-item-index="1"). The Virtua migration silently dropped this attribute; restore it so the item wrapper keeps parity with the old DOM output. Co-authored-by: Cursor <cursoragent@cursor.com>
| ref, | ||
| ) { | ||
| return ( | ||
| <SidepanelListItem ref={ref} data-item-index={index} style={style} {...props}> |
There was a problem hiding this comment.
| <SidepanelListItem ref={ref} data-item-index={index} style={style} {...props}> | |
| <SidepanelListItem ref={ref} style={style} {...props}> |
We should avoid adding data-* attributes whenever we can, and from what I can see this is only used by the test right?
There was a problem hiding this comment.
Thanks, Martin! I wanted to double-check this one before removing it. I originally added data-item-index because one of the existing E2E tests (feature-preview.spec.ts) relies on it to verify the room ordering after the Virtua migration. Removing it would make that test fail again. Would you prefer updating the E2E test to use a different selector, or should we keep this attribute for compatibility?
Addresses review feedback from Martin Schoeler on PR RocketChat#41255: - Remove the unnecessary @rocket.chat/fuselage jest mock from SidePanelInternal.spec.tsx; fuselage components render fine unmocked. - Extract the inline sidePanelVirtualItem wrapper into its own SidePanelVirtualItem.tsx, matching the RoomMembers/BannedUsers convention, removing the now-unneeded react/no-multi-comp disable. - Add SidePanelInternal.stories.tsx and rework the spec to use the composeStories + toMatchSnapshot pattern established by BannedUsers/ RoomMembers/RoomFiles, while preserving the existing list-semantics, data-item-index, and aria-current assertions. data-item-index is intentionally left untouched pending Martin's response, since apps/meteor/tests/e2e/feature-preview.spec.ts relies on it to verify room ordering. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Whole-tree baseElement snapshots baked in the useId() output for the unread toggle label, which shifts with render order/count (e.g. running a single story in isolation) rather than reflecting the tree itself. Replace the snapshot with semantic assertions, matching the existing behavioral test style in this file. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx (1)
74-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the implementation comments.
Lines 74-77 add a four-line implementation comment. The
*.tsxguideline says to avoid code comments in implementation. Keep the semantic assertion. Move the snapshot rationale to the PR description if it must remain documented.🤖 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/navigation/sidepanel/SidePanelInternal.spec.tsx` around lines 74 - 77, Remove the four-line implementation comment explaining why baseElement is not snapshot-tested in SidePanelInternal.spec.tsx, while preserving the existing semantic assertions and story-specific tests 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 `@apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx`:
- Around line 74-77: Remove the four-line implementation comment explaining why
baseElement is not snapshot-tested in SidePanelInternal.spec.tsx, while
preserving the existing semantic assertions and story-specific tests unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 84bc8999-1233-43c6-9153-edb4fbdc76d1
📒 Files selected for processing (1)
apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: cubic · AI code reviewer
⚠️ CI failures not shown inline (1)
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ❌ **Has milestone or project** — This PR is missing the required milestone or project
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 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/navigation/sidepanel/SidePanelInternal.spec.tsx
🧠 Learnings (3)
📚 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:
apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.
Applied to files:
apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.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/navigation/sidepanel/SidePanelInternal.spec.tsx
🔇 Additional comments (4)
apps/meteor/client/views/navigation/sidepanel/SidePanelInternal.spec.tsx (4)
1-69: LGTM!
78-80: LGTM!
83-98: LGTM!
100-107: LGTM!
Proposed changes
This PR migrates SidePanelInternal from react-virtuoso to Virtua while preserving the existing behavior as closely as possible.
Changes included
This migration is intentionally scoped to replacing the virtualization layer only, avoiding unrelated behavioral or architectural changes.
Issue(s)
Part of the GSoC Virtua migration effort.
Steps to test or reproduce
Further comments
Following the project's migration strategy, this implementation replaces only the virtualization layer while preserving the existing behavior.
Since this component is not paginated, it uses a local Virtua implementation instead of PaginatedVirtualList, following the guidance provided during the project discussion. The existing SidepanelListWrapper, keyboard navigation, and DOM semantics have been preserved to minimize behavioral changes and keep the migration isolated to this component.
Summary by CodeRabbit
Improvements
Tests