@@ -18,6 +18,15 @@ import {
1818import { useAppSettings } from "~/appSettings" ;
1919import { Button } from "~/components/ui/button" ;
2020import { Checkbox } from "~/components/ui/checkbox" ;
21+ import {
22+ AlertDialog ,
23+ AlertDialogClose ,
24+ AlertDialogDescription ,
25+ AlertDialogFooter ,
26+ AlertDialogHeader ,
27+ AlertDialogPopup ,
28+ AlertDialogTitle ,
29+ } from "~/components/ui/alert-dialog" ;
2130import {
2231 Dialog ,
2332 DialogDescription ,
@@ -161,6 +170,8 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
161170 [ activeThreadId ] ,
162171 ) ;
163172 const queryClient = useQueryClient ( ) ;
173+ const [ confirmInitOpen , setConfirmInitOpen ] = useState ( false ) ;
174+ const [ isInitConfirming , setIsInitConfirming ] = useState ( false ) ;
164175 const [ isCommitDialogOpen , setIsCommitDialogOpen ] = useState ( false ) ;
165176 const [ dialogCommitMessage , setDialogCommitMessage ] = useState ( "" ) ;
166177 const [ excludedFiles , setExcludedFiles ] = useState < ReadonlySet < string > > ( new Set ( ) ) ;
@@ -191,6 +202,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
191202 const noneSelected = selectedFiles . length === 0 ;
192203
193204 const initMutation = useMutation ( gitInitMutationOptions ( { cwd : gitCwd , queryClient } ) ) ;
205+ const isInitPending = initMutation . isPending || isInitConfirming ;
194206
195207 const runImmediateGitActionMutation = useMutation (
196208 gitRunStackedActionMutationOptions ( {
@@ -632,19 +644,51 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
632644 [ gitCwd , threadToastData ] ,
633645 ) ;
634646
647+ const confirmGitInit = useCallback ( ( ) => {
648+ if ( isInitPending ) return ;
649+
650+ setIsInitConfirming ( true ) ;
651+ setConfirmInitOpen ( false ) ;
652+ initMutation . mutate ( undefined , {
653+ onSettled : ( ) => {
654+ setIsInitConfirming ( false ) ;
655+ } ,
656+ } ) ;
657+ } , [ initMutation , isInitPending ] ) ;
658+
635659 if ( ! gitCwd ) return null ;
636660
637661 return (
638662 < >
639663 { ! isRepo ? (
640- < Button
641- variant = "outline"
642- size = "xs"
643- disabled = { initMutation . isPending }
644- onClick = { ( ) => initMutation . mutate ( ) }
645- >
646- { initMutation . isPending ? "Initializing..." : "Initialize Git" }
647- </ Button >
664+ < >
665+ < Button
666+ variant = "outline"
667+ size = "xs"
668+ disabled = { isInitPending }
669+ onClick = { ( ) => setConfirmInitOpen ( true ) }
670+ >
671+ { isInitPending ? "Initializing..." : "Initialize Git" }
672+ </ Button >
673+ < AlertDialog open = { confirmInitOpen } onOpenChange = { setConfirmInitOpen } >
674+ < AlertDialogPopup >
675+ < AlertDialogHeader >
676+ < AlertDialogTitle > Initialize Git repository?</ AlertDialogTitle >
677+ < AlertDialogDescription >
678+ This will run{ " " }
679+ < code className = "rounded bg-muted px-1 py-0.5 text-xs" > git init</ code > in{ " " }
680+ < code className = "rounded bg-muted px-1 py-0.5 text-xs break-all" > { gitCwd } </ code >
681+ </ AlertDialogDescription >
682+ </ AlertDialogHeader >
683+ < AlertDialogFooter >
684+ < AlertDialogClose render = { < Button variant = "outline" /> } > Cancel</ AlertDialogClose >
685+ < Button disabled = { isInitPending } onClick = { confirmGitInit } >
686+ Initialize
687+ </ Button >
688+ </ AlertDialogFooter >
689+ </ AlertDialogPopup >
690+ </ AlertDialog >
691+ </ >
648692 ) : (
649693 < Group aria-label = "Git actions" >
650694 { quickActionDisabledReason ? (
0 commit comments