@@ -1008,6 +1008,8 @@ export default function GitActionsControl({
10081008 const [ inlineSuccess , setInlineSuccess ] = useState < InlineGitActionSuccess | null > ( null ) ;
10091009 const [ pendingDefaultBranchAction , setPendingDefaultBranchAction ] =
10101010 useState < PendingDefaultBranchAction | null > ( null ) ;
1011+ // Keep the payload until the dialog finishes closing.
1012+ const [ isDefaultBranchDialogOpen , setIsDefaultBranchDialogOpen ] = useState ( false ) ;
10111013 const sourceControlScope = { environmentId : activeEnvironmentId , cwd : gitCwd } ;
10121014 const vcsActionState = useAtomValue ( vcsActionManager . stateAtom ( sourceControlScope ) ) ;
10131015 const visibleInlineSuccess = inlineSuccess ?. scopeKey === successScopeKey ? inlineSuccess : null ;
@@ -1250,6 +1252,7 @@ export default function GitActionsControl({
12501252 ...( onConfirmed ? { onConfirmed } : { } ) ,
12511253 ...( filePaths ? { filePaths } : { } ) ,
12521254 } ) ;
1255+ setIsDefaultBranchDialogOpen ( true ) ;
12531256 return ;
12541257 }
12551258 onConfirmed ?.( ) ;
@@ -1359,29 +1362,18 @@ export default function GitActionsControl({
13591362 }
13601363 }
13611364
1362- const continuePendingDefaultBranchAction = ( ) => {
1363- if ( ! pendingDefaultBranchAction ) return ;
1364- const { action, commitMessage, onConfirmed, filePaths } = pendingDefaultBranchAction ;
1365- setPendingDefaultBranchAction ( null ) ;
1366- void runGitActionWithToast ( {
1367- action,
1368- ...( commitMessage ? { commitMessage } : { } ) ,
1369- ...( onConfirmed ? { onConfirmed } : { } ) ,
1370- ...( filePaths ? { filePaths } : { } ) ,
1371- skipDefaultBranchPrompt : true ,
1372- } ) ;
1373- } ;
1374-
1375- const checkoutFeatureBranchAndContinuePendingAction = ( ) => {
1376- if ( ! pendingDefaultBranchAction ) return ;
1365+ const continuePendingDefaultBranchAction = ( featureBranch : boolean ) => {
1366+ if ( ! isDefaultBranchDialogOpen || ! pendingDefaultBranchAction || ! canWriteSourceControl ) return ;
1367+ if ( featureBranch && ( ! canChangeThreadBranch || featureBranchUnavailableReason !== null ) )
1368+ return ;
13771369 const { action, commitMessage, onConfirmed, filePaths } = pendingDefaultBranchAction ;
1378- setPendingDefaultBranchAction ( null ) ;
1370+ setIsDefaultBranchDialogOpen ( false ) ;
13791371 void runGitActionWithToast ( {
13801372 action,
13811373 ...( commitMessage ? { commitMessage } : { } ) ,
13821374 ...( onConfirmed ? { onConfirmed } : { } ) ,
13831375 ...( filePaths ? { filePaths } : { } ) ,
1384- featureBranch : true ,
1376+ featureBranch,
13851377 skipDefaultBranchPrompt : true ,
13861378 } ) ;
13871379 } ;
@@ -2041,11 +2033,10 @@ export default function GitActionsControl({
20412033 />
20422034
20432035 < Dialog
2044- open = { pendingDefaultBranchAction !== null }
2045- onOpenChange = { ( open ) => {
2046- if ( ! open ) {
2047- setPendingDefaultBranchAction ( null ) ;
2048- }
2036+ open = { isDefaultBranchDialogOpen }
2037+ onOpenChange = { setIsDefaultBranchDialogOpen }
2038+ onOpenChangeComplete = { ( open ) => {
2039+ if ( ! open ) setPendingDefaultBranchAction ( null ) ;
20492040 } }
20502041 >
20512042 < DialogPopup className = "max-w-xl" >
@@ -2063,23 +2054,23 @@ export default function GitActionsControl({
20632054 className = "w-full sm:mr-auto sm:w-auto"
20642055 variant = "outline"
20652056 size = "sm"
2066- onClick = { ( ) => setPendingDefaultBranchAction ( null ) }
2057+ onClick = { ( ) => setIsDefaultBranchDialogOpen ( false ) }
20672058 >
20682059 Abort
20692060 </ Button >
20702061 < Button
20712062 className = "w-full max-w-full sm:w-auto"
20722063 variant = "outline"
20732064 size = "sm-multiline"
2074- onClick = { continuePendingDefaultBranchAction }
2065+ onClick = { ( ) => continuePendingDefaultBranchAction ( false ) }
20752066 disabled = { ! canWriteSourceControl }
20762067 >
20772068 { pendingDefaultBranchActionCopy ?. continueLabel ?? "Continue" }
20782069 </ Button >
20792070 < Button
20802071 className = "w-full max-w-full sm:w-auto"
20812072 size = "sm-multiline"
2082- onClick = { checkoutFeatureBranchAndContinuePendingAction }
2073+ onClick = { ( ) => continuePendingDefaultBranchAction ( true ) }
20832074 disabled = { ! canChangeThreadBranch || featureBranchUnavailableReason !== null }
20842075 >
20852076 Check out feature branch & continue
0 commit comments