feat(ai): add blocked channel check to triage module (#180)#225
feat(ai): add blocked channel check to triage module (#180)#225BillChirico merged 3 commits intomainfrom
Conversation
- Import isChannelBlocked from ai.js - Add blocked channel check in accumulateMessage to skip blocked channels - Add isChannelBlocked mock to triage tests The blocked channel feature is now fully implemented: - Config schema has blockedChannelIds - isChannelBlocked function exists in ai.js - events.js uses it to block AI responses - triage.js now also checks for blocked channels - Dashboard has the UI for selecting blocked channels
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe pull request introduces channel blocking functionality to the triage module with corresponding test coverage, reorganizes imports in the config module, and applies minor formatting adjustments to command and module files. Changes
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Pull request overview
Adds the missing triage-side enforcement of the AI blocked-channel list so the bot fully ignores messages in blocked channels (per #180).
Changes:
- Import and apply
isChannelBlockedinsidetriage.accumulateMessage()to skip triage processing for blocked channels. - Update triage tests to mock
isChannelBlocked. - Minor formatting-only adjustments in role menu/template and config modules.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/modules/triage.js |
Adds blocked-channel gating to triage message accumulation. |
tests/modules/triage.test.js |
Extends AI module mock to include isChannelBlocked. |
src/modules/roleMenuTemplates.js |
Formatting-only change to an if statement. |
src/modules/config.js |
Import order/whitespace cleanup. |
src/commands/rolemenu.js |
Formatting-only changes (line wrapping / arrow param parens). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
| Filename | Overview |
|---|---|
| src/modules/triage.js | Added blocked channel checks in accumulateMessage and evaluateNow with proper thread/category handling |
| tests/modules/triage.test.js | Comprehensive tests for blocked channel logic including thread vs category channel handling |
Last reviewed commit: 499fe77
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/modules/triage.js`:
- Around line 638-641: The current blocklist check only prevents new
accumulation but lets evaluateNow act on already-buffered content; update the
evaluation path (the evaluateNow function) to re-check
isChannelBlocked(channelId, parentId, guildId) before any classification or
response, and if blocked immediately abort processing and remove/clear the
buffered messages for that channel from the pending buffer (e.g., messageBuffers
/ whatever buffer/map holds pending messages) so previously buffered content
cannot be evaluated later.
In `@tests/modules/triage.test.js`:
- Around line 336-388: Add a regression test that verifies a channel can be
buffered by accumulateMessage and later blocked before evaluateNow so no
classifier/responder runs; specifically, in tests/modules/triage.test.js create
a new it block that calls accumulateMessage(...) for a message (using
makeMessage and accumulateMessage), then mock isChannelBlocked to return true
when evaluateNow runs, call await evaluateNow(channelId, config, client,
healthMonitor), and assert that addToHistory was not called and
mockClassifierSend/mockResponder (or whatever classifier/responder spies are
used in this file) were not called; reference existing helper names
accumulateMessage, evaluateNow, isChannelBlocked, addToHistory, and
mockClassifierSend to locate where to add and what to assert.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
src/commands/rolemenu.jssrc/modules/config.jssrc/modules/roleMenuTemplates.jssrc/modules/triage.jstests/modules/triage-budget.test.jstests/modules/triage.test.js
📜 Review details
⏰ 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: Greptile Review
🧰 Additional context used
📓 Path-based instructions (5)
**/*.js
📄 CodeRabbit inference engine (AGENTS.md)
**/*.js: Use ESM modules — useimport/export, neverrequire()
Always usenode:protocol for Node.js builtins (e.g.import { readFileSync } from 'node:fs')
Always use semicolons in JavaScript code
Use single quotes for strings (enforced by Biome)
Use 2-space indentation (enforced by Biome)
Files:
tests/modules/triage.test.jssrc/modules/roleMenuTemplates.jstests/modules/triage-budget.test.jssrc/modules/config.jssrc/modules/triage.jssrc/commands/rolemenu.js
tests/**/*.js
📄 CodeRabbit inference engine (AGENTS.md)
All new code must include tests. Test coverage must maintain an 80% threshold on statements, branches, functions, and lines. Run
pnpm testbefore every commit
Files:
tests/modules/triage.test.jstests/modules/triage-budget.test.js
src/**/*.js
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.js: Always use Winston logger —import { info, warn, error } from '../logger.js'. NEVER useconsole.log,console.warn,console.error, or anyconsole.*method in src/ files — replace any existing console calls with Winston equivalents
Pass structured metadata to Winston logs:info('Message processed', { userId, channelId })
Files:
src/modules/roleMenuTemplates.jssrc/modules/config.jssrc/modules/triage.jssrc/commands/rolemenu.js
src/modules/*.js
📄 CodeRabbit inference engine (AGENTS.md)
Per-request modules (AI, spam, moderation) should call
getConfig(guildId)on every invocation for automatic config changes. Stateful resources should useonConfigChangelisteners for reactive updates
Files:
src/modules/roleMenuTemplates.jssrc/modules/config.jssrc/modules/triage.js
src/commands/*.js
📄 CodeRabbit inference engine (AGENTS.md)
src/commands/*.js: Slash commands must exportdata(SlashCommandBuilder) andexecute(interaction)function. ExportadminOnly = truefor mod-only commands
Moderation commands must follow the shared pattern:deferReply({ ephemeral: true }), validate inputs,sendDmNotification(), execute Discord action,createCase(),sendModLogEmbed(),checkEscalation()
Files:
src/commands/rolemenu.js
🧠 Learnings (1)
📚 Learning: 2026-03-01T06:03:34.399Z
Learnt from: CR
Repo: VolvoxLLC/volvox-bot PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-01T06:03:34.399Z
Learning: Triage channel buffer holds at most 100 channels. Channels inactive for 30 minutes are evicted. Evicted channels lose their conversation history and restart evaluation from scratch
Applied to files:
src/modules/triage.js
🧬 Code graph analysis (2)
tests/modules/triage.test.js (1)
src/modules/ai.js (4)
isChannelBlocked(40-52)config(42-42)config(60-60)config(75-75)
src/modules/triage.js (1)
src/modules/ai.js (1)
isChannelBlocked(40-52)
🔇 Additional comments (8)
src/modules/roleMenuTemplates.js (1)
93-93: Validation guard refactor is safe.This keeps the same behavior and constraints while improving compactness.
src/commands/rolemenu.js (2)
157-158: List field formatting change is non-functional.No logic change here; output remains equivalent.
214-214: Filter predicate update is correct.Parenthesizing the arrow parameter is stylistic and keeps behavior intact.
src/modules/config.js (1)
11-11: Import consolidation looks good.Using a single authoritative
DANGEROUS_KEYSsource improves consistency.src/modules/triage.js (1)
28-28: Import wiring is correct.
isChannelBlockedis correctly integrated into the triage module surface.tests/modules/triage-budget.test.js (1)
76-76: Mock update is appropriate for test isolation.Defaulting
isChannelBlockedtofalsepreserves existing budget test intent.tests/modules/triage.test.js (2)
72-72: AI mock surface update is correct.Including
isChannelBlockedkeeps the test module contract in sync with triage imports.
336-388: Good new coverage for blocked channels and thread parent handling.These tests validate the intended call contract and early-return behavior.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Completes #180 - Configurable AI channel blocklist
What was done
The feature was already partially implemented. Added the missing check in triage.js:
Already implemented (existing)
blockedChannelIdsisChannelBlockedfunction exists in ai.jsTesting