Skip to content

Warn at submit if a review may be hidden for toxicity (#1110)#1265

Open
IshanA2007 wants to merge 2 commits into
devfrom
1110-moderation-toxicity-warning
Open

Warn at submit if a review may be hidden for toxicity (#1110)#1265
IshanA2007 wants to merge 2 commits into
devfrom
1110-moderation-toxicity-warning

Conversation

@IshanA2007

Copy link
Copy Markdown
Collaborator

Closes #1110

Problem

There was no pre-submission feedback when a review would be hidden by the toxicity display filter — users had no idea their review wouldn't show up.

Fix

Adds a pre-submit toxicity check mirroring the existing preflight/modal pattern (duplicate-review, zero-hours):

  • New check_toxicity XHR endpoint (reviews/check_toxicity/) returning {"toxic": bool}.
  • Scoring reuses the exact logic of the former evaluate_review_toxicity command + the shared settings.TOXICITY_THRESHOLD (74), so the warning matches what actually gets hidden.
  • A "Review may be hidden / Submit anyway / Continue editing" modal wired into the existing submit handler.
  • Display concern only — "Submit anyway" still saves the review; submission is never blocked (per the issue).

⚠️ Important caveat — the scorer is currently absent

detoxify was removed from the project entirely (commit 32623d53, "remove detoxify ENTIRELY"); toxicity_rating is now populated out-of-band. The new service lazily imports detoxify and fails open (returns not-toxic) when it's unavailable — so with the current dependencies the modal never triggers and submission is never blocked. Re-adding detoxify to dependencies (local model, no API key, but heavyweight) activates the warning automatically. This PR wires the mechanism; enabling it is a deploy decision.

Verification (run in the docker stack)

  • manage.py test tcf_website.tests.test_review28 pass (incl. 7 new).
  • manage.py check clean; ruff + djlint clean.

Follow-ups

  • Re-add detoxify (or another local scorer) to make the warning live.
  • The pre-existing duplicate-warning modal markup is dead (alert()-based) — left untouched; could be cleaned up separately.

🤖 Implemented with Claude Code.

Add a pre-submission toxicity warning matching the existing preflight/modal
pattern (duplicate + zero-hours checks).

- Add score_review_toxicity/review_will_be_hidden_for_toxicity services that
  reuse the original detoxify scoring (round(100 * toxicity)) and the same
  TOXICITY_THRESHOLD display filter. Detoxify is optional and lazily loaded;
  when unavailable, scoring returns not-flagged so submission is never blocked.
- Add check_toxicity preflight endpoint + URL returning {"toxic": bool},
  mirroring check_zero_hours_per_week.
- Add a 'Review may be hidden' modal with 'Submit anyway' / 'Continue editing',
  wired into the review submit handler after the duplicate/zero-hours checks.
  Submission is never blocked -- moderation here is display-only.
- Add endpoint + service unit tests.

Note: the review is still saved on 'Submit anyway'; toxicity only affects
whether it is displayed.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@IshanA2007, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fffa0256-0d33-4e96-acd9-09c5642039cb

📥 Commits

Reviewing files that changed from the base of the PR and between ed955fb and fff7ec9.

📒 Files selected for processing (6)
  • tcf_website/review/services.py
  • tcf_website/templates/site/review/review.html
  • tcf_website/tests/test_review.py
  • tcf_website/urls.py
  • tcf_website/views/review/__init__.py
  • tcf_website/views/review/preflight.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 1110-moderation-toxicity-warning

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.

@IshanA2007 IshanA2007 marked this pull request as ready for review July 8, 2026 18:53
@IshanA2007 IshanA2007 self-assigned this Jul 8, 2026
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.

Moderation: Warning

1 participant