Fixed unexpected issue with suppressions when no text is provided#247
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates SuppressorService.sendSuppressedMessage to avoid failures when message text is missing, and adjusts when “corpo mode” is used, with expanded unit tests to cover the new behaviors.
Changes:
- Allow
sendSuppressedMessageto accepttext: string | undefinedand return early when no text is provided. - Change “corpo mode” selection to require
> 10words for both#libworkchatandC023B688SLT. - Add/adjust tests for undefined text handling, corpo-mode thresholds, and translation fallback.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/backend/src/shared/services/suppressor.service.ts | Handles undefined text and adjusts corpo-mode selection logic. |
| packages/backend/src/shared/services/suppressor.service.spec.ts | Adds tests for new early-return behavior and updated corpo/translation paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await this.webService.deleteMessage(channel, timestamp, userId); | ||
|
|
||
| const words = text.split(' '); | ||
| if (!text) { |
| return; | ||
| } | ||
|
|
||
| const words: string[] | undefined = text.split(' '); |
| .join(' '); | ||
|
|
||
| const shouldCorpo = channel === '#libworkchat' || (channel === 'C023B688SLT' && words.length > 10); | ||
| const shouldCorpo = (channel === '#libworkchat' || channel === 'C023B688SLT') && words.length > 10; |
Comment on lines
+227
to
233
| it('sendSuppressedMessage falls back when corpo speak fails', async () => { | ||
| (suppressorService.aiService.generateCorpoSpeak as Mock).mockRejectedValue(new Error('ai fail')); | ||
|
|
||
| await suppressorService.sendSuppressedMessage( | ||
| '#libworkchat', | ||
| 'U1', | ||
| 'hello world', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds and updates tests for the
sendSuppressedMessagemethod inSuppressorService, and makes the implementation more robust by improving input validation and refining the logic for when "corpo speak" should be used. The changes ensure better handling of edge cases and clarify the conditions under which translation or AI-based message generation is invoked.Test coverage improvements:
sendSuppressedMessagereturns early whentextisundefined, and that neither translation nor message sending is attempted in this case.#libworkchatandC023B688SLT.Implementation improvements:
sendSuppressedMessageto return early iftextisundefined, preventing errors and unnecessary service calls.#libworkchatandC023B688SLTchannels only if the message has more than 10 words.shouldMuzzlecondition to only check for a maximum word count, removing the unnecessary lower bound.