@@ -9,6 +9,7 @@ import type {
99 CommitNextStep ,
1010 GitMenuAction ,
1111 GitMenuActionId ,
12+ PushMode ,
1213} from "@features/git-interaction/types" ;
1314import {
1415 createBranch ,
@@ -70,7 +71,7 @@ interface GitInteractionActions {
7071 setPrBody : ( value : string ) => void ;
7172 setBranchName : ( value : string ) => void ;
7273 runCommit : ( ) => Promise < void > ;
73- runPush : ( ) => Promise < void > ;
74+ runPush : ( mode ?: PushMode ) => Promise < void > ;
7475 runBranch : ( ) => Promise < void > ;
7576 runCreatePr : ( ) => Promise < void > ;
7677 generateCommitMessage : ( ) => Promise < void > ;
@@ -411,24 +412,29 @@ export function useGitInteraction(
411412 modal . closeCommit ( ) ;
412413
413414 if ( store . commitNextStep === "commit-push" ) {
414- modal . openPush ( git . hasRemote ? "push" : "publish" ) ;
415+ const mode = git . hasRemote ? "push" : "publish" ;
416+ modal . openPush ( mode ) ;
417+ await runPush ( mode ) ;
418+ return ;
415419 }
416420 } finally {
417421 modal . setIsSubmitting ( false ) ;
418422 }
419423 } ;
420424
421- const runPush = async ( ) => {
425+ const runPush = async ( mode ?: PushMode ) => {
422426 if ( ! repoPath ) return ;
423427
428+ const pushMode = mode ?? useGitInteractionStore . getState ( ) . pushMode ;
429+
424430 modal . setIsSubmitting ( true ) ;
425431 modal . setPushError ( null ) ;
426432
427433 try {
428434 const pushFn =
429- store . pushMode === "sync"
435+ pushMode === "sync"
430436 ? trpcClient . git . sync
431- : store . pushMode === "publish"
437+ : pushMode === "publish"
432438 ? trpcClient . git . publish
433439 : trpcClient . git . push ;
434440
@@ -439,13 +445,13 @@ export function useGitInteraction(
439445 "message" in result
440446 ? result . message
441447 : `Pull: ${ result . pullMessage } , Push: ${ result . pushMessage } ` ;
442- trackGitAction ( taskId , store . pushMode , false ) ;
448+ trackGitAction ( taskId , pushMode , false ) ;
443449 modal . setPushError ( message || "Push failed." ) ;
444450 modal . setPushState ( "error" ) ;
445451 return ;
446452 }
447453
448- trackGitAction ( taskId , store . pushMode , true ) ;
454+ trackGitAction ( taskId , pushMode , true ) ;
449455
450456 if ( result . state ) {
451457 updateGitCacheFromSnapshot ( queryClient , repoPath , result . state ) ;
0 commit comments