fix(ui-kit): Fix type guard mismatches for InputBlock and ActionsBlock#39416
fix(ui-kit): Fix type guard mismatches for InputBlock and ActionsBlock#39416shrijatewari wants to merge 3 commits intoRocketChat:developfrom
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 |
🦋 Changeset detectedLatest commit: c3b9f2c The changes in this PR will be included in the next version bump. This PR includes changesets to release 42 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
|
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 (7)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
**/*.spec.ts📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (7)📓 Common learnings📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2025-11-24T17:08:17.065ZApplied to files:
📚 Learning: 2025-12-10T21:00:43.645ZApplied to files:
📚 Learning: 2026-02-24T19:22:48.358ZApplied to files:
📚 Learning: 2026-03-06T18:10:15.268ZApplied to files:
🔇 Additional comments (2)
WalkthroughDisabled the Yarn engines plugin and added an HTML template to webpack config. Extended two UI-kit type-guard functions to recognize additional BlockElementType variants and added unit tests covering valid and invalid element classifications. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the 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. Comment |
There was a problem hiding this comment.
1 issue found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".yarnrc.yml">
<violation number="1" location=".yarnrc.yml:11">
P2: Commenting out the Yarn engines plugin disables enforcement of the repo’s declared Node/Yarn engine requirements, allowing installs on unsupported runtimes.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| # Temporarily disabled engines plugin for development | ||
| # plugins: | ||
| # - path: .yarn/plugins/@yarnpkg/plugin-engines.cjs | ||
| # spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js" |
There was a problem hiding this comment.
P2: Commenting out the Yarn engines plugin disables enforcement of the repo’s declared Node/Yarn engine requirements, allowing installs on unsupported runtimes.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .yarnrc.yml, line 11:
<comment>Commenting out the Yarn engines plugin disables enforcement of the repo’s declared Node/Yarn engine requirements, allowing installs on unsupported runtimes.</comment>
<file context>
@@ -8,8 +8,9 @@ enableImmutableInstalls: false
-plugins:
- - path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
- spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js"
+# Temporarily disabled engines plugin for development
+# plugins:
+# - path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
</file context>
| # Temporarily disabled engines plugin for development | |
| # plugins: | |
| # - path: .yarn/plugins/@yarnpkg/plugin-engines.cjs | |
| # spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js" | |
| plugins: | |
| - path: .yarn/plugins/@yarnpkg/plugin-engines.cjs | |
| spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js" |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.yarnrc.yml:
- Around line 11-14: The commented-out "plugins" block in .yarnrc.yml (the lines
referencing .yarn/plugins/@yarnpkg/plugin-engines.cjs and its spec URL) is a
temporary local workaround that disables Node.js version validation and must not
be merged to develop; revert the change by restoring the plugins block
(uncomment the .yarnrc.yml plugin entries) so the engines plugin remains enabled
for the team, or if this must stay local move the comment into a local-only
config (or document the reason and add a flag to prevent merging) and add a
short PR note explaining why any deviation is intentionally local-only.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e42ffa8a-2b89-43b8-ad98-bb09e1d78ff8
📒 Files selected for processing (6)
.yarnrc.ymlpackages/livechat/webpack.config.tspackages/ui-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isActionsBlockElement.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.ts
📜 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). (1)
- GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isActionsBlockElement.tspackages/livechat/webpack.config.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.ts
**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use.spec.tsextension for test files (e.g.,login.spec.ts)
Files:
packages/ui-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.ts
🧠 Learnings (9)
📓 Common learnings
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39304
File: packages/ui-contexts/src/ActionManagerContext.ts:26-26
Timestamp: 2026-03-04T14:16:49.202Z
Learning: In `packages/ui-contexts/src/ActionManagerContext.ts` (TypeScript, RocketChat/Rocket.Chat), the `disposeView` method in `IActionManager` uses an intentionally explicit union `UiKit.ModalView['id'] | UiKit.BannerView['viewId'] | UiKit.ContextualBarView['id']` to document which view types are accepted, even though all constituents resolve to the same primitive. The inline `// eslint-disable-next-line typescript-eslint/no-duplicate-type-constituents` comment is intentional and should not be flagged or removed.
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files
Applied to files:
packages/ui-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests
Applied to files:
packages/ui-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.spec.ts : Use descriptive test names that clearly communicate expected behavior in Playwright tests
Applied to files:
packages/ui-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.ts
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
Learning: Adopt the monorepo-wide Jest testMatch pattern: <rootDir>/src/**/*.spec.{ts,js,mjs} (represented here as '**/src/**/*.spec.{ts,js,mjs}') to ensure spec files under any package's src directory are picked up consistently across all packages in the Rocket.Chat monorepo. Apply this pattern in jest.config.ts for all relevant packages to maintain uniform test discovery.
Applied to files:
packages/ui-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.
Applied to files:
packages/ui-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.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 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-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isActionsBlockElement.tspackages/livechat/webpack.config.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.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-kit/src/blocks/isActionsBlockElement.spec.tspackages/ui-kit/src/blocks/isActionsBlockElement.tspackages/livechat/webpack.config.tspackages/ui-kit/src/blocks/isInputBlockElement.spec.tspackages/ui-kit/src/blocks/isInputBlockElement.ts
📚 Learning: 2026-03-04T14:16:49.202Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39304
File: packages/ui-contexts/src/ActionManagerContext.ts:26-26
Timestamp: 2026-03-04T14:16:49.202Z
Learning: In `packages/ui-contexts/src/ActionManagerContext.ts` (TypeScript, RocketChat/Rocket.Chat), the `disposeView` method in `IActionManager` uses an intentionally explicit union `UiKit.ModalView['id'] | UiKit.BannerView['viewId'] | UiKit.ContextualBarView['id']` to document which view types are accepted, even though all constituents resolve to the same primitive. The inline `// eslint-disable-next-line typescript-eslint/no-duplicate-type-constituents` comment is intentional and should not be flagged or removed.
Applied to files:
packages/ui-kit/src/blocks/isActionsBlockElement.ts
🔇 Additional comments (5)
packages/livechat/webpack.config.ts (1)
136-141: LGTM!The template addition works correctly. HtmlWebpackPlugin's default
inject: truebehavior will automatically inject the bundled scripts (before</body>) and styles (in<head>) into the template, so explicit injection tags inindex.ejsare not required.packages/ui-kit/src/blocks/isInputBlockElement.ts (1)
5-25: Runtime guard now matches the declared input-element union.Nice fix. The added cases line up with
packages/ui-kit/src/blocks/layout/InputBlock.ts, so valid input elements should no longer be rejected at render time.packages/ui-kit/src/blocks/isInputBlockElement.spec.ts (1)
5-46: Coverage looks solid for the expanded input guard.The spec hits both sides of the predicate and includes every newly accepted input type, so this should keep the runtime fix well protected.
packages/ui-kit/src/blocks/isActionsBlockElement.ts (1)
5-26: Actions-block guard is now consistent with the layout type.This now matches the allowed element union in
packages/ui-kit/src/blocks/layout/ActionsBlock.ts, so the added select variants should pass the runtime check correctly.packages/ui-kit/src/blocks/isActionsBlockElement.spec.ts (1)
5-46: Good regression coverage for the actions guard.The table of valid and invalid types cleanly exercises the broadened switch, which should make future mismatches easier to catch.
- Temporarily disable engines plugin in .yarnrc.yml for Node version compatibility - Add template path to livechat webpack config for proper index.html generation Made-with: Cursor
- Add 7 missing element types to isInputBlockElement: MULTI_CHANNELS_SELECT, MULTI_CONVERSATIONS_SELECT, MULTI_USERS_SELECT, CHECKBOX, RADIO_BUTTON, TIME_PICKER, TOGGLE_SWITCH - Add 6 missing element types to isActionsBlockElement: CHANNELS_SELECT, CONVERSATIONS_SELECT, MULTI_CHANNELS_SELECT, MULTI_CONVERSATIONS_SELECT, MULTI_USERS_SELECT, USERS_SELECT - Add comprehensive unit tests for both type guards Fixes runtime type checking failures where valid InputBlock and ActionsBlock elements were incorrectly rejected by SurfaceRenderer methods. Made-with: Cursor
Made-with: Cursor
505d06a to
c3b9f2c
Compare
[Description of the PR here:
Fixes type guard mismatches in
isInputBlockElementandisActionsBlockElementthat were causing valid UIKit block elements to be incorrectly rejected at runtime.Changes I made
isInputBlockElement:MULTI_CHANNELS_SELECTMULTI_CONVERSATIONS_SELECTMULTI_USERS_SELECTCHECKBOXRADIO_BUTTONTIME_PICKERTOGGLE_SWITCHisActionsBlockElement:CHANNELS_SELECTCONVERSATIONS_SELECTMULTI_CHANNELS_SELECTMULTI_CONVERSATIONS_SELECTMULTI_USERS_SELECTUSERS_SELECTProblem
The
InputBlockandActionsBlocktypes include element types that were not being checked by their respective type guards (isInputBlockElementandisActionsBlockElement). This causedSurfaceRenderer.renderInputBlockElement()andSurfaceRenderer.renderActionsBlockElement()to incorrectly reject valid elements at runtime.Testing
Impact of this:
This fixes a bug where valid UIKit elements (like
MultiChannelsSelectElement,CheckboxElement,RadioButtonElement, etc.) were being incorrectly rejected, preventing them from being rendered in InputBlocks and ActionsBlocks.Related
This addresses the type guard inconsistencies identified in the UIKit and Fuselage codebase review.
Summary by CodeRabbit
-
- Extended support for additional block element types (selects, multi-selects, users/channels/conversations selects, checkboxes, radio, timepicker, toggles) as action and input elements.
-
- Added comprehensive unit tests covering the updated block element type validations.
-
- Temporarily disabled an engines-related plugin in the build config and clarified the HTML template used by the build.
](https://github.com//pull/39416)New Features
Tests
Chores