@@ -1052,35 +1052,39 @@ const Changes: FC<{
10521052 const [ branchId , setBranchId ] = useState < string | null > ( null ) ;
10531053 const branch = branchComboboxItems . find ( ( item ) => item . id === branchId ) ?? branchComboboxItems [ 0 ] ;
10541054
1055- const commit = async ( ) => {
1056- if ( ! branch ) return ;
1055+ const [ commitCreatePending , startCommitCreateTransition ] = useTransition ( ) ;
10571056
1058- const changes = await resolveDiffSpecs ( {
1059- source : changesSectionOperand ,
1060- projectId,
1061- queryClient,
1062- } ) ;
1063- if ( ! changes ) return ;
1057+ const commit = ( ) => {
1058+ startCommitCreateTransition ( async ( ) => {
1059+ if ( ! branch ) return ;
10641060
1065- await commitCreate . mutateAsync (
1066- {
1061+ const changes = await resolveDiffSpecs ( {
1062+ source : changesSectionOperand ,
10671063 projectId,
1068- relativeTo : {
1069- type : "referenceBytes" ,
1070- subject : branch . branch . branchRef ,
1064+ queryClient,
1065+ } ) ;
1066+ if ( ! changes ) return ;
1067+
1068+ await commitCreate . mutateAsync (
1069+ {
1070+ projectId,
1071+ relativeTo : {
1072+ type : "referenceBytes" ,
1073+ subject : branch . branch . branchRef ,
1074+ } ,
1075+ side : "below" ,
1076+ changes,
1077+ message : commitTextareaRef . current ?. value ?? "" ,
1078+ dryRun : false ,
10711079 } ,
1072- side : "below" ,
1073- changes,
1074- message : commitTextareaRef . current ?. value ?? "" ,
1075- dryRun : false ,
1076- } ,
1077- {
1078- onSuccess : ( response ) => {
1079- if ( response . newCommit !== null && commitTextareaRef . current )
1080- commitTextareaRef . current . value = "" ;
1080+ {
1081+ onSuccess : ( response ) => {
1082+ if ( response . newCommit !== null && commitTextareaRef . current )
1083+ commitTextareaRef . current . value = "" ;
1084+ } ,
10811085 } ,
1082- } ,
1083- ) ;
1086+ ) ;
1087+ } ) ;
10841088 } ;
10851089
10861090 const [ open , setOpen ] = useState ( false ) ;
@@ -1131,7 +1135,7 @@ const Changes: FC<{
11311135 } ) ;
11321136
11331137 const commitCommand = useCommand ( commit , {
1134- enabled : outlineMode . _tag === "Default" && ! ! branch ,
1138+ enabled : outlineMode . _tag === "Default" && ! ! branch && ! commitCreatePending ,
11351139 group : "Changes" ,
11361140 commandPalette : { label : "Commit" } ,
11371141 hotkeys : [ { hotkey : "Mod+Enter" } ] ,
@@ -1199,7 +1203,7 @@ const Changes: FC<{
11991203 hotkeys = { commitCommand . hotkeys }
12001204 className = { classes ( uiStyles . button , styles . changesSectionCommitButton ) }
12011205 type = "submit"
1202- disabled = { outlineMode . _tag !== "Default" || ! branch }
1206+ disabled = { outlineMode . _tag !== "Default" || ! branch || commitCreatePending }
12031207 >
12041208 Commit
12051209 </ ShortcutButton >
0 commit comments