Skip to content

Comments

chore: unsafe type assertion in CannedResponseForm#38341

Merged
kodiakhq[bot] merged 7 commits intoRocketChat:developfrom
NAME-ASHWANIYADAV:fix/38340-canned-response-form-types
Jan 27, 2026
Merged

chore: unsafe type assertion in CannedResponseForm#38341
kodiakhq[bot] merged 7 commits intoRocketChat:developfrom
NAME-ASHWANIYADAV:fix/38340-canned-response-form-types

Conversation

@NAME-ASHWANIYADAV
Copy link
Contributor

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV commented Jan 26, 2026

Description

This PR removes an unsafe type assertion (as unknown as string[]) from the
CannedResponseForm component. The fix uses nullish coalescing (??) to safely
handle potentially undefined values coming from React Hook Form.

This improves type safety while keeping the existing behavior unchanged.

Related issue

Changes proposed

  • Removed the unsafe as unknown as string[] type assertion.
  • Removed the // FIXME: fix types comment.
  • Added value ?? [] to provide a default empty array when the value is
    undefined.

Before

<Tags handler={onChange} tags={value as unknown as string[]} /> // FIXME: fix types

After

<Tags handler={onChange} tags={value ?? []} />

Verification

  • No TypeScript errors.
  • Type safety is maintained.
  • Functionality remains unchanged.

COMM-133

Summary by CodeRabbit

  • Refactor
    • Simplified type handling in the canned responses form by removing an unnecessary assertion and relying on the Tags field to accept values directly. This change also removes an outdated inline comment and improves code clarity, maintainability, and reduces surface area for future type-related issues.

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

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV requested a review from a team as a code owner January 26, 2026 12:13
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 26, 2026

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

  • This PR is targeting the wrong base branch. It should target 8.2.0, but it targets 8.1.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2026

⚠️ No Changeset found

Latest commit: 4381931

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 26, 2026

Walkthrough

Removed an unsafe type assertion in CannedResponseForm: the Tags component now receives the form value directly instead of casting it with as unknown as string[].

Changes

Cohort / File(s) Summary
Type Safety Refactor
apps/meteor/client/views/omnichannel/cannedResponses/components/CannedResponseForm.tsx
Removed as unknown as string[] cast when passing value to Tags; now passes tags={value} and removed the FIXME cast.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 I hopped through code with careful paws,
Removed a cast that made no laws,
Now tags flow true, no forced disguise,
Type-safe trails beneath my eyes ✨

🚥 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 accurately describes the main change: removing an unsafe type assertion in CannedResponseForm.
Linked Issues check ✅ Passed The PR addresses all objectives from #38340: removes the FIXME comment, eliminates the unsafe type assertion, and achieves type-safe code.
Out of Scope Changes check ✅ Passed All changes in the PR are directly related to addressing the unsafe type assertion in CannedResponseForm as specified in the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

@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 2 files

@KevLehman KevLehman added the area: ui Touches the code on client side label Jan 26, 2026
Copy link
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!
For this small refactor we don't need to add the changeset, so you can remove it :)

@NAME-ASHWANIYADAV
Copy link
Contributor Author

Thanks for the review @dougfabris !

I've removed the changeset file as suggested. Please review when you get a chance. 🙏

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 1 file

@dougfabris dougfabris changed the title refactor(omnichannel): fix unsafe type assertion in CannedResponseForm chore: unsafe type assertion in CannedResponseForm Jan 27, 2026
dougfabris
dougfabris previously approved these changes Jan 27, 2026
@dougfabris dougfabris added this to the 8.2.0 milestone Jan 27, 2026
@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Jan 27, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 27, 2026
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.79%. Comparing base (c6ec7a9) to head (4381931).
⚠️ Report is 23 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38341      +/-   ##
===========================================
+ Coverage    70.77%   70.79%   +0.01%     
===========================================
  Files         3159     3159              
  Lines       109401   109397       -4     
  Branches     19675    19673       -2     
===========================================
+ Hits         77428    77443      +15     
+ Misses       29944    29922      -22     
- Partials      2029     2032       +3     
Flag Coverage Δ
e2e 60.31% <100.00%> (-0.02%) ⬇️
e2e-api 48.88% <ø> (+1.02%) ⬆️
unit 71.95% <0.00%> (-0.02%) ⬇️

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.

@kodiakhq kodiakhq bot merged commit 31d0c01 into RocketChat:develop Jan 27, 2026
62 of 64 checks passed
@dougfabris dougfabris added contrib: valid A valid contribution where maintainers will review based on priority labels Feb 3, 2026
Rohit3523 pushed a commit that referenced this pull request Feb 4, 2026
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui Touches the code on client side contrib: valid A valid contribution where maintainers will review based on priority 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.

Refactor: Fix unsafe type assertion in CannedResponseForm

3 participants