Skip to content

fix(discord): ignore system messages so thread renames don't reach the agent#51

Open
scriptease wants to merge 2 commits into
RunMaestro:mainfrom
scriptease:main
Open

fix(discord): ignore system messages so thread renames don't reach the agent#51
scriptease wants to merge 2 commits into
RunMaestro:mainfrom
scriptease:main

Conversation

@scriptease

@scriptease scriptease commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Problem

When a user renames a Discord thread the AI is working in, Discord emits a messageCreate event carrying a system message (MessageType.ChannelNameChange). Its author is the renaming user (not a bot) and its content is the new thread name. The handler had no system-message guard, so it passed every check and enqueued a bare message containing just the new thread name to the agent.

Fix

One-line guard in src/providers/discord/messageCreate.ts:

if (message.author.bot) return;
if (message.system) return;      // ← added
if (!message.guild) return;

message.system is true for all Discord system messages (thread renames, pins, member joins, etc.), so this also filters other system-message noise that should never reach the agent.

Tests

Added regression test handleMessageCreate ignores system messages (e.g. thread rename). All 212 tests pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Discord system messages (such as thread renames) are now properly ignored and do not trigger message processing.
  • Tests

    • Added test coverage to verify system messages are correctly ignored during message handling.

scriptease and others added 2 commits June 20, 2026 15:55
…e agent

A thread rename emits a messageCreate system message whose content is the
new thread name. With no system-message guard it was enqueued to the agent
as a bare message. Filter message.system early (also drops pins, joins, etc).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(discord): ignore system messages so thread renames don't reach the agent
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6001fe66-4762-453c-b037-9381bded40d8

📥 Commits

Reviewing files that changed from the base of the PR and between 8424883 and e323180.

📒 Files selected for processing (2)
  • src/__tests__/messageCreate.test.ts
  • src/providers/discord/messageCreate.ts

📝 Walkthrough

Walkthrough

A one-line early-return guard is added to createMessageCreateHandler to skip processing when message.system is true. A corresponding test verifies that the enqueue callback is not called when the handler receives a system message such as a thread rename.

Changes

System Message Early-Return Guard

Layer / File(s) Summary
System message guard and test
src/providers/discord/messageCreate.ts, src/__tests__/messageCreate.test.ts
Handler returns early when message.system is true; new test asserts the enqueue callback is not invoked for a system message (e.g., thread rename).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A bunny hops through Discord's stream,
But system notes? They're not what they seem.
"Thread renamed!" cries the server aloud —
The relay just shrugs, skips past the crowd.
Only real messages earn the queue's gleam! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding a guard to ignore Discord system messages to prevent thread renames from reaching the agent.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant