Skip to content

feat(dashboard): show "Ready for review" CTA on draft PRs#180

Merged
stylessh merged 2 commits intomainfrom
stylessh/draft-pr-merge
Apr 25, 2026
Merged

feat(dashboard): show "Ready for review" CTA on draft PRs#180
stylessh merged 2 commits intomainfrom
stylessh/draft-pr-merge

Conversation

@stylessh
Copy link
Copy Markdown
Owner

@stylessh stylessh commented Apr 25, 2026

Summary

Draft pull requests cannot be merged on GitHub, so the existing merge footer is misleading on a draft PR. This swaps the merge action footer for a "Ready for review" CTA when the PR is a draft, while keeping the reviews / checks / conflicts / branch-status rows in place.

Changes

  • Add markPullReadyForReview server function that calls GitHub's markPullRequestReadyForReview GraphQL mutation and busts the PR detail caches.
  • Plumb isDraft and the PR's graphqlId into MergeStatusSection / MergeStatusCard, and conditionally render a new ReadyForReviewFooter instead of MergeFooter when the PR is a draft.
  • The new footer follows the action CTA loading pattern (icon swaps to spinner, label stays static, button disables) and invalidates ["github"] queries on success so the merge controls appear automatically once the PR flips to ready.

Test Plan

  • Open a draft PR detail page — confirm reviews/checks/conflicts rows render and the footer shows the "Ready for review" CTA instead of the merge button.
  • Click "Ready for review" — confirm the spinner shows, the PR flips out of draft, and the merge footer appears without a hard refresh.
  • Open a non-draft PR — confirm the merge footer still renders unchanged.

Summary by CodeRabbit

  • New Features
    • Added "Ready for review" action for draft pull requests in the merge status area — users can mark drafts ready for review directly from the UI. Includes loading state, user-facing error toasts, and permission warnings. Successful marking refreshes pull request details so the updated status appears immediately.

… on draft PRs

Draft PRs can't be merged on GitHub, so swap the merge footer for a
"Ready for review" action that calls the markPullRequestReadyForReview
GraphQL mutation. Reviews/checks/conflicts rows still render.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 25, 2026

📝 Walkthrough

Walkthrough

Adds a "Ready for review" CTA for draft PRs: UI threads pr.isDraft and pr.graphqlId to render a ReadyForReviewFooter that calls a new server mutation to mark the PR ready, invalidates GitHub React Query cache on success, and surfaces errors/toasts.

Changes

Cohort / File(s) Summary
Draft PR Ready-for-Review UI
apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx
Merge-status UI now branches on pr.isDraft and pr.graphqlId. When draft, renders a new ReadyForReviewFooter that manages isMarking state, calls the server mutation, shows toasts, and disables action on missing pullId.
Draft PR Ready-for-Review Server Mutation
apps/dashboard/src/lib/github.functions.ts
Adds ReadyForReviewInput type and markPullReadyForReview POST handler with input validation. Resolves repository-scoped GitHub auth, calls GitHub GraphQL markPullRequestReadyForReview using pullId, invalidates pull-detail caches on success, and maps errors to MutationResult.

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as UI Component
    participant Server as Server Mutation
    participant GitHub as GitHub GraphQL API
    participant Cache as React Query Cache

    User->>UI: Click "Ready for review"
    UI->>UI: Set loading state
    UI->>Server: POST markPullReadyForReview(owner,repo,pullNumber,pullId)
    Server->>Server: Validate input & check repo-scoped auth
    Server->>GitHub: GraphQL markPullRequestReadyForReview(pullId)
    GitHub->>Server: Return result
    Server->>Cache: Invalidate ["github"] cache key
    Server->>UI: Return MutationResult { ok: true } / error
    UI->>User: Show success toast or error/permission warning
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested Labels

tembo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely captures the main change: showing a 'Ready for review' CTA on draft PRs instead of the misleading merge footer.
Description check ✅ Passed The description follows the template structure with Summary, Changes, and Test Plan sections fully completed with specific implementation details and test scenarios.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stylessh/draft-pr-merge

Comment @coderabbitai help to get the list of available commands and usage tips.

