Skip to content

fix: stay on question page when sending back to drafts#4424

Open
SylvainChevalier wants to merge 1 commit intomainfrom
claude/issue-2176-sending-a-question-back-to
Open

fix: stay on question page when sending back to drafts#4424
SylvainChevalier wants to merge 1 commit intomainfrom
claude/issue-2176-sending-a-question-back-to

Conversation

@SylvainChevalier
Copy link
Contributor

@SylvainChevalier SylvainChevalier commented Feb 25, 2026

Instead of redirecting to the review queue (/questions/?status=pending), the page now stays on the current question after sending it back to drafts.

Closes #2176

Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Simplified the post drafting process by streamlining action handling, making the draft-post flow more efficient and consistent.

Instead of redirecting to the review queue (/questions/?status=pending),
the page now stays on the current question after sending it back to
drafts. This matches the expected behavior discussed in the issue.

Closes #2176

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

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

Modified the draftPost function to accept only a post ID parameter, removing the defaultProject argument. Updated the calling component to invoke this simplified function and refresh the router instead of handling conditional redirects based on project type.

Changes

Cohort / File(s) Summary
UI Component
front_end/src/app/(main)/questions/[id]/components/post_status_box.tsx
Updated draftPost function call to pass only postId, removed defaultProject parameter, and added router refresh after the operation.
Server Action
front_end/src/app/(main)/questions/actions.ts
Simplified draftPost function signature to accept only postId parameter; removed Tournament and TournamentType imports; eliminated conditional redirect logic based on project type in favor of simple path revalidation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • hlbmtc

Poem

🐰 A rabbit hops through drafts with glee,
No more redirects from post to sea,
Simpler paths, a lighter load,
Stay the course on question road! ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: staying on the question page instead of redirecting to the review queue when sending back to drafts.
Linked Issues check ✅ Passed The code changes directly address issue #2176 by removing the redirect logic and keeping users on the question page after sending it back to drafts.
Out of Scope Changes check ✅ Passed All changes are scoped to the draftPost function and its caller, directly addressing the redirect behavior specified in issue #2176 with no extraneous modifications.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/issue-2176-sending-a-question-back-to

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
Contributor

github-actions bot commented Feb 25, 2026

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4424-claude-issue-2176-sending-a-qu-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:claude-issue-2176-sending-a-question-back-to-c7c45de
🗄️ PostgreSQL NeonDB branch preview/pr-4424-claude-issue-2176-sending-a-qu
Redis Fly Redis mtc-redis-pr-4424-claude-issue-2176-sending-a-qu

Details

  • Commit: c7c45de3a7d57da104dddf2eb63b065db606a189
  • Branch: claude/issue-2176-sending-a-question-back-to
  • Fly App: metaculus-pr-4424-claude-issue-2176-sending-a-qu

ℹ️ 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
Contributor Author

lgtm.

@SylvainChevalier SylvainChevalier marked this pull request as ready for review February 25, 2026 17:16
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.

🧹 Nitpick comments (1)
front_end/src/app/(main)/questions/actions.ts (1)

121-124: Trailing slash inconsistency with approvePost.

draftPost calls revalidatePath(\/questions/${postId}`)(no trailing slash), whileapprovePostat Line 64 usesrevalidatePath(`/questions/${postId}/`)` (with trailing slash). Next.js normalizes both, so there is no functional bug, but it's worth aligning them for consistency.

🔧 Optional alignment
 export async function draftPost(postId: number) {
   await ServerPostsApi.makeDraft(postId);
-  revalidatePath(`/questions/${postId}`);
+  revalidatePath(`/questions/${postId}/`);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@front_end/src/app/`(main)/questions/actions.ts around lines 121 - 124, The
revalidation path in draftPost is inconsistent with approvePost: change the call
in draftPost (after ServerPostsApi.makeDraft) to use the same trailing-slash
form as approvePost by calling revalidatePath(`/questions/${postId}/`) so both
functions use the identical path normalization; locate the draftPost function
and update its revalidatePath argument to include the trailing slash to match
approvePost.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@front_end/src/app/`(main)/questions/actions.ts:
- Around line 121-124: The revalidation path in draftPost is inconsistent with
approvePost: change the call in draftPost (after ServerPostsApi.makeDraft) to
use the same trailing-slash form as approvePost by calling
revalidatePath(`/questions/${postId}/`) so both functions use the identical path
normalization; locate the draftPost function and update its revalidatePath
argument to include the trailing slash to match approvePost.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8ac136 and c7c45de.

📒 Files selected for processing (2)
  • front_end/src/app/(main)/questions/[id]/components/post_status_box.tsx
  • front_end/src/app/(main)/questions/actions.ts

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.

Sending a question back to drafts redirects to the review queue

1 participant