feat(desktop): open create PR link after publishing branch#865
Conversation
Automatically opens the GitHub PR creation page when a user publishes a branch for the first time, streamlining the PR workflow.
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
| const handlePush = () => { | ||
| const isPublishing = !hasUpstream; | ||
| pushMutation.mutate( | ||
| { worktreePath, setUpstream: true }, | ||
| { | ||
| onSuccess: () => { | ||
| if (isPublishing) { | ||
| createPRMutation.mutate({ worktreePath }); | ||
| } | ||
| }, | ||
| }, | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Double onRefresh and unintended PR creation in "Commit & Push" flow.
Two concerns with this implementation:
-
Double
onRefreshcall when publishing: The mutation-levelonSuccess(line 62) already callsonRefresh(), thencreatePRMutation.onSuccess(line 86) calls it again. This causes redundant refetches. -
Side effect on
handleCommitAndPush: SincehandleCommitAndPush(line 127) delegates tohandlePush, 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 }) },
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
Test plan
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.