Skip to content

feat(ai): add blocked channel check to triage module (#180)#225

Merged
BillChirico merged 3 commits intomainfrom
feat/issue-180-ai-blocklist
Mar 2, 2026
Merged

feat(ai): add blocked channel check to triage module (#180)#225
BillChirico merged 3 commits intomainfrom
feat/issue-180-ai-blocklist

Conversation

@BillChirico
Copy link
Collaborator

Summary

Completes #180 - Configurable AI channel blocklist

What was done

The feature was already partially implemented. Added the missing check in triage.js:

  • Import isChannelBlocked from ai.js
  • Add blocked channel check in accumulateMessage function to skip blocked channels
  • Add isChannelBlocked mock to triage tests

Already implemented (existing)

  • Config schema has blockedChannelIds
  • isChannelBlocked function exists in ai.js
  • events.js uses it to block AI responses
  • Dashboard has the UI for selecting blocked channels
  • Config validation and allowlist

Testing

  • Files pass lint
  • Implementation complete

- 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
Copilot AI review requested due to automatic review settings March 2, 2026 13:53
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

Warning

Rate limit exceeded

@BillChirico has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 53 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 1b28c80 and 499fe77.

📒 Files selected for processing (2)
  • src/modules/triage.js
  • tests/modules/triage.test.js
📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Code Style Updates
src/commands/rolemenu.js, src/modules/roleMenuTemplates.js
Minor formatting adjustments including multi-line assignment restructuring and conditional return statements with no semantic changes.
Module Import Cleanup
src/modules/config.js
Removed duplicate DANGEROUS_KEYS import; now imported once from ../api/utils/dangerousKeys.js.
Channel Blocking Feature
src/modules/triage.js
Added isChannelBlocked import and implemented channel blocking logic in accumulateMessage that skips processing for blocked channels based on computed parentId context.
Test Coverage
tests/modules/triage-budget.test.js, tests/modules/triage.test.js
Added mock isChannelBlocked function (defaulting to false) and new test cases covering early-return blocking behavior, parentId handling for threads, and non-thread channel scenarios.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: adding a blocked channel check to the triage module as part of completing issue #180.
Description check ✅ Passed The description is directly related to the changeset, explaining what was implemented in triage.js and the context of the broader feature completion.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/issue-180-ai-blocklist

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.

Copy link
Contributor

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

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 isChannelBlocked inside triage.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.

@greptile-apps
Copy link

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR completes the AI channel blocklist feature by adding blocked channel checks to the triage module. The implementation correctly handles the distinction between threads and regular channels when checking parentId, and includes a safety check in evaluateNow to prevent processing buffered messages if a channel is blocked after buffering.

  • Added isChannelBlocked check in accumulateMessage to skip blocked channels early
  • Added blocked channel check in evaluateNow to handle race conditions where channels become blocked after message buffering
  • Properly distinguishes between threads (where parentId is the parent channel) and regular channels in categories (where parentId is the category ID)
  • Comprehensive test coverage including edge cases for thread vs category channel handling
  • Minor unrelated formatting changes (linting fixes) in rolemenu, config, and roleMenuTemplates files

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The implementation is well-tested with comprehensive edge case coverage, properly handles the thread/category distinction that was flagged in the previous review, includes defensive error handling in evaluateNow, and follows existing patterns from events.js. The formatting changes are benign linting fixes.
  • No files require special attention

Important Files Changed

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

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d04016 and 1b28c80.

📒 Files selected for processing (6)
  • src/commands/rolemenu.js
  • src/modules/config.js
  • src/modules/roleMenuTemplates.js
  • src/modules/triage.js
  • tests/modules/triage-budget.test.js
  • tests/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 — use import/export, never require()
Always use node: 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.js
  • src/modules/roleMenuTemplates.js
  • tests/modules/triage-budget.test.js
  • src/modules/config.js
  • src/modules/triage.js
  • src/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 test before every commit

Files:

  • tests/modules/triage.test.js
  • tests/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 use console.log, console.warn, console.error, or any console.* 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.js
  • src/modules/config.js
  • src/modules/triage.js
  • src/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 use onConfigChange listeners for reactive updates

Files:

  • src/modules/roleMenuTemplates.js
  • src/modules/config.js
  • src/modules/triage.js
src/commands/*.js

📄 CodeRabbit inference engine (AGENTS.md)

src/commands/*.js: Slash commands must export data (SlashCommandBuilder) and execute(interaction) function. Export adminOnly = true for 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_KEYS source improves consistency.

src/modules/triage.js (1)

28-28: Import wiring is correct.

isChannelBlocked is correctly integrated into the triage module surface.

tests/modules/triage-budget.test.js (1)

76-76: Mock update is appropriate for test isolation.

Defaulting isChannelBlocked to false preserves existing budget test intent.

tests/modules/triage.test.js (2)

72-72: AI mock surface update is correct.

Including isChannelBlocked keeps 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.

Copilot AI review requested due to automatic review settings March 2, 2026 14:33
Copy link
Contributor

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

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.

@BillChirico BillChirico merged commit e2e9451 into main Mar 2, 2026
12 of 17 checks passed
@BillChirico BillChirico deleted the feat/issue-180-ai-blocklist branch March 2, 2026 14:51
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