Skip to content

Commit c155060

Browse files
committed
Fix default branch confirmation dialog for push and create_pr menu actions
The menu's push and create_pr actions bypassed the default branch confirmation dialog because requiresDefaultBranchConfirmation only checked for commit_push and commit_push_pr. Extend the check to also cover the split push and create_pr actions, and update the action guard and dialog copy resolver to handle them.
1 parent 5dc3c21 commit c155060

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

apps/web/src/components/GitActionsControl.logic.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,12 @@ describe("when: branch has no upstream configured", () => {
802802
describe("requiresDefaultBranchConfirmation", () => {
803803
it("requires confirmation for push actions on default branch", () => {
804804
assert.isFalse(requiresDefaultBranchConfirmation("commit", true));
805+
assert.isTrue(requiresDefaultBranchConfirmation("push", true));
806+
assert.isTrue(requiresDefaultBranchConfirmation("create_pr", true));
805807
assert.isTrue(requiresDefaultBranchConfirmation("commit_push", true));
806808
assert.isTrue(requiresDefaultBranchConfirmation("commit_push_pr", true));
807809
assert.isFalse(requiresDefaultBranchConfirmation("commit_push", false));
810+
assert.isFalse(requiresDefaultBranchConfirmation("push", false));
808811
});
809812
});
810813

apps/web/src/components/GitActionsControl.logic.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export interface DefaultBranchActionDialogCopy {
3131
continueLabel: string;
3232
}
3333

34-
export type DefaultBranchConfirmableAction = "commit_push" | "commit_push_pr";
34+
export type DefaultBranchConfirmableAction =
35+
| "push"
36+
| "create_pr"
37+
| "commit_push"
38+
| "commit_push_pr";
3539

3640
export function buildGitActionProgressStages(input: {
3741
action: GitStackedAction;
@@ -272,7 +276,12 @@ export function requiresDefaultBranchConfirmation(
272276
isDefaultBranch: boolean,
273277
): boolean {
274278
if (!isDefaultBranch) return false;
275-
return action === "commit_push" || action === "commit_push_pr";
279+
return (
280+
action === "push" ||
281+
action === "create_pr" ||
282+
action === "commit_push" ||
283+
action === "commit_push_pr"
284+
);
276285
}
277286

278287
export function resolveDefaultBranchActionDialogCopy(input: {
@@ -283,7 +292,7 @@ export function resolveDefaultBranchActionDialogCopy(input: {
283292
const branchLabel = input.branchName;
284293
const suffix = ` on "${branchLabel}". You can continue on this branch or create a feature branch and run the same action there.`;
285294

286-
if (input.action === "commit_push") {
295+
if (input.action === "push" || input.action === "commit_push") {
287296
if (input.includesCommit) {
288297
return {
289298
title: "Commit & push to default branch?",

apps/web/src/components/GitActionsControl.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,12 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
425425
requiresDefaultBranchConfirmation(action, actionIsDefaultBranch) &&
426426
actionBranch
427427
) {
428-
if (action !== "commit_push" && action !== "commit_push_pr") {
428+
if (
429+
action !== "push" &&
430+
action !== "create_pr" &&
431+
action !== "commit_push" &&
432+
action !== "commit_push_pr"
433+
) {
429434
return;
430435
}
431436
setPendingDefaultBranchAction({

0 commit comments

Comments
 (0)