fix(livechat): prevent whitespace-only values in Name, Description and Messages#38609
fix(livechat): prevent whitespace-only values in Name, Description and Messages#38609Codersintu wants to merge 2 commits into
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 |
|
|
|
WalkthroughAdded client-side validation to form fields in omnichannel triggers to prevent values starting with spaces. Validation checks were added to the Name and Description fields in EditTrigger and the Message field in SendMessageActionForm, with inline error display for failed validation. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
|
Hi, could someone review this PR when possible? Thanks 🙂 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In
`@apps/meteor/client/views/omnichannel/triggers/actions/SendMessageActionForm.tsx`:
- Around line 35-37: Replace the current custom validate that blocks leading
ASCII spaces in the rules for the message input in SendMessageActionForm.tsx
with a trimming transform and let the existing required rule handle empty
values: apply a setValueAs (or onChange/onBlur transform) on the message form
field to trimStart/trim (or trim on submit) so leading/trailing whitespace is
removed before validation, remove the validate that uses startsWith(" "), and
replace the literal error key t('Message cannot start with space') with a real
i18n key or parameterized existing key (e.g., use the registered translation key
for an empty/invalid message) so all locales render correctly.
In `@apps/meteor/client/views/omnichannel/triggers/EditTrigger.tsx`:
- Around line 196-206: The Description TextInput is missing the accessibility
linking used by the Name field; update the Controller render for 'description'
in EditTrigger.tsx to pass the same error and ARIA props as Name: set
error={Boolean(errors?.description)} aria-invalid={Boolean(errors?.description)}
and when there is an error set aria-describedby={`${descriptionField}-error`}
(otherwise omit or undefined), so the TextInput is visually and programmatically
associated with the FieldError element.
- Line 199: The description field Controller uses an inconsistent lowercase
error string and is on one long line; update the validation message used in
Controller name='description' (the validate rule) to title case ("Description
cannot start with space") to match the other fields, and reformat the Controller
+ rules + render (the Controller with control and render that returns TextInput
id={descriptionField}) across multiple lines to match the Name field's
formatting for readability.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/meteor/client/views/omnichannel/triggers/EditTrigger.tsxapps/meteor/client/views/omnichannel/triggers/actions/SendMessageActionForm.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/triggers/actions/SendMessageActionForm.tsxapps/meteor/client/views/omnichannel/triggers/EditTrigger.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). (1)
- GitHub Check: cubic · AI code reviewer
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/meteor/client/views/omnichannel/triggers/actions/SendMessageActionForm.tsx">
<violation number="1" location="apps/meteor/client/views/omnichannel/triggers/actions/SendMessageActionForm.tsx:36">
P3: Missing i18n key for new validation message; the literal string is not defined in locale files, so it won’t be translated.</violation>
<violation number="2" location="apps/meteor/client/views/omnichannel/triggers/actions/SendMessageActionForm.tsx:36">
P2: Validation only rejects a leading literal space. Multiline inputs can start with other whitespace (e.g., newline/tab) and bypass the check, allowing whitespace-only/leading-whitespace messages despite the PR goal.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Proposed changes
Problem
The Livechat Trigger form accepts whitespace-only values (" ") in Name, Description, and Message fields, creating invalid triggers.
Solution
Result
Invalid triggers can no longer be saved.
Issue(s)
Fixes #38512
Steps to test or reproduce
Before: saved successfully
After: validation error shown
Further comments
Small validation improvement. No breaking changes.
Summary by CodeRabbit
Release Notes
Bug Fixes