Skip to content

Commit 0ae1a79

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 84abd10 commit 0ae1a79

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
@@ -1119,6 +1119,8 @@ export default function GitActionsControl({
11191119
const [inlineSuccess, setInlineSuccess] = useState<InlineGitActionSuccess | null>(null);
11201120
const [pendingDefaultBranchAction, setPendingDefaultBranchAction] =
11211121
useState<PendingDefaultBranchAction | null>(null);
1122+
// Separate from the payload so the dialog copy survives its exit transition.
1123+
const [isDefaultBranchDialogOpen, setIsDefaultBranchDialogOpen] = useState(false);
11221124
const sourceControlScope = useMemo(
11231125
() => ({ environmentId: activeEnvironmentId, cwd: gitCwd }),
11241126
[activeEnvironmentId, gitCwd],
@@ -1368,6 +1370,7 @@ export default function GitActionsControl({
13681370
...(onConfirmed ? { onConfirmed } : {}),
13691371
...(filePaths ? { filePaths } : {}),
13701372
});
1373+
setIsDefaultBranchDialogOpen(true);
13711374
return;
13721375
}
13731376
onConfirmed?.();
@@ -1481,10 +1484,10 @@ export default function GitActionsControl({
14811484
);
14821485

14831486
const continuePendingDefaultBranchAction = (featureBranch: boolean) => {
1484-
if (!pendingDefaultBranchAction) return;
1487+
if (!isDefaultBranchDialogOpen || !pendingDefaultBranchAction) return;
14851488
if (featureBranch && !canChangeThreadBranch) return;
14861489
const { action, commitMessage, onConfirmed, filePaths } = pendingDefaultBranchAction;
1487-
setPendingDefaultBranchAction(null);
1490+
setIsDefaultBranchDialogOpen(false);
14881491
void runGitActionWithToast({
14891492
action,
14901493
...(commitMessage ? { commitMessage } : {}),
@@ -2153,11 +2156,10 @@ export default function GitActionsControl({
21532156
/>
21542157

21552158
<Dialog
2156-
open={pendingDefaultBranchAction !== null}
2157-
onOpenChange={(open) => {
2158-
if (!open) {
2159-
setPendingDefaultBranchAction(null);
2160-
}
2159+
open={isDefaultBranchDialogOpen}
2160+
onOpenChange={setIsDefaultBranchDialogOpen}
2161+
onOpenChangeComplete={(open) => {
2162+
if (!open) setPendingDefaultBranchAction(null);
21612163
}}
21622164
>
21632165
<DialogPopup className="max-w-xl">
@@ -2172,7 +2174,7 @@ export default function GitActionsControl({
21722174
className="w-full sm:mr-auto sm:w-auto"
21732175
variant="outline"
21742176
size="sm"
2175-
onClick={() => setPendingDefaultBranchAction(null)}
2177+
onClick={() => setIsDefaultBranchDialogOpen(false)}
21762178
>
21772179
Abort
21782180
</Button>

0 commit comments

Comments
 (0)