feat(feedback): allow error messages to be customized#20474
feat(feedback): allow error messages to be customized#20474
Conversation
There was a problem hiding this comment.
Pull request overview
Adds customizable Feedback error messages by shifting internal error handling to stable error codes, which the UI can map to user-provided text (i18n/custom wording) while keeping defaults.
Changes:
- Introduces
FeedbackErrorCode+createFeedbackError(...)and updatessendFeedbackto throw/reject with error codes. - Wires new error-text options through the integration defaults and into the modal
Formto render customized messages. - Updates
sendFeedbacktests to assert on error codes instead of full English strings.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/feedback/test/core/sendFeedback.test.ts | Updates assertions to expect error-code rejections. |
| packages/feedback/src/util/createFeedbackError.ts | Adds a typed error-code union and helper to create errors. |
| packages/feedback/src/modal/components/Form.tsx | Maps error codes to configurable UI strings; normalizes thrown values to Error. |
| packages/feedback/src/core/sendFeedback.ts | Reworks error messaging to use codes (throws + Promise rejections). |
| packages/feedback/src/core/integration.ts | Adds new text options with defaults and passes them through internal options. |
| packages/feedback/src/constants/index.ts | Defines default error-text constants for each error code. |
| packages/core/src/types-hoist/feedback/config.ts | Extends public text configuration type with new error-text fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
size-limit report 📦
|
|
|
||
| await expect( | ||
| sendFeedback({ message: 'mi' }, { errorMessages: { ERROR_FORBIDDEN: 'custom forbidden text' } }), | ||
| ).rejects.toMatch('custom forbidden text'); |
There was a problem hiding this comment.
l: maybe it could be worth adding a case where we check that non-overriden messages keep the default?
JPeer264
left a comment
There was a problem hiding this comment.
LGTM. Also nice that it only bumps the specific feedback bundles
| @@ -1,11 +1,14 @@ | |||
| /* eslint-disable max-lines */ | |||
| /* eslint-disable complexity */ | |||
There was a problem hiding this comment.
l: Could this be avoided by outsourcing wrappedSendFeedback ? Would still be nice to keep as many eslint oxlint rules as possible
There was a problem hiding this comment.
Complexity is coming from the massive destructions, extracting the inner function doesn't make the rule pass 😕
dadaa16 to
90ec385
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 90ec385. Configure here.
Adds five new text options (errorEmptyMessageText, errorNoClientText, errorTimeoutText, errorForbiddenText, errorGenericText) to FeedbackTextConfiguration so consumers can translate or reword the widget's error messages. sendFeedback now throws/rejects with stable codes (typed via FeedbackErrorCode) and the widget maps those codes to the configured text. Closes #14687 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Form: use ?? so empty-string text overrides are respected (Copilot) - constants: grammar fix "with an empty message" (Copilot) - sendFeedback: clean up afterSendEvent listener on timeout to avoid leak (Copilot) - tests: cover empty-message and no-client early-return paths (Copilot) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…messages Addresses review feedback that sendFeedback (a public API) was rejecting with internal codes instead of human-readable strings, changing observable behavior for non-widget consumers. sendFeedback now accepts optional errorMessages overrides via its hint argument, defaulting to the original English strings. The widget wraps sendFeedback to inject its configured text options, so standalone consumers of sendFeedback see the same strings as before. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Keeps the default error string identical to the pre-PR version so standalone sendFeedback consumers matching on the exact message string see no behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
90ec385 to
029c535
Compare

Adds text options to
FeedbackTextConfigurationto allow customizing the widget's error messages (for i18n and other purposes).sendFeedbacknow accepts optionalerrorMessagesoverrides via itshintargument, defaulting to the original English strings. The widget wrapssendFeedbackto inject the configured text options before the form displays them.Standalone
sendFeedbackconsumers see the same English messages as before — no observable behavior change.Closes #14687