Add Comment Moderation experiment#155
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Adds AI-powered comment moderation with: - Toxicity scoring and sentiment analysis badges in Comments list - Lazy analysis that processes pending comments on page load - Bulk action to queue multiple comments for analysis - AI Reply suggestions modal with tone selection - Comment meta storage for analysis results Includes shared run-ability.ts utility for Abilities API fallback and get_model_preferences() method for model selection.
8316832 to
0a7405d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #155 +/- ##
=============================================
- Coverage 69.17% 67.23% -1.94%
- Complexity 981 1054 +73
=============================================
Files 63 65 +2
Lines 4649 5024 +375
=============================================
+ Hits 3216 3378 +162
- Misses 1433 1646 +213
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive AI-powered comment moderation experiment to WordPress, enabling automated toxicity detection, sentiment analysis, and AI-generated reply suggestions directly within the Comments admin screen.
Key Changes
- Introduces two new WordPress Abilities:
ai/comment-analysisfor toxicity/sentiment scoring andai/reply-suggestionfor generating contextual reply drafts - Implements React-based UI with lazy analysis of pending comments and an interactive reply modal with tone selection
- Adds a shared
run-ability.tsutility that provides Abilities API client support with REST API fallback
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
webpack.config.js |
Adds webpack entry point for comment-moderation experiment bundle |
src/utils/run-ability.ts |
New shared utility for executing abilities with client/REST fallback |
src/experiments/comment-moderation/index.tsx |
React entry point mounting lazy analysis and reply modal controllers |
src/experiments/comment-moderation/components/ReplyModalController.tsx |
Manages reply modal state and WordPress inline reply form integration |
src/experiments/comment-moderation/components/ReplyModal.tsx |
UI for displaying and selecting AI-generated reply suggestions |
src/experiments/comment-moderation/components/LazyAnalysisController.tsx |
Detects and processes pending comment analysis on page load |
includes/Experiments/Comment_Moderation/Comment_Moderation.php |
Main experiment class with column rendering, bulk actions, and asset enqueuing |
includes/Experiment_Loader.php |
Registers Comment_Moderation experiment in loader |
includes/Abstracts/Abstract_Ability.php |
Adds get_model_preferences() helper method to base ability class |
includes/Abilities/Comment_Moderation/Reply_Suggestion.php |
Ability implementation for generating reply suggestions with tone control |
includes/Abilities/Comment_Moderation/Comment_Analysis.php |
Ability implementation for analyzing comment toxicity and sentiment |
includes/Abilities/Comment_Moderation/system-instruction.php |
AI system prompt for comment analysis with JSON output format |
includes/Abilities/Comment_Moderation/reply-system-instruction.php |
AI system prompt for generating contextual comment replies |
docs/experiments/comment-moderation.md |
Documentation covering hooks, data flow, and testing procedures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Added comment moderation feature details to the readme.
|
Note we'll want to update the screenshot numbers when this gets merged in, I left it with a hash instead of a number depending on when this versus other experiments get merged in. |
|
@Jameswlepage can you add tests here like was done in https://github.com/WordPress/ai/pull/147/changes#diff-0cf348eda48cae411ad9d44a2e5b449603a971f2313b0a849893ff4cf8280c46? |
…bility and if it is above our threshold and is negative sentiment, automatically moderate it
|
@jeffpaul This is ready for review now. I've read through all the comments on the PR and I think I've addressed all actionable items. There is some good back and forth with you and Seth that I'd suggest we pull that out into a new issue just so we don't lose track of it, as I think there's some valuable things we can look at as enhancements to this or even entirely new experiments. |
jeffpaul
left a comment
There was a problem hiding this comment.
-
Update the bulk action to
Analyze Sentiment and Toxicity(while I agreeAnalyze with AIis MUCH shorter I'm trying to get away from usingAIin the editor and admin and more describe things as "this is what happens when you click this". -
Is there sufficient hooks in place such that the "comment value" / Relevance concept that @sethrubenstein mentions in #155 (comment) and #155 (comment) could reasonably be extended from this work (and similarly have low value comments based on their algorithm/approach go to moderation)?
… the response schema so that can be modified if someone wants to add additional analysis. Simplify docs. Bring back enable/disable all tests for the admin group
This has been updated now
So yes and no. There's a filter around the system instructions and another around the response schema so in theory, you could use both of those to change the response the LLM gives. There's also then Core filters on the comment list screen that you could use to add a new column for "Value/Relevance". But the manual processing of comments is done via custom javascript which doesn't have hooks in place so you'd have to add some of your own JS to replicate the full experience. That said, I'd love to add a comment value / relevance experiment to this plugin though I think that's fine as a separate PR (also some discussion on if that should be part of comment moderation or a separate experiment). |

What?
Adds comment toxicity and sentiment analysis and uses that to moderate comments.
Why?
There are multiple approaches to moderating comments and using AI to do that is a natural fit. For sites that get lots of comments, having a first-line moderation strategy is key to keep up with them.
How?
Use of AI Tools
Can't speak to the original code in this PR but in the cleanup, used Claude running Opus 4.6 and also Cursor running Codex 5.3 to do code reviews, some cleanup, tests and documentation
Testing Instructions
npm i && npm run buildSettings → AICommentsin the admin and verify badges appearI hate this post). Ensure this comment goes to moderationScreenshots