# Conflicts:
#	apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx
Copy link
Copy Markdown
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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx`:
- Around line 1328-1349: The loading flag is never cleared on success in
handleMarkReady, causing the CTA to remain disabled; update handleMarkReady to
reset the loading state (call setIsMarking(false)) after a successful
markPullReadyForReview and queryClient.invalidateQueries (or move the
setIsMarking(false) into a finally block) so the spinner/button is re-enabled
even if the refetch doesn't immediately update the view.

In `@apps/dashboard/src/lib/github.functions.ts`:
- Line 6304: The bustPullDetailCaches call currently misses invalidating the
cached pull page-data resource that contains detail.isDraft; update
bustPullDetailCaches (or add an explicit call right after await
bustPullDetailCaches(context.session.user.id, data)) to also clear the
pulls.pageData.graphql.v2 cache entry for the affected pull (use the same
identifier available in data — e.g., data.id or data.pullNumber and
context.session.user.id). Specifically, ensure the function invokes the cache
invalidation API used elsewhere (e.g.,
invalidateResource/cacheClient.invalidate/removeResource) for the resource key
"pulls.pageData.graphql.v2" scoped to that pull so the draft state is not served
stale.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e92236b5-867c-4fee-85d2-93974a415874

📥 Commits

Reviewing files that changed from the base of the PR and between 4bfe010 and 8f5ec98.

📒 Files selected for processing (2)
  • apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx
  • apps/dashboard/src/lib/github.functions.ts

Comment on lines +1328 to +1349
const handleMarkReady = async () => {
if (!pullId) {
toast.error("Missing pull request id");
return;
}
setIsMarking(true);
try {
const result = await markPullReadyForReview({
data: { owner, repo, pullNumber, pullId },
});
if (result.ok) {
await queryClient.invalidateQueries({ queryKey: ["github"] });
} else {
toast.error(result.error);
checkPermissionWarning(result, `${owner}/${repo}`);
setIsMarking(false);
}
} catch {
toast.error("Failed to mark as ready for review");
setIsMarking(false);
}
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Reset loading state on success to prevent a permanently disabled CTA.

isMarking is never cleared on the success path. If the refetch/invalidation does not transition the view immediately, the button can stay disabled with a stuck spinner.

💡 Suggested fix
 const handleMarkReady = async () => {
   if (!pullId) {
     toast.error("Missing pull request id");
     return;
   }
   setIsMarking(true);
   try {
     const result = await markPullReadyForReview({
       data: { owner, repo, pullNumber, pullId },
     });
     if (result.ok) {
       await queryClient.invalidateQueries({ queryKey: ["github"] });
     } else {
       toast.error(result.error);
       checkPermissionWarning(result, `${owner}/${repo}`);
-      setIsMarking(false);
+      return;
     }
   } catch {
     toast.error("Failed to mark as ready for review");
-    setIsMarking(false);
+  } finally {
+    setIsMarking(false);
   }
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleMarkReady = async () => {
if (!pullId) {
toast.error("Missing pull request id");
return;
}
setIsMarking(true);
try {
const result = await markPullReadyForReview({
data: { owner, repo, pullNumber, pullId },
});
if (result.ok) {
await queryClient.invalidateQueries({ queryKey: ["github"] });
} else {
toast.error(result.error);
checkPermissionWarning(result, `${owner}/${repo}`);
setIsMarking(false);
}
} catch {
toast.error("Failed to mark as ready for review");
setIsMarking(false);
}
};
const handleMarkReady = async () => {
if (!pullId) {
toast.error("Missing pull request id");
return;
}
setIsMarking(true);
try {
const result = await markPullReadyForReview({
data: { owner, repo, pullNumber, pullId },
});
if (result.ok) {
await queryClient.invalidateQueries({ queryKey: ["github"] });
} else {
toast.error(result.error);
checkPermissionWarning(result, `${owner}/${repo}`);
return;
}
} catch {
toast.error("Failed to mark as ready for review");
} finally {
setIsMarking(false);
}
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx` around
lines 1328 - 1349, The loading flag is never cleared on success in
handleMarkReady, causing the CTA to remain disabled; update handleMarkReady to
reset the loading state (call setIsMarking(false)) after a successful
markPullReadyForReview and queryClient.invalidateQueries (or move the
setIsMarking(false) into a finally block) so the spinner/button is re-enabled
even if the refetch doesn't immediately update the view.

}`,
{ pullRequestId: data.pullId },
);
await bustPullDetailCaches(context.session.user.id, data);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Bust pulls.pageData.graphql.v2 cache after marking ready-for-review.

At Line 6304, bustPullDetailCaches does not clear the cached pull page-data resource that contains detail.isDraft. This can leave stale draft state after the mutation and keep showing the draft CTA until cache expiry.

💡 Proposed fix
async function bustPullDetailCaches(userId: string, params: PullCacheParams) {
  await Promise.all([
+   bustGitHubCache(userId, "pulls.pageData.graphql.v2", params),
    bustGitHubCache(userId, "pulls.detail.raw", params),
    bustGitHubCache(userId, "pulls.status.raw", params),
    bustGitHubCache(userId, "pulls.status.v1", params),
    bustGitHubCache(userId, "pulls.status.v2", params),
    bustGitHubCache(userId, "pulls.status.v3", params),
  ]);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/dashboard/src/lib/github.functions.ts` at line 6304, The
