Add sorting and filtering plus additional labelling to Comment Moderation#518
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #518 +/- ##
=============================================
+ Coverage 70.07% 70.75% +0.67%
- Complexity 1107 1144 +37
=============================================
Files 67 67
Lines 5367 5508 +141
=============================================
+ Hits 3761 3897 +136
- Misses 1606 1611 +5
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:
|
- validate for positive sentiment - validate for medium toxicity
- validate appearance on dashboard - validate visibility opt-out filter
…nd 'low' will always evaluate to true
|
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. |
dkotter
left a comment
There was a problem hiding this comment.
This looks really good, nice work here. Left a few comments but also seeing a couple issues when testing.
If I have a comment without a sentiment or toxicity score and I filter by Positive sentiment or Low toxicity, that comment shows. Seems like this should be excluded?
If I end up combining filters to where no results are found, I end up on a screen where all the filters disappear:
dkotter
left a comment
There was a problem hiding this comment.
We have good unit tests here but would be great to update our E2E tests to have them verify the filters and sorts work
|
Thankyou for the PR review, testing! @dkotter
I am unable to reproduce this issue. Can you check if the comment has metadata present in the database?
I did notice this. I've implemented the filters via |
Ah, yep, seems that was it. Which does bring up a question on why those values weren't showing in the columns but not related to the filtering.
Hmm.. I guess if this is core behavior (to have all filters hide if nothing matches) then I'm fine with sticking with it. Seems odd that's the approach though. |
- Added neutral comment verification and filtering to sort/filter test - Removed bulk analysis step to rely on automatic background analysis
|
@dkotter I have implemented the feedback changes and added e2e test for filtering and sorting of comments. PR is ready for re-review 😄
I have noticed it occurs when a comment fails to be analyzed and then it ends up still containing the metadata (as an empty string value) instead of having no metadata. |
What?
Closes #509
Why?
Presently there is no UX to sort and filter in Comments screen for the new Comment Moderation Experiment 's Sentiment and Toxicity Analysis. This acts as a UX enhancement.
By displaying the pills in the Admin dashboard as well for the Activity widget's Recent Comments section, we maintain consistency in our User Experience.
How?
Sorting and Filtering Logic:
wpai_sentimentandwpai_toxicityto the sortable columns via themanage_edit-comments_sortable_columnsfilter.restrict_manage_commentsto inject custom dropdowns for Sentiment and Toxicity filtering.pre_get_commentslogic (viahandle_sorting_and_filtering) to intercept list table queries and adds relevant meta query for filtering.Dashboard Integration & Scoping of Pills:
get_comment_excerptto inject AI sentiment and toxicity "pills" into the Dashboard's Activity widget.get_current_screen()to scope UI injection to the dashboard only.wpai_comment_moderation_show_dashboard_pillsfilter, allowing third-party developers to opt-out of dashboard pill rendering if needed.add_inline_styleshooked toadmin_head-edit-comments.phpandadmin_head-index.phpfor conditional rendering to ensures that the styling is only rendered on the exact required screens.Automated Testing:
Comment_ModerationTest.phpthat validate themeta_querylogic for sentiment and medium toxicity ranges.Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini 3.1 Pro, Gemini 3 Flash
Used for: Gemini built an initial solution, test cases were written via the same. I have manually reviewed, refactored the code and decided on the approach to be taken.
Testing Instructions
You may also run the added tests to validate the functioning.
Screenshots or screencast
Screenshot showcasing filtering by Sentiment:

Changelog Entry