Skip to content

Fixed unexpected issue with suppressions when no text is provided#247

Merged
sfreeman422 merged 1 commit into
masterfrom
fix/bad-null-check
May 7, 2026
Merged

Fixed unexpected issue with suppressions when no text is provided#247
sfreeman422 merged 1 commit into
masterfrom
fix/bad-null-check

Conversation

@sfreeman422
Copy link
Copy Markdown
Collaborator

@sfreeman422 sfreeman422 commented May 7, 2026

This pull request adds and updates tests for the sendSuppressedMessage method in SuppressorService, 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:

  • Added tests to verify that sendSuppressedMessage returns early when text is undefined, and that neither translation nor message sending is attempted in this case.
  • Added and updated tests to distinguish between when translation or "corpo speak" is used, based on the channel and word count, for both #libworkchat and C023B688SLT.
  • Added tests to verify fallback behavior when either translation or "corpo speak" fails, ensuring that a message is still sent.

Implementation improvements:

  • Updated sendSuppressedMessage to return early if text is undefined, preventing errors and unnecessary service calls.
  • Refined the logic for when "corpo speak" is used: now it triggers for both #libworkchat and C023B688SLT channels only if the message has more than 10 words.
  • Simplified the shouldMuzzle condition to only check for a maximum word count, removing the unnecessary lower bound.

Copilot AI review requested due to automatic review settings May 7, 2026 19:55
@sfreeman422 sfreeman422 merged commit f472e9c into master May 7, 2026
14 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 sendSuppressedMessage to accept text: string | undefined and return early when no text is provided.
  • Change “corpo mode” selection to require > 10 words for both #libworkchat and C023B688SLT.
  • 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',
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.

2 participants