Skip to content

chore: align CurrentChatTags handler type with AutoCompleteTagsMultiple onChange#38879

Open
Agarwalchetan wants to merge 4 commits into
RocketChat:developfrom
Agarwalchetan:fix/current-chat-tags-as-any
Open

chore: align CurrentChatTags handler type with AutoCompleteTagsMultiple onChange#38879
Agarwalchetan wants to merge 4 commits into
RocketChat:developfrom
Agarwalchetan:fix/current-chat-tags-as-any

Conversation

@Agarwalchetan
Copy link
Copy Markdown
Contributor

@Agarwalchetan Agarwalchetan commented Feb 21, 2026

Removes the as any type assertion in CurrentChatTags.tsx by aligning the handler prop type with the onChange type of AutoCompleteTagsMultiple.


Problem

CurrentChatTags manually defined the handler prop as:

(value: { label: string; value: string }[]) => void

However, AutoCompleteTagsMultiple expects an onChange signature derived from PaginatedMultiSelectProps, where:

(values: { value: string | number; label: string }[]) => void

Because string is narrower than string | number, TypeScript rejected the assignment and required an unsafe cast:

onChange={handler as any} // FIXME: any

Solution

The handler type is now derived directly from the component it is passed to:

handler: ComponentProps<typeof AutoCompleteTagsMultiple>['onChange'];

This keeps the prop fully aligned with AutoCompleteTagsMultiple and prevents future type drift. The as any cast has been removed.

Since this change widens the accepted handler type, the callback in Tags.tsx was also updated to match the correct onChange signature and avoid narrowing the parameter type.


Changes

  • Updated handler type in CurrentChatTagsProps to derive from AutoCompleteTagsMultiple['onChange']
  • Removed as any from onChange
  • Updated Tags.tsx handler callback to align with the widened onChange type

Verification

  • TypeScript compiles successfully (yarn typecheck)
  • Lint passes
  • No runtime logic was modified
  • Strictly a type-level improvement

Summary by CodeRabbit

  • Refactor
    • Improved chat tags input handling by aligning event types and removing unsafe type conversions, resulting in more reliable tag selection and fewer runtime issues for users.

@Agarwalchetan Agarwalchetan requested a review from a team as a code owner February 21, 2026 16:11
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Feb 21, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 21, 2026

⚠️ No Changeset found

Latest commit: cc73ea2

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 Feb 21, 2026

Walkthrough

Type and usage updates for tag handlers: CurrentChatTags’s handler prop is retyped to use AutoCompleteTagsMultiple's onChange signature and the unsafe as any cast is removed; Tags.tsx adapts its handler to accept a looser tag shape and maps tags to label strings before delegating.

Changes

Cohort / File(s) Summary
CurrentChatTags type update
apps/meteor/client/views/omnichannel/additionalForms/CurrentChatTags.tsx
Changed CurrentChatTagsProps.handler from a concrete (value: { label: string; value: string }[]) => void to ComponentProps<typeof AutoCompleteTagsMultiple>['onChange']; replaced onChange={handler as any} with onChange={handler}.
Tags handler adaptation
apps/meteor/client/views/omnichannel/components/Tags.tsx
Updated the handler passed to CurrentChatTags to accept an unspecified tag shape (tags) and map tags.map(tag => tag.label) before calling the outer handler (removed explicit tag type annotation).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nibble types and tidy the trail,
No more casts that wobble and fail,
Labels hop out in tidy rows,
Clean code blooms where clarity grows! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: aligning the handler type in CurrentChatTags with AutoCompleteTagsMultiple's onChange, which directly corresponds to the primary objective of removing the 'as any' type assertion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

❤️ Share

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

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.

No issues found across 1 file

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.

🧹 Nitpick comments (1)
apps/meteor/client/views/omnichannel/additionalForms/CurrentChatTags.tsx (1)

7-7: Nitpick: value prop type is not aligned with AutoCompleteTagsMultiple.

