Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,19 @@ export function CommitInput({
commitMutation.mutate({ worktreePath, message: commitMessage.trim() });
};

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

const handlePull = () => pullMutation.mutate({ worktreePath });
const handleSync = () => syncMutation.mutate({ worktreePath });
const handleCreatePR = () => createPRMutation.mutate({ worktreePath });
Expand Down
Loading