bustPullDetailCaches call currently misses invalidating the cached pull
page-data resource that contains detail.isDraft; update bustPullDetailCaches (or
add an explicit call right after await
bustPullDetailCaches(context.session.user.id, data)) to also clear the
pulls.pageData.graphql.v2 cache entry for the affected pull (use the same
identifier available in data — e.g., data.id or data.pullNumber and
context.session.user.id). Specifically, ensure the function invokes the cache
invalidation API used elsewhere (e.g.,
invalidateResource/cacheClient.invalidate/removeResource) for the resource key
"pulls.pageData.graphql.v2" scoped to that pull so the draft state is not served
stale.

Copy link
Copy Markdown
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.

♻️ Duplicate comments (1)
apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx (1)

1371-1392: ⚠️ Potential issue | 🟠 Major

Reset isMarking on success to avoid a stuck disabled CTA.

On Line 1381, the success branch never clears isMarking. If cache invalidation doesn’t immediately transition the view, the button can remain disabled with a spinner. Prefer resetting in finally.

💡 Suggested fix
 const handleMarkReady = async () => {
 	if (!pullId) {
 		toast.error("Missing pull request id");
 		return;
 	}
 	setIsMarking(true);
 	try {
 		const result = await markPullReadyForReview({
 			data: { owner, repo, pullNumber, pullId },
 		});
 		if (result.ok) {
 			await queryClient.invalidateQueries({ queryKey: ["github"] });
 		} else {
 			toast.error(result.error);
 			checkPermissionWarning(result, `${owner}/${repo}`);
-			setIsMarking(false);
 		}
 	} catch {
 		toast.error("Failed to mark as ready for review");
-		setIsMarking(false);
+	} finally {
+		setIsMarking(false);
 	}
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx` around
lines 1371 - 1392, The handler handleMarkReady leaves the isMarking flag true on
the success path so the CTA can stay disabled; update handleMarkReady to always
reset loading by moving setIsMarking(false) into a finally block (or call it
after await queryClient.invalidateQueries) so setIsMarking(false) runs on
success, error, and exceptions; reference the handleMarkReady function and the
setIsMarking variable, and ensure any early returns (e.g., missing pullId) still
behave correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx`:
- Around line 1371-1392: The handler handleMarkReady leaves the isMarking flag
true on the success path so the CTA can stay disabled; update handleMarkReady to
always reset loading by moving setIsMarking(false) into a finally block (or call
it after await queryClient.invalidateQueries) so setIsMarking(false) runs on
success, error, and exceptions; reference the handleMarkReady function and the
setIsMarking variable, and ensure any early returns (e.g., missing pullId) still
behave correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 70917a12-8cf7-4eda-b38f-47bd3a9ea067

📥 Commits

Reviewing files that changed from the base of the PR and between 8f5ec98 and 2f506ce.

📒 Files selected for processing (2)
  • apps/dashboard/src/components/pulls/detail/pull-detail-activity.tsx
  • apps/dashboard/src/lib/github.functions.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/src/lib/github.functions.ts

@stylessh stylessh merged commit 19abfaa into main Apr 25, 2026
5 checks passed
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.

1 participant