handler is now derived from AutoCompleteTagsMultiple's onChange prop, but value is still a hardcoded Array<{ value: string; label: string }>. Per the PR description, AutoCompleteTagsMultiple uses string | number for value entries — keeping a hand-rolled narrower type here is inconsistent with the refactor's intent. It's harmless today (string ⊆ string | number), but could silently reject valid callers passing numeric values.

♻️ Optional alignment
-	value: Array<{ value: string; label: string }>;
+	value: NonNullable<ComponentProps<typeof AutoCompleteTagsMultiple>['value']>;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/omnichannel/additionalForms/CurrentChatTags.tsx` at
line 7, The prop type for value in the CurrentChatTags component is narrower
than AutoCompleteTagsMultiple's items and should be widened to accept numeric
values too; update the value prop type used in CurrentChatTags (the value prop
and any local type alias it uses) from Array<{ value: string; label: string }>
to Array<{ value: string | number; label: string }> so it matches
AutoCompleteTagsMultiple and prevents rejecting numeric tag values.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3145c41 and d9323ce.

📒 Files selected for processing (1)
  • apps/meteor/client/views/omnichannel/additionalForms/CurrentChatTags.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:

  • apps/meteor/client/views/omnichannel/additionalForms/CurrentChatTags.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). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
apps/meteor/client/views/omnichannel/additionalForms/CurrentChatTags.tsx (1)

8-8: Verify that handler hasn't inadvertently become optional.

ComponentProps<typeof AutoCompleteTagsMultiple>['onChange'] resolves to exactly what the underlying component declares. AutoCompleteTagsMultiple inherits from ComponentProps<typeof PaginatedMultiSelectFiltered> without explicitly overriding the onChange type, yet provides a default parameter onChange = () => undefined. If the underlying component's onChange prop is optional, the extracted type would include undefined, silently making handler optional. This would be inconsistent with all current usages, which pass non-nullable values from React Hook Form field callbacks.

Verify the type of onChange in PaginatedMultiSelectFiltered from @rocket.chat/fuselage. If optional, consider using NonNullable to preserve the required behavior:

Proposed fix if `onChange` is optional in the underlying component
-	handler: ComponentProps<typeof AutoCompleteTagsMultiple>['onChange'];
+	handler: NonNullable<ComponentProps<typeof AutoCompleteTagsMultiple>['onChange']>;
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/meteor/client/views/omnichannel/additionalForms/CurrentChatTags.tsx`:
- Line 7: The prop type for value in the CurrentChatTags component is narrower
than AutoCompleteTagsMultiple's items and should be widened to accept numeric
values too; update the value prop type used in CurrentChatTags (the value prop
and any local type alias it uses) from Array<{ value: string; label: string }>
to Array<{ value: string | number; label: string }> so it matches
AutoCompleteTagsMultiple and prevents rejecting numeric tag values.

…rwalchetan/Rocket.Chat into fix/current-chat-tags-as-any

# Conflicts:
#	apps/meteor/client/views/omnichannel/additionalForms/CurrentChatTags.tsx
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 21, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.57%. Comparing base (3145c41) to head (cc73ea2).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38879      +/-   ##
===========================================
+ Coverage    70.55%   70.57%   +0.01%     
===========================================
  Files         3189     3189              
  Lines       112703   112695       -8     
  Branches     20429    20420       -9     
===========================================
+ Hits         79519    79535      +16     
+ Misses       31123    31095      -28     
- Partials      2061     2065       +4     
Flag Coverage Δ
e2e 60.35% <100.00%> (+<0.01%) ⬆️
e2e-api 47.80% <ø> (-0.04%) ⬇️
unit 71.58% <33.33%> (+0.03%) ⬆️

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.

@Agarwalchetan
Copy link
Copy Markdown
Contributor Author

Hi, just a gentle follow-up on this PR
Please let me know if any changes or clarifications are needed.
Happy to update accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant