Skip to content

Commit 6277e7f

Browse files
committed
fix(web): default-branch confirmation keeps its copy while closing
The dialog's open state was derived from the pending action payload, so dismissing it nulled the payload in the same render. The popup stayed mounted for its 200ms exit transition with fallback copy ("Run action on default branch?", no description, "Continue"), visibly shrinking before it faded. Track the open flag separately and clear the payload in onOpenChangeComplete(false), matching RelayClientInstallDialog and ConfirmDialogHost. The continue handler now checks the open flag so a click during the exit transition cannot run the action twice. Fixes #13831
1 parent 363f8ae commit 6277e7f

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

‎apps/web/src/components/GitActionsControl.tsx‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,8 @@ export default function GitActionsControl({
10561056
const [inlineSuccess, setInlineSuccess] = useState<InlineGitActionSuccess | null>(null);
10571057
const [pendingDefaultBranchAction, setPendingDefaultBranchAction] =
10581058
useState<PendingDefaultBranchAction | null>(null);
1059+
// Separate from the payload so the dialog copy survives its exit transition.
1060+
const [isDefaultBranchDialogOpen, setIsDefaultBranchDialogOpen] = useState(false);
10591061
const sourceControlScope = useMemo(
10601062
() => ({ environmentId: activeEnvironmentId, cwd: gitCwd }),
10611063
[activeEnvironmentId, gitCwd],
@@ -1305,6 +1307,7 @@ export default function GitActionsControl({
13051307
...(onConfirmed ? { onConfirmed } : {}),
13061308
...(filePaths ? { filePaths } : {}),
13071309
});
1310+
setIsDefaultBranchDialogOpen(true);
13081311
return;
13091312
}
13101313
onConfirmed?.();
@@ -1418,10 +1421,10 @@ export default function GitActionsControl({
14181421
);
14191422

14201423
const continuePendingDefaultBranchAction = (featureBranch: boolean) => {
1421-
if (!pendingDefaultBranchAction) return;
1424+
if (!isDefaultBranchDialogOpen || !pendingDefaultBranchAction) return;
14221425
if (featureBranch && !canChangeThreadBranch) return;
14231426
const { action, commitMessage, onConfirmed, filePaths } = pendingDefaultBranchAction;
1424-
setPendingDefaultBranchAction(null);
1427+
setIsDefaultBranchDialogOpen(false);
14251428
void runGitActionWithToast({
14261429
action,
14271430
...(commitMessage ? { commitMessage } : {}),
@@ -2092,11 +2095,10 @@ export default function GitActionsControl({
20922095
/>
20932096

20942097
<Dialog
2095-
open={pendingDefaultBranchAction !== null}
2096-
onOpenChange={(open) => {
2097-
if (!open) {
2098-
setPendingDefaultBranchAction(null);
2099-
}
2098+
open={isDefaultBranchDialogOpen}
2099+
onOpenChange={setIsDefaultBranchDialogOpen}
2100+
onOpenChangeComplete={(open) => {
2101+
if (!open) setPendingDefaultBranchAction(null);
21002102
}}
21012103
>
21022104
<DialogPopup className="max-w-xl">
@@ -2111,7 +2113,7 @@ export default function GitActionsControl({
21112113
className="w-full sm:mr-auto sm:w-auto"
21122114
variant="outline"
21132115
size="sm"
2114-
onClick={() => setPendingDefaultBranchAction(null)}
2116+
onClick={() => setIsDefaultBranchDialogOpen(false)}
21152117
>
21162118
Abort
21172119
</Button>

0 commit comments

Comments
 (0)