Skip to content

feat: Restrict @predictors mentions to curators/admins with warning toast#4599

Draft
SylvainChevalier wants to merge 2 commits into
mainfrom
claude/issue-4082-tagging-predictors-in-comments-should
Draft

feat: Restrict @predictors mentions to curators/admins with warning toast#4599
SylvainChevalier wants to merge 2 commits into
mainfrom
claude/issue-4082-tagging-predictors-in-comments-should

Conversation

@SylvainChevalier
Copy link
Copy Markdown
Contributor

Summary

  • @predictors autocomplete suggestion only shown to curators/admins (already existed)
  • Backend now filters to only active (non-withdrawn) predictions
  • Non-privileged users see a warning toast when using @predictors
  • Edit form now includes mention autocomplete with permission filtering

Fixes #4082


Generated with Claude Code

- Backend: filter @predictors to only active (non-withdrawn) predictions
  by excluding forecasts with end_time in the past
- Frontend: show warning toast when non-admin/curator uses @predictors
  in both comment creation and editing flows
- Frontend: add mention autocomplete with permission filtering to the
  comment edit form (was previously only on new comment form)
- Add translation key for the warning message
- Add test for withdrawn forecast exclusion

Fixes #4082

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a94dfa09-584c-41b8-b110-44ccea3734f5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-4082-tagging-predictors-in-comments-should

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4599-claude-issue-4082-tagging-pred-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:claude-issue-4082-tagging-predictors-in-comments-should-128c693
🗄️ PostgreSQL NeonDB branch preview/pr-4599-claude-issue-4082-tagging-pred
Redis Fly Redis mtc-redis-pr-4599-claude-issue-4082-tagging-pred

Details

  • Commit: 128c6932567a18d3337f224164f749c863dc97e1
  • Branch: claude/issue-4082-tagging-predictors-in-comments-should
  • Fly App: metaculus-pr-4599-claude-issue-4082-tagging-pred

ℹ️ Preview Environment Info

Isolation:

  • PostgreSQL and Redis are fully isolated from production
  • Each PR gets its own database branch and Redis instance
  • Changes pushed to this PR will trigger a new deployment

Limitations:

  • Background workers and cron jobs are not deployed in preview environments
  • If you need to test background jobs, use Heroku staging environments

Cleanup:

  • This preview will be automatically destroyed when the PR is closed

@SylvainChevalier
Copy link
Copy Markdown
Contributor Author

@claude please fix the unit test problems.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 20, 2026

Claude encountered an error —— View job


Fixing Unit Test Problems

  • Read CLAUDE.md for repo-specific instructions
  • Identify test failures
  • Fix test issues
  • Commit and push fixes

@SylvainChevalier
Copy link
Copy Markdown
Contributor Author

@claude please fix the unit test problems.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 15, 2026

Claude finished @SylvainChevalier's task in 5m 20s —— View job


Fixing Unit Test Problems

  • Read Claude.md for repo-specific instructions
  • Check CI status to identify test failures
  • Investigate failing tests
  • Fix test issues
  • Commit and push fixes

Summary

Two CI failures, both fixed in 128c693:

Backendtests/unit/test_comments/test_utils.py
test_predictors_mention_excludes_withdrawn_forecasts failed with a DB IntegrityError on the end_time_after_start_time check constraint. factory_forecast auto-populates start_time to now(), so passing only end_time = now - 1 day produces end_time < start_time. Fixed by also passing start_time = now - 2 days so the withdrawn forecast spans 2 days in the past.

Frontend formattingfront_end/src/components/comment_feed/comment.tsx
Prettier flagged the new ![CURATOR, ADMIN].includes(userPermission) block. The canonical prettier shape (already present in comment_editor.tsx:175) keeps the array literal inline and puts userPermission on its own line. Reformatted to match.

Not done

I could not run the prettier check or the pytest suite locally (sandbox restrictions on shell access), so the fixes rely on CI to validate. The frontend fix mirrors the exact pattern prettier produced in the sibling file, and the backend fix addresses the precise constraint shown in the traceback.
· Branch

- tests/unit/test_comments/test_utils.py: pass start_time alongside
  end_time for the withdrawn forecast so end_time > start_time and
  the end_time_after_start_time DB check constraint is satisfied.
- front_end/src/components/comment_feed/comment.tsx: reformat the
  predictors-warning condition to match prettier's preferred shape
  (matches the equivalent block already in comment_editor.tsx).

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
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.

Tagging @predictors in comments should be restricted to admins and curators

1 participant