Skip to content

feat(desktop): open create PR link after publishing branch#865

Merged
Kitenite merged 1 commit into
mainfrom
after-publishing-branch-open-the-create-pr-link
Jan 21, 2026
Merged

feat(desktop): open create PR link after publishing branch#865
Kitenite merged 1 commit into
mainfrom
after-publishing-branch-open-the-create-pr-link

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Jan 21, 2026

Summary

  • Automatically opens the GitHub PR creation page when a user clicks "Publish Branch"
  • Streamlines the workflow by eliminating the need to manually click "Create Pull Request" after publishing

Test plan

  • Create a new branch locally without an upstream
  • Click "Publish Branch" in the Changes sidebar
  • Verify the branch is pushed and GitHub's PR creation page opens automatically
  • Verify regular "Push" operations (with existing upstream) do not open the PR page

Summary by CodeRabbit

  • New Features

    • Pushing a branch now automatically initiates pull request creation for newly published branches.
  • Improvements

    • Streamlined push workflow to reduce manual steps.

✏️ Tip: You can customize this high-level summary in your review settings.

Automatically opens the GitHub PR creation page when a user publishes
a branch for the first time, streamlining the PR workflow.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

The handlePush function in CommitInput was refactored to implement a two-phase flow. It now checks for upstream presence, calls pushMutation with setUpstream: true, and automatically triggers createPRMutation upon successful push if the branch was initially unpublished.

Changes

Cohort / File(s) Summary
Push flow refactoring
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitInput/CommitInput.tsx
Modified handlePush to implement two-phase flow: determines isPublishing state (no upstream), calls pushMutation with setUpstream: true, and conditionally triggers createPRMutation on success. Other command handlers unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • create commit in change tab #409: Adds push/pull/sync/createPR git operations and mutation wiring that are now orchestrated by the refactored CommitInput push flow.

Poem

🐰 A rabbit hops through push and flow,
Two phases dance, both high and low,
Upstream checked with care so true,
Then PR springs forth, all fresh and new!
Automation's magic, swift and bright!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature addition: automatically opening the GitHub PR creation page after publishing a branch.
Description check ✅ Passed The description provides a summary of changes and a detailed test plan, but omits several required template sections like Related Issues, Type of Change, Screenshots, and Additional Notes.

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

✨ Finishing touches
  • 📝 Generate docstrings

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

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: 1

Comment on lines +105 to +117
const handlePush = () => {
const isPublishing = !hasUpstream;
pushMutation.mutate(
{ worktreePath, setUpstream: true },
{
onSuccess: () => {
if (isPublishing) {
createPRMutation.mutate({ worktreePath });
}
},
},
);
};
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 | 🟡 Minor

Double onRefresh and unintended PR creation in "Commit & Push" flow.

Two concerns with this implementation:

  1. Double onRefresh call when publishing: The mutation-level onSuccess (line 62) already calls onRefresh(), then createPRMutation.onSuccess (line 86) calls it again. This causes redundant refetches.

  2. Side effect on handleCommitAndPush: Since handleCommitAndPush (line 127) delegates to handlePush, the "Commit & Push" dropdown action will now also open the PR creation page for branches without an upstream. This may conflict with user expectations, as the dropdown explicitly offers a separate "Commit, Push & Create PR" option for that workflow.

Consider either:

  • Extracting the PR-opening logic to only run when triggered from "Publish Branch" / explicit PR flows
  • Or accepting this as intentional UX (all pushes of new branches open PR creation)
Suggested refactor to isolate PR creation behavior
-	const handlePush = () => {
-		const isPublishing = !hasUpstream;
-		pushMutation.mutate(
-			{ worktreePath, setUpstream: true },
-			{
-				onSuccess: () => {
-					if (isPublishing) {
-						createPRMutation.mutate({ worktreePath });
-					}
-				},
-			},
-		);
-	};
+	const handlePush = ({ openPRAfterPublish = false }: { openPRAfterPublish?: boolean } = {}) => {
+		const isPublishing = !hasUpstream;
+		pushMutation.mutate(
+			{ worktreePath, setUpstream: true },
+			{
+				onSuccess: () => {
+					if (isPublishing && openPRAfterPublish) {
+						createPRMutation.mutate({ worktreePath });
+					}
+				},
+			},
+		);
+	};

Then update the "Publish Branch" action in getPrimaryAction (line 201):

-				handler: handlePush,
+				handler: () => handlePush({ openPRAfterPublish: true }),

And update handleCommitAndPush to explicitly not open PR:

-			{ onSuccess: handlePush },
+			{ onSuccess: () => handlePush({ openPRAfterPublish: false }) },

@Kitenite Kitenite merged commit ed99f48 into main Jan 21, 2026
5 checks passed
@Kitenite Kitenite deleted the after-publishing-branch-open-the-create-pr-link branch January 21, 2026 05:12